/** * Creates a new executable command for the given unique command ID and the given command listener. * Finally the created command is added to internal list of registered commands. * * @param commandID a unique command ID * @param listener the command listener which executes the command and updates its state * * @return a new executable command * * @see #createToolCommand * @see #createCommandGroup * @see #addCommand(Command) */ @Override public ExecCommand createExecCommand(String commandID, CommandListener listener) { Guardian.assertNotNullOrEmpty("commandID", commandID); ExecCommand command = new ExecCommand(commandID, listener); addCommand(command); return command; }
/** * 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 new tool command for the given unique command ID an the given tool. * Finally the created command is added to internal list of registered commands. * * @param commandID a unique command ID * @param listener the command state listener used to update the tool command's state * @param tool the tool which executes the command and updates its state * * @return a new tool command * * @see #createExecCommand * @see #createCommandGroup * @see #addCommand(Command) */ @Override public ToolCommand createToolCommand(String commandID, CommandStateListener listener, Interactor tool) { Guardian.assertNotNullOrEmpty("commandID", commandID); Guardian.assertNotNull("tool", tool); ToolCommand command = new ToolCommand(commandID, listener, tool); addCommand(command); return command; }
private static ExecCommand createCommand(String commandId, DefaultCommandManager manager) { ExecCommand command = new ExecCommand(); command.setCommandID(commandId); manager.addCommand(command); return command; } }
private void addCommand(String commandId) { ExecCommand command1 = new ExecCommand(); command1.setCommandID(commandId); _manager.addCommand(command1); }
public void testCreateCommandWithConstraintsAndListener() { final CommandListener listener = new CommandListener() { public void actionPerformed(CommandEvent event) { } public void updateState(CommandEvent event) { } }; ExecCommand command = createCommand("test"); command.addCommandListener(listener); _manager.addCommand(command); final Command commandAt = _manager.getCommandAt(0); final CommandListener[] listeners = (CommandListener[]) commandAt.getEventListenerList().getListeners( CommandListener.class); assertEquals(1, listeners.length); assertSame(listener, listeners[0]); }