/** * Adds an execution listener to this manager. This listener will be * notified if any of the commands controlled by this manager execute. This * can be used to support macros and instrumentation of commands. * * @param listener * The listener to attach; must not be <code>null</code>. */ public void addExecutionListener(final IExecutionListener listener) { if (listener == null) { throw new NullPointerException( "Cannot add a null execution listener"); //$NON-NLS-1$ } if (executionListeners == null) { executionListeners = new ListenerList<>(ListenerList.IDENTITY); // Add an execution listener to every command. executionListener = new ExecutionListener(); final Iterator<NamedHandleObject> commandItr = handleObjectsById.values().iterator(); while (commandItr.hasNext()) { final Command command = (Command) commandItr.next(); command.addExecutionListener(executionListener); } } executionListeners.add(listener); }
/** * Adds an execution listener to this manager. This listener will be * notified if any of the commands controlled by this manager execute. This * can be used to support macros and instrumentation of commands. * * @param listener * The listener to attach; must not be <code>null</code>. */ public final void addExecutionListener(final IExecutionListener listener) { if (listener == null) { throw new NullPointerException( "Cannot add a null execution listener"); //$NON-NLS-1$ } if (executionListeners == null) { executionListeners = new ListenerList<>(ListenerList.IDENTITY); // Add an execution listener to every command. executionListener = new ExecutionListener(); final Iterator<NamedHandleObject> commandItr = handleObjectsById.values().iterator(); while (commandItr.hasNext()) { final Command command = (Command) commandItr.next(); command.addExecutionListener(executionListener); } } executionListeners.add(listener); }
/** * Adds an execution listener to this manager. This listener will be * notified if any of the commands controlled by this manager execute. This * can be used to support macros and instrumentation of commands. * * @param listener * The listener to attach; must not be <code>null</code>. */ public final void addExecutionListener(final IExecutionListener listener) { if (listener == null) { throw new NullPointerException( "Cannot add a null execution listener"); //$NON-NLS-1$ } if (executionListeners == null) { executionListeners = new ListenerList<>(ListenerList.IDENTITY); // Add an execution listener to every command. executionListener = new ExecutionListener(); final Iterator<NamedHandleObject> commandItr = handleObjectsById.values().iterator(); while (commandItr.hasNext()) { final Command command = (Command) commandItr.next(); command.addExecutionListener(executionListener); } } executionListeners.add(listener); }
/** * Gets the command with the given identifier. If no such command currently * exists, then the command will be created (but will be undefined). * * @param commandId * The identifier to find; must not be <code>null</code> and * must not be zero-length. * @return The command with the given identifier; this value will never be * <code>null</code>, but it might be undefined. * @see Command */ public final Command getCommand(final String commandId) { checkId(commandId); Command command = (Command) handleObjectsById.get(commandId); if (command == null) { command = new Command(commandId); command.shouldFireEvents = shouldCommandFireEvents; handleObjectsById.put(commandId, command); command.addCommandListener(this); if (executionListener != null) { command.addExecutionListener(executionListener); } } return command; }
/** * Gets the command with the given identifier. If no such command currently * exists, then the command will be created (but will be undefined). * * @param commandId * The identifier to find; must not be <code>null</code> and * must not be zero-length. * @return The command with the given identifier; this value will never be * <code>null</code>, but it might be undefined. * @see Command */ public Command getCommand(final String commandId) { checkId(commandId); Command command = (Command) handleObjectsById.get(commandId); if (command == null) { command = new Command(commandId); command.shouldFireEvents = shouldCommandFireEvents; handleObjectsById.put(commandId, command); command.addCommandListener(this); if (executionListener != null) { command.addExecutionListener(executionListener); } } return command; }
/** * Gets the command with the given identifier. If no such command currently * exists, then the command will be created (but will be undefined). * * @param commandId * The identifier to find; must not be <code>null</code> and * must not be zero-length. * @return The command with the given identifier; this value will never be * <code>null</code>, but it might be undefined. * @see Command */ public final Command getCommand(final String commandId) { checkId(commandId); Command command = (Command) handleObjectsById.get(commandId); if (command == null) { command = new Command(commandId); command.shouldFireEvents = shouldCommandFireEvents; handleObjectsById.put(commandId, command); command.addCommandListener(this); if (executionListener != null) { command.addExecutionListener(executionListener); } } return command; }