public CommandGroup(String commandGroupID, CommandStateListener listener) { super(commandGroupID); addCommandStateListener(listener); }
/** * Adds a command listener. * * @param l the command listener */ public void addCommandStateListener(CommandStateListener l) { addEventListener(CommandStateListener.class, l); }
public String[] getGroupItems() { return getProperty(ACTION_KEY_GROUP_ITEMS, new String[0]); }
/** * 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; }
/** * Creates a menu item (a <code>JMenu</code> instance) for this command group. */ @Override public JMenuItem createMenuItem() { return getCommandUIFactory().createMenuItem(this); }
public void setGroupItems(String[] groupItems) { setProperty(ACTION_KEY_GROUP_ITEMS, groupItems.clone()); }
/** * Removes a command listener. * * @param l the command listener */ public void removeCommandStateListener(CommandStateListener l) { removeEventListener(CommandStateListener.class, l); }
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 new command group command for the given unique command ID an the given command state listener. * Finally the created command group is added to internal list of registered commands. * * @param commandGroupID a unique command group ID * @param listener the command state listener used to update the command group state * * @return a new command group * * @see #createExecCommand * @see #createToolCommand * @see #addCommand(Command) */ @Override public CommandGroup createCommandGroup(String commandGroupID, CommandStateListener listener) { Guardian.assertNotNullOrEmpty("commandGroupID", commandGroupID); CommandGroup commandGroup = new CommandGroup(commandGroupID, listener); addCommand(commandGroup); return commandGroup; }
/** * 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 an appropriate tool bar button for this command. */ @Override public AbstractButton createToolBarButton() { return getCommandUIFactory().createToolBarButton(this); }
@Override public void configure(ConfigurationElement config) throws CoreException { super.configure(config); ConfigurationElement itemsElement = config.getChild(ELEMENT_NAME_ITEMS); if (itemsElement == null) { return; } ConfigurationElement[] children = itemsElement.getChildren(); String[] groupItems = new String[children.length]; for (int i = 0; i < children.length; i++) { ConfigurationElement child = children[i]; String childName = child.getName(); switch (childName) { case ELEMENT_NAME_ACTION_ID: case ELEMENT_NAME_ACTION_GROUP_ID: groupItems[i] = child.getValue().trim(); break; case ELEMENT_NAME_SEPARATOR: groupItems[i] = null; break; default: Module declaringModule = config.getDeclaringExtension().getDeclaringModule(); throw new CoreException(String.format("Module [%s]: '%s' is an unknown 'groupItems' element", declaringModule.getName(), childName)); } } setProperty(ACTION_KEY_GROUP_ITEMS, groupItems); }