private void registerActionGroups(ModuleContext moduleContext) { actionGroupList = BeamCoreActivator.loadExecutableExtensions(moduleContext, "actionGroups", "actionGroup", CommandGroup.class); HashMap<String, CommandGroup> actionGroupMap = new HashMap<>(2 * actionGroupList.size() + 1); for (CommandGroup actionGroup : new ArrayList<>(actionGroupList)) { final String actionGroupId = actionGroup.getCommandID(); final CommandGroup existingActionGroup = actionGroupMap.get(actionGroupId); if (existingActionGroup != null) { moduleContext.getLogger().warning(String.format("Action group [%s] has been redeclared!\n", actionGroupId)); actionGroupMap.remove(actionGroupId); actionGroupList.remove(existingActionGroup); } actionGroupMap.put(actionGroupId, actionGroup); } }
/** * Creates a menu item for the given command group. * * @param commandGroup the command group, must not be <code>null</code> * * @return the menu item */ public JMenuItem createMenuItem(CommandGroup commandGroup) { JMenu menu = new JMenu(commandGroup.getAction()); menu.setName(commandGroup.getCommandID()); // Ensure that the menu has some text, so that is guranteed to be visible for the user if (menu.getText() == null) { menu.setText(commandGroup.getCommandID()); } enableHelp(menu, commandGroup); return menu; }
/** * Creates a tool bar button for the given command group. * * @param commandGroup the command group, must not be <code>null</code> * * @return the tool bar button */ public AbstractButton createToolBarButton(CommandGroup commandGroup) { AbstractButton button = ToolButtonFactory.createButton(commandGroup.getAction(), false); button.setName(commandGroup.getCommandID()); return button; }