private void createMenuBar() { // Delegate to the menu builder, which will create the // menus based on installed plugins. MenuBuilder menuBuilder = new MenuBuilder(workspace.getEditorKit()); setJMenuBar(menuBuilder.buildMenu()); menuActions.addAll(menuBuilder.getActions()); }
public JMenuBar buildMenu() { JMenuBar menuBar = new JMenuBar(); parentChildMap.clear(); Map<String, MenuActionPlugin> idPluginMap = getPlugins(); for (MenuActionPlugin plugin : idPluginMap.values()) { MenuActionPlugin parent = idPluginMap.get(plugin.getParentId()); getChildren(parent).add(plugin); } // Should now have a hierarchy of plugins List<MenuActionPlugin> topLevelMenus = getSortedList(getChildren(null)); for (MenuActionPlugin plugin : topLevelMenus) { if (!isPopupMenuItem(plugin)) { addMenu(plugin, menuBar); } } return menuBar; }
private void addMenu(MenuActionPlugin plugin, JComponent menuContainer) { logCreateMenu(plugin, menuContainer); List<MenuActionPlugin> children = getSortedList(getChildren(plugin)); if (!children.isEmpty()) { //this is a recursive function, it is important to have a stop condition buildCompositeMenu(plugin, menuContainer, children); } else { if (plugin.isDynamic()) { buildDynamicMenu(plugin, menuContainer); } else { if (hasParentMenu(plugin)) { buildInnerMenu(plugin, menuContainer); } else { buildTopLevelMenu(plugin, menuContainer); } } } }
private void showPopupMenu(MouseEvent e) { getPopupMenuId().ifPresent(popupMenuId -> { MenuBuilder menuBuilder = new MenuBuilder(eKit); JPopupMenu popupMenu = menuBuilder.buildPopupMenu(popupMenuId); popupMenu.show(this, e.getX(), e.getY()); }); }
private void buildInnerMenu(MenuActionPlugin plugin, JComponent menuContainer) { try { ProtegeAction action = plugin.newInstance(); final JMenuItem menuItem = createMenuItem(plugin, action); KeyStroke ks = plugin.getAccelerator(); ks = fixAcceleratorForMacOSX(ks); menuItem.setAccelerator(ks); menuContainer.add(menuItem); invokeInnerMenuMethods(action, menuItem, menuContainer); actions.add(action); } catch (Exception e) { logger.error(e); } }
Menu mainMenu = new MenuBuilder().buildMenu(MenuDefinition.class);
private void buildCompositeMenu(MenuActionPlugin plugin, JComponent menuContainer, List<MenuActionPlugin> children) { // Add a JMenu JMenu menu = new JMenu(plugin.getName()); menuContainer.add(menu); MenuActionPlugin lastPlugin = null; for (MenuActionPlugin childPlugin : children) { if (lastPlugin != null) { if (!lastPlugin.getGroup().equals(childPlugin.getGroup())) { menu.addSeparator(); } } addMenu(childPlugin, menu); //recursive call lastPlugin = childPlugin; } }
private void buildInnerMenu(MenuActionPlugin plugin, JComponent menuContainer) { try { ProtegeAction action = plugin.newInstance(); final JMenuItem menuItem = createMenuItem(plugin, action); KeyStroke ks = plugin.getAccelerator(); ks = fixAcceleratorForMacOSX(ks); menuItem.setAccelerator(ks); menuContainer.add(menuItem); invokeInnerMenuMethods(action, menuItem, menuContainer); actions.add(action); } catch (Exception e) { logger.warn("Error building menu: {}", e.getMessage(), e); } catch (NoClassDefFoundError noClass) { logger.error("Error loading menu plugin {} ({})", plugin.getId(), plugin.getName()); } }
private void showPopupMenu(MouseEvent e) { if (!getPopupMenuId().isPresent()) { return; } MenuBuilder menuBuilder = new MenuBuilder(eKit); PopupMenuId popupMenuId = getPopupMenuId().get(); JPopupMenu popupMenu = menuBuilder.buildPopupMenu(popupMenuId); popupMenu.show(this, e.getX(), e.getY()); }
MenuBuilder menuBuilder =new MenuBuilder(this); MenuInflater inflater = new MenuInflater(this); inflater.inflate(R.menu.menu, menuBuilder); MenuPopupHelper optionsMenu = new MenuPopupHelper(this, menuBuilder, view); optionsMenu.setForceShowIcon(true); optionsMenu.show();
private void buildCompositeMenu(MenuActionPlugin plugin, JComponent menuContainer, List<MenuActionPlugin> children) { // Add a JMenu JMenu menu = new JMenu(plugin.getName()); menuContainer.add(menu); MenuActionPlugin lastPlugin = null; for (MenuActionPlugin childPlugin : children) { if (lastPlugin != null) { if (!lastPlugin.getGroup().equals(childPlugin.getGroup())) { menu.addSeparator(); } } addMenu(childPlugin, menu); //recursive call lastPlugin = childPlugin; } }
private void addMenu(MenuActionPlugin plugin, JComponent menuContainer) { logCreateMenu(plugin, menuContainer); List<MenuActionPlugin> children = getSortedList(getChildren(plugin)); if (!children.isEmpty()) { //this is a recursive function, it is important to have a stop condition buildCompositeMenu(plugin, menuContainer, children); } else { if (plugin.isDynamic()) { buildDynamicMenu(plugin, menuContainer); } else { if (hasParentMenu(plugin)) { buildInnerMenu(plugin, menuContainer); } else { buildTopLevelMenu(plugin, menuContainer); } } } }
public JMenuBar buildMenu() { JMenuBar menuBar = new JMenuBar(); parentChildMap.clear(); Map<String, MenuActionPlugin> idPluginMap = getPlugins(); for (MenuActionPlugin plugin : idPluginMap.values()) { MenuActionPlugin parent = idPluginMap.get(plugin.getParentId()); getChildren(parent).add(plugin); if (logger.isDebugEnabled()) { logger.debug("" + parent + " parent of " + plugin); } } // Should now have a hierarchy of plugins List<MenuActionPlugin> topLevelMenus = getSortedList(getChildren(null)); for (MenuActionPlugin plugin : topLevelMenus) { addMenu(plugin, menuBar); } return menuBar; }
private void createMenuBar() { // Delegate to the menu builder, which will create the // menus based on installed plugins. MenuBuilder menuBuilder = new MenuBuilder(workspace.getEditorKit()); setJMenuBar(menuBuilder.buildMenu()); menuActions.addAll(menuBuilder.getActions()); }
private void buildInnerMenu(MenuActionPlugin plugin, JComponent menuContainer) { try { ProtegeAction action = plugin.newInstance(); final JMenuItem menuItem = createMenuItem(plugin, action); KeyStroke ks = plugin.getAccelerator(); ks = fixAcceleratorForMacOSX(ks); menuItem.setAccelerator(ks); menuContainer.add(menuItem); invokeInnerMenuMethods(action, menuItem, menuContainer); actions.add(action); } catch (Exception e) { ProtegeApplication.getErrorLog().logError(e); } catch (NoClassDefFoundError noClass) { logger.error("Error loading menu plugin " + plugin.getId() + "(" + plugin.getName() + ")"); ProtegeApplication.getErrorLog().logError(noClass); } }
public void start() { editorKit.getOWLWorkspace().getOWLSelectionModel().addListener(this::handleSelectionChanged); handleSelectionChanged(); MenuBuilder menuBuilder = new MenuBuilder(editorKit); JPopupMenu popupMenu = menuBuilder.buildPopupMenu(new PopupMenuId(ENTITY_BANNER_MENU_ID)); view.setPopupMenu(popupMenu); }
MenuBuilder menuBuilder =new MenuBuilder(this); MenuInflater inflater = new MenuInflater(this); inflater.inflate(R.menu.menu, menuBuilder); MenuPopupHelper optionsMenu = new MenuPopupHelper(this, menuBuilder, view); optionsMenu.setForceShowIcon(true); optionsMenu.show();
private void buildCompositeMenu(MenuActionPlugin plugin, JComponent menuContainer, List<MenuActionPlugin> children) { // Add a JMenu JMenu menu = new JMenu(plugin.getName()); menuContainer.add(menu); MenuActionPlugin lastPlugin = null; for (MenuActionPlugin childPlugin : children) { if (lastPlugin != null) { if (!lastPlugin.getGroup().equals(childPlugin.getGroup())) { menu.addSeparator(); } } addMenu(childPlugin, menu); //recursive call lastPlugin = childPlugin; } }
private void addMenu(MenuActionPlugin plugin, JComponent menuContainer) { List<MenuActionPlugin> children = getSortedList(getChildren(plugin)); if (!children.isEmpty()) { //this is a recursive function, it is important to have a stop condition buildCompositeMenu(plugin, menuContainer, children); } else { if (plugin.isDynamic()) { buildDynamicMenu(plugin, menuContainer); } else { if (hasParentMenu(plugin)) { buildInnerMenu(plugin, menuContainer); } else { buildTopLevelMenu(plugin, menuContainer); } } } }
public JMenuBar buildMenu() { JMenuBar menuBar = new JMenuBar(); parentChildMap.clear(); Map<String, MenuActionPlugin> idPluginMap = getPlugins(); for (MenuActionPlugin plugin : idPluginMap.values()) { MenuActionPlugin parent = idPluginMap.get(plugin.getParentId()); getChildren(parent).add(plugin); if (logger.isDebugEnabled()) { logger.debug("" + parent + " parent of " + plugin); } } // Should now have a hierarchy of plugins List<MenuActionPlugin> topLevelMenus = getSortedList(getChildren(null)); for (MenuActionPlugin plugin : topLevelMenus) { addMenu(plugin, menuBar); } return menuBar; }