Skip to content

Commit 55bc0f2

Browse files
committed
ModuleSearchResult: prepend menu root in brackets
For menus other than the main application menu, it is nice to know in which menu a module resides.
1 parent 0134042 commit 55bc0f2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/scijava/search/module/ModuleSearchResult.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import org.scijava.MenuEntry;
3636
import org.scijava.MenuPath;
37+
import org.scijava.UIDetails;
3738
import org.scijava.input.Accelerator;
3839
import org.scijava.module.ModuleInfo;
3940
import org.scijava.search.SearchResult;
@@ -103,8 +104,13 @@ private String getMenuPath(boolean includeLeaf) {
103104
}
104105

105106
private String getMenuPath(boolean includeLeaf, String separator) {
107+
final String menuRoot = info.getMenuRoot();
108+
final boolean isContextMenu = menuRoot != null && //
109+
!menuRoot.equals(UIDetails.APPLICATION_MENU_ROOT);
110+
final String prefix = isContextMenu ? "[" + menuRoot + "]" : "";
106111
final MenuPath menuPath = info.getMenuPath();
107-
if (menuPath == null) return "";
108-
return menuPath.getMenuString(includeLeaf).replace(" > ", separator);
112+
if (menuPath == null) return prefix;
113+
final String menuString = menuPath.getMenuString(includeLeaf);
114+
return prefix + " " + menuString.replace(" > ", separator);
109115
}
110116
}

0 commit comments

Comments
 (0)