Open imagejan opened 6 years ago
I created a small test project (https://github.com/imagejan/test-menu-path), containing:
in the same submenu Plugins > ASubmenu.
When placing the project's jar file (Test_Menu_Path-0.1.0-SNAPSHOT.jar
) in ./Fiji.app/plugins/
, all three menu entries appear in ASubmenu in the upper part of the Plugins menu.
However, when the jar file is placed in ./Fiji.app/jars/
(where the IJ1 plugin isn't recognized), the ASubmenu entry ends up being in the lower part of Plugins, below the separator.
Menu entries are sorted alphabetically if and only if their menu weight is the same.
DEFAULT_WEIGHT = Double.POSITIVE_INFINITY
. So in order to unify menus of Legacy and IJ2 commands, we need to either:
(Maybe I'm missing something here.)
For the record: here's a script I used to display the menu weights for each menu entry:
#@ MenuService menus
def printMenu(menu, prefix) {
entry = menu.getMenuEntry()
if(entry!=null) println "${prefix}[${entry.getWeight()}] ${entry.getName()}"
if (!menu.isLeaf()) {
menu.getChildren().each {
printMenu(it, prefix+" ")
}
}
}
printMenu(menus.getMenu(), "")
Currently, legacy-compatible IJ2 commands end up in a menu group separate from IJ1 plugins, e.g. the
Debug
,Sandbox
,AutoRun
,Kymograph
andScripting
submenus of the Plugins menu are in a separate section.Let's merge them all and sort them alphabetically.
See also https://github.com/PreibischLab/BigStitcher/issues/7#issuecomment-342518669.
The adding and sorting is supposed to happen in
IJ1Helper#addMenuItems()
method:https://github.com/imagej/imagej-legacy/blob/dd36b3ffd2d8c8cc392a7ade88e2edd87e172175/src/main/java/net/imagej/legacy/IJ1Helper.java#L775-L850