private void initCommandManager() { commandManager = new DefaultCommandManager(); commandUIFactory = new DefaultCommandUIFactory(); commandUIFactory.setCommandManager(commandManager); commandMenuInserter = new DefaultCommandMenuInserter(commandManager); }
/** * Creates a menu item (a <code>JMenuItem</code> or <code>JCheckBoxMenuItem</code> instance) for this command * group. */ @Override public JMenuItem createMenuItem() { return getCommandUIFactory().createMenuItem(this); }
/** * Creates an appropriate tool bar button for this command. */ @Override public AbstractButton createToolBarButton() { return getCommandUIFactory().createToolBarButton(this); }
public void testCreateOneCommand() { assertEquals(0, _manager.getNumCommands()); addCommand("test"); assertEquals(1, _manager.getNumCommands()); final Command command = _manager.getExecCommand("test"); assertNotNull(command); final Command commandAt = _manager.getCommandAt(0); assertSame(command, commandAt); }
private static ExecCommand createCommand(String commandId, DefaultCommandManager manager) { ExecCommand command = new ExecCommand(); command.setCommandID(commandId); manager.addCommand(command); return command; } }
/** * Calls the <code>updateState</code> method of all registered commands. */ @Override public void updateState() { final int n = getNumCommands(); for (int i = 0; i < n; i++) { getCommandAt(i).updateState(); } }
/** * Updates the component tree of all commands since the Java look-and-feel has changed. */ @Override public void updateComponentTreeUI() { final int n = getNumCommands(); for (int i = 0; i < n; i++) { getCommandAt(i).updateComponentTreeUI(); } }
/** * Index out of bounds exception wenn der index out of range ist. */ public void testGetCommandAt_IndexOutOfBoundsException() { addCommand("test"); assertNotNull(_manager.getCommandAt(0)); try { _manager.getCommandAt(1); fail("IndexOutOfBoundsException not expected"); } catch (IndexOutOfBoundsException e) { // Exception expected } }
@Override public void configure(ConfigurationElement config) throws CoreException { super.configure(config); Boolean resBoolean = getConfigBoolean(config, "selected"); if (resBoolean != null) { setSelected(resBoolean); } }
@Override public void configure(ConfigurationElement config) throws CoreException { super.configure(config); Boolean confBoolean = getConfigBoolean(config, "toggle"); if (confBoolean != null) { setToggle(confBoolean); } } }
/** * Causes this command to fire the 'check status' event to all of its listeners. */ public void updateState() { updateState(new CommandEvent(this, null, null, null)); fireUpdateState(); }
/** * Creates a menu item (a <code>JMenuItem</code> or <code>JCheckBoxMenuItem</code> instance) for this command * group. */ @Override public JMenuItem createMenuItem() { return getCommandUIFactory().createMenuItem(this); }
/** * Creates an appropriate tool bar button for this command. */ @Override public AbstractButton createToolBarButton() { return getCommandUIFactory().createToolBarButton(this); }
/** * Creates an appropriate tool bar button for this command. */ @Override public AbstractButton createToolBarButton() { return getCommandUIFactory().createToolBarButton(this); }
/** * Creates a menu item (a <code>JMenu</code> instance) for this command group. */ @Override public JMenuItem createMenuItem() { return getCommandUIFactory().createMenuItem(this); }
private static boolean isSortedByName(JMenu menu, CommandManager commandManager) { Command commandGroup = getCommandForMenu(menu, commandManager); return commandGroup != null && commandGroup.getSortChildren(); }
/** * Executes this command with the given command-specific argument. */ public void execute(Object argument) { fireActionPerformed(null, argument); }
/** * Adds a command state listener. * * @param l the command listener */ public void addCommandStateListener(CommandStateListener l) { addEventListener(CommandStateListener.class, l); }
/** * Gets the tool command associated with the given command-ID or <code>null</code> if a tool command with the given * command-ID has not been registered. */ @Override public ToolCommand getToolCommand(String commandID) { final Command command = getCommand(commandID); if (command instanceof ToolCommand) { return (ToolCommand) command; } return null; }
private void addCommand(String commandId) { ExecCommand command1 = new ExecCommand(); command1.setCommandID(commandId); _manager.addCommand(command1); }