private String getMenuPath(boolean includeLeaf, String separator) { final String menuRoot = info.getMenuRoot(); final boolean isContextMenu = menuRoot != null && // !menuRoot.equals(UIDetails.APPLICATION_MENU_ROOT); final String prefix = isContextMenu ? "[" + menuRoot + "]" : ""; final MenuPath menuPath = info.getMenuPath(); if (menuPath == null) return prefix; final String menuString = menuPath.getMenuString(includeLeaf); return prefix + " " + menuString.replace(" > ", separator); } }
private ShadowMenu addInternal(final ModuleInfo o) { if (o.getMenuPath().isEmpty()) return null; // no menu return addChild(o, 0); }
private String details(final ModuleInfo info) { if (info == null) return "<null>"; String className, classLocation; try { final Class<?> c = info.loadDelegateClass(); className = c.getName(); classLocation = Types.location(c).toString(); } catch (final ClassNotFoundException exc) { className = info.getDelegateClassName(); classLocation = "<invalid>"; } return info.getMenuPath() + " : " + className + " [" + classLocation + "]"; }
private String details(final ModuleInfo info) { if (info == null) return "<null>"; String className, classLocation; try { final Class<?> c = info.loadDelegateClass(); className = c.getName(); classLocation = Types.location(c).toString(); } catch (final ClassNotFoundException exc) { className = info.getDelegateClassName(); classLocation = "<invalid>"; } return info.getMenuPath() + " : " + className + " [" + classLocation + "]"; }
private ShadowMenu addInternal(final ModuleInfo o) { if (o.getMenuPath().isEmpty()) return null; // no menu return addChild(o, 0); }
/** Updates the list of visible commands. */ private void updateCommands() { final ModuleInfo selected = commandsList.getSelectedRow() < 0 ? null : getCommand(); int counter = 0, selectedRow = -1; final String regex = getRegex(); final List<ModuleInfo> matches = new ArrayList<>(); for (final ModuleInfo command : commands) { if (!command.getMenuPath().toString().toLowerCase().matches(regex)) continue; // no match matches.add(command); if (command == selected) selectedRow = counter; counter++; } tableModel.setData(matches); if (selectedRow >= 0) { commandsList.setRowSelectionInterval(selectedRow, selectedRow); } }
void addModuleCompletions(ModuleService moduleService) { if (this.moduleService == moduleService) { return; } this.moduleService = moduleService; for (ModuleInfo info : moduleService.getModules()) { if(info.getMenuPath().getLeaf() != null) { String name = info.getMenuPath().getLeaf().getName().trim(); String headline = "run(\"" + name +"\")"; String description = "<b>" + headline + "</b><p>" + "<a href=\"https://imagej.net/Special:Search/" + name.replace(" ", "%20") + "\">Search imagej wiki for help</a>"; addCompletion(makeListEntry(this, headline, null, description)); } } } }
@Override public String context() { return "/" + getMenuPath(name() != "" + info.getMenuPath().getLeaf(), "/"); }
private ShadowMenu(final Context context, final ModuleInfo moduleInfo, final int menuDepth, final ShadowMenu parent) { setContext(context); if (moduleInfo == null) { this.moduleInfo = null; menuEntry = null; } else { final MenuPath menuPath = moduleInfo.getMenuPath(); // preserve moduleInfo reference only for leaf items final boolean leaf = menuDepth == menuPath.size() - 1; this.moduleInfo = leaf ? moduleInfo : null; menuEntry = menuPath.get(menuDepth); } this.menuDepth = menuDepth; this.parent = parent; children = new HashMap<>(); }
private ShadowMenu(final Context context, final ModuleInfo moduleInfo, final int menuDepth, final ShadowMenu parent) { setContext(context); if (moduleInfo == null) { this.moduleInfo = null; menuEntry = null; } else { final MenuPath menuPath = moduleInfo.getMenuPath(); // preserve moduleInfo reference only for leaf items final boolean leaf = menuDepth == menuPath.size() - 1; this.moduleInfo = leaf ? moduleInfo : null; menuEntry = menuPath.get(menuDepth); } this.menuDepth = menuDepth; this.parent = parent; children = new HashMap<>(); }
public ModuleSearchResult(final ModuleInfo info, final String baseDir) { this.info = info; props = new LinkedHashMap<>(); final MenuPath menuPath = info.getMenuPath(); if (menuPath != null && !menuPath.isEmpty()) { props.put("Menu path", getMenuPath(true)); final MenuEntry menuLeaf = menuPath.getLeaf(); if (menuLeaf != null) { final Accelerator accelerator = menuLeaf.getAccelerator(); if (accelerator != null) { props.put("Shortcut", accelerator.toString()); } } } props.put("Identifier", info.getIdentifier()); props.put("Location", ModuleSearcher.location(info, baseDir)); }
/** * Gets a human-readable title for the module, or null if none. * <p> * We do not use {@link ModuleInfo#getTitle()} because that method tries very * hard to return something in every case, whereas we only want to give really * nice titles, or null if the module is inappropriate. * </p> */ public static String title(final ModuleInfo info) { // use object label, if available final String label = info.getLabel(); if (label != null && !label.isEmpty()) return label; // use name of leaf menu item, if available final MenuPath menuPath = info.getMenuPath(); if (menuPath != null && menuPath.size() > 0) { final MenuEntry menuLeaf = menuPath.getLeaf(); final String menuName = menuLeaf.getName(); if (menuName != null && !menuName.isEmpty()) return menuName; } return null; }
final MenuPath menuPath = info.getMenuPath(); return menuPath == null ? "" : menuPath.getMenuString(false); final MenuPath menuPath = info.getMenuPath(); final MenuEntry menuLeaf = menuPath == null ? null : menuPath.getLeaf(); return menuLeaf == null ? "" : menuLeaf.getAccelerator();
/** Gets the icon path associated with the given module. */ public static String iconPath(final ModuleInfo info) { final String iconPath = info.getIconPath(); if (iconPath != null) return iconPath; final MenuPath menuPath = info.getMenuPath(); return menuPath == null || menuPath.getLeaf() == null ? // null : menuPath.getLeaf().getIconPath(); }
private String menuLabel(final Module module) { final MenuPath menuPath = module.getInfo().getMenuPath(); if (menuPath != null) { final MenuEntry menuLeaf = menuPath.getLeaf(); if (menuLeaf != null) return menuLeaf.getName(); } return module.getInfo().getTitle(); } }
@Override public ModuleInfo getModuleForAccelerator(final Accelerator acc) { for (final ModuleInfo info : getModules()) { final MenuPath menuPath = info.getMenuPath(); if (menuPath == null || menuPath.isEmpty()) continue; if (acc.equals(menuPath.getLeaf().getAccelerator())) return info; } return null; }
@Override public ModuleInfo getModuleForAccelerator(final Accelerator acc) { for (final ModuleInfo info : getModules()) { final MenuPath menuPath = info.getMenuPath(); if (menuPath == null || menuPath.isEmpty()) continue; if (acc.equals(menuPath.getLeaf().getAccelerator())) return info; } return null; }
private ShadowMenu addChild(final ModuleInfo info, final int depth) { final MenuPath menuPath = info.getMenuPath(); final MenuEntry entry = menuPath.get(depth); final boolean leaf = isLeaf(depth, menuPath);
private ShadowMenu addChild(final ModuleInfo info, final int depth) { final MenuPath menuPath = info.getMenuPath(); final MenuEntry entry = menuPath.get(depth); final boolean leaf = isLeaf(depth, menuPath);
private void checkIter(final ShadowMenuIterator iter, final String name) { assertTrue(iter.hasNext()); final ModuleInfo info = iter.next(); assertEquals(name, info.getMenuPath().getLeaf().getName()); }