@Override public Command getCommand(String commandId) { return commandManager.getCommand(commandId); } }
public static CommandManager fromCommand(String command) { for (CommandManager commandManager : values()) { if (commandManager.getCommand().equals(command)) { return commandManager; } } return null; // or throw exception, whatever fits best for your code }
@Override public Command getCommand(final String commandId) { return commandManager.getCommand(commandId); }
public static CommandManager getCommandManager(String command) { for (CommandManager cManager : CommandManager.values()) { if (command.equals(cManager.getCommand())) { return cManager; } } throw new IllegalArgumentException(command); }
getCommand((String) commandIdItr.next());
getCommand((String) commandIdItr.next());
/** * Gets the best active binding for a command. The best binding is the one * that would be most appropriate to show in a menu. Bindings which belong * to a child scheme are given preference over those in a parent scheme. * Bindings which belong to a particular locale or platform are given * preference over those that do not. The rest of the calculaton is based * most on various concepts of "length", as well as giving some modifier * keys preference (e.g., <code>Alt</code> is less likely to appear than * <code>Ctrl</code>). * * @param commandId * The identifier of the command for which the best active * binding should be retrieved; must not be <code>null</code>. * @return The trigger sequence for the best binding; may be * <code>null</code> if no bindings are active for the given * command. * @since 3.2 */ public final TriggerSequence getBestActiveBindingFor(final String commandId) { return getBestActiveBindingFor(new ParameterizedCommand(commandManager.getCommand(commandId), null)); }
/** * <p> * Returns the active bindings for a particular command identifier. This * method operates in O(n) time over the number of bindings. * </p> * <p> * This method completes in <code>O(1)</code>. If the active bindings are * not yet computed, then this completes in <code>O(nn)</code>, where * <code>n</code> is the number of bindings. * </p> * * @param commandId * The identifier of the command whose bindings are requested. * This argument may be <code>null</code>. It is assumed that * the command has no parameters. * @return The array of active triggers (<code>TriggerSequence</code>) * for a particular command identifier. This value is guaranteed not * to be <code>null</code>, but it may be empty. */ public TriggerSequence[] getActiveBindingsFor(final String commandId) { final ParameterizedCommand parameterizedCommand = new ParameterizedCommand( commandManager.getCommand(commandId), null); return getActiveBindingsFor(parameterizedCommand); }
/** * Gets the best active binding for a command. The best binding is the one * that would be most appropriate to show in a menu. Bindings which belong * to a child scheme are given preference over those in a parent scheme. * Bindings which belong to a particular locale or platform are given * preference over those that do not. The rest of the calculaton is based * most on various concepts of "length", as well as giving some modifier * keys preference (e.g., <code>Alt</code> is less likely to appear than * <code>Ctrl</code>). * * @param commandId * The identifier of the command for which the best active * binding should be retrieved; must not be <code>null</code>. * @return The trigger sequence for the best binding; may be * <code>null</code> if no bindings are active for the given * command. */ public final TriggerSequence getBestActiveBindingFor(final String commandId) { return getBestActiveBindingFor(new ParameterizedCommand(commandManager.getCommand(commandId), null)); }
/** * Gets the best active binding for a command. The best binding is the one * that would be most appropriate to show in a menu. Bindings which belong * to a child scheme are given preference over those in a parent scheme. * Bindings which belong to a particular locale or platform are given * preference over those that do not. The rest of the calculaton is based * most on various concepts of "length", as well as giving some modifier * keys preference (e.g., <code>Alt</code> is less likely to appear than * <code>Ctrl</code>). * * @param commandId * The identifier of the command for which the best active * binding should be retrieved; must not be <code>null</code>. * @return The trigger sequence for the best binding; may be * <code>null</code> if no bindings are active for the given * command. * @since 3.2 */ public TriggerSequence getBestActiveBindingFor(final String commandId) { return getBestActiveBindingFor(new ParameterizedCommand(commandManager.getCommand(commandId), null)); }
/** * <p> * Returns the active bindings for a particular command identifier. This * method operates in O(n) time over the number of bindings. * </p> * <p> * This method completes in <code>O(1)</code>. If the active bindings are * not yet computed, then this completes in <code>O(nn)</code>, where * <code>n</code> is the number of bindings. * </p> * * @param commandId * The identifier of the command whose bindings are requested. * This argument may be <code>null</code>. It is assumed that * the command has no parameters. * @return The array of active triggers (<code>TriggerSequence</code>) * for a particular command identifier. This value is guaranteed not * to be <code>null</code>, but it may be empty. */ public final TriggerSequence[] getActiveBindingsFor(final String commandId) { final ParameterizedCommand parameterizedCommand = new ParameterizedCommand( commandManager.getCommand(commandId), null); return getActiveBindingsFor(parameterizedCommand); }
/** * <p> * Returns the active bindings for a particular command identifier. This * method operates in O(n) time over the number of bindings. * </p> * <p> * This method completes in <code>O(1)</code>. If the active bindings are * not yet computed, then this completes in <code>O(nn)</code>, where * <code>n</code> is the number of bindings. * </p> * * @param commandId * The identifier of the command whose bindings are requested. * This argument may be <code>null</code>. It is assumed that * the command has no parameters. * @return The array of active triggers (<code>TriggerSequence</code>) * for a particular command identifier. This value is guaranteed not * to be <code>null</code>, but it may be empty. */ public final TriggerSequence[] getActiveBindingsFor(final String commandId) { final ParameterizedCommand parameterizedCommand = new ParameterizedCommand( commandManager.getCommand(commandId), null); return getActiveBindingsFor(parameterizedCommand); }
@Override public ICommand getCommand(String commandId) { final Command command = commandManager.getCommand(commandId); if (!command.isDefined()) { command.setHandler(HandlerServiceImpl.getHandler(commandId)); } return new CommandLegacyWrapper(command, bindingManager); }
@Override public Command defineCommand(String id, String name, String description, Category category, IParameter[] parameters) { Command cmd = commandManager.getCommand(id); if (!cmd.isDefined()) { cmd.define(name, description, category, parameters); cmd.setHandler(HandlerServiceImpl.getHandler(id)); } return cmd; }
@Override public Command defineCommand(String id, String name, String description, Category category, IParameter[] parameters, String helpContextId) { Command cmd = commandManager.getCommand(id); if (!cmd.isDefined()) { cmd.define(name, description, category, parameters, null, helpContextId); cmd.setHandler(HandlerServiceImpl.getHandler(id)); } return cmd; }
public void preExecute(IAction action, Event event) { String actionDefinitionId = action.getActionDefinitionId(); if (actionDefinitionId==null || !applicabilityChecker.isApplicable(action)) { return; } Command command = commandManager.getCommand(actionDefinitionId); ExecutionEvent executionEvent = new ExecutionEvent(command, Collections.EMPTY_MAP, event, null); commandManager.firePreExecute(actionDefinitionId, executionEvent); }
public final void bindingManagerChanged(final BindingManagerEvent event) { if (event.isActiveBindingsChanged()) { final Iterator listenerItr = registeredListeners.entrySet() .iterator(); while (listenerItr.hasNext()) { final Map.Entry entry = (Map.Entry) listenerItr.next(); final String commandId = (String) entry.getKey(); final Command command = commandManager .getCommand(commandId); final ParameterizedCommand parameterizedCommand = new ParameterizedCommand( command, null); if (event.isActiveBindingsChangedFor(parameterizedCommand)) { Object value = entry.getValue(); PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(event .getManager(), IAction.TEXT, null, null); if (value instanceof ListenerList) { Object[] listeners= ((ListenerList) value).getListeners(); for (int i = 0; i < listeners.length; i++) { final IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i]; listener.propertyChange(propertyChangeEvent); } } else { final IPropertyChangeListener listener = (IPropertyChangeListener) value; listener.propertyChange(propertyChangeEvent); } } } } }
/** * @since 3.4 */ @Override public void preExecute(IAction action, Event event) { String actionDefinitionId = action.getActionDefinitionId(); if (actionDefinitionId==null || !applicabilityChecker.isApplicable(action)) { return; } Command command = commandManager.getCommand(actionDefinitionId); ExecutionEvent executionEvent = new ExecutionEvent(command, Collections.EMPTY_MAP, event, null); commandManager.firePreExecute(actionDefinitionId, executionEvent); }
/** * @since 3.4 */ @Override public void preExecute(IAction action, Event event) { String actionDefinitionId = action.getActionDefinitionId(); if (actionDefinitionId==null || !applicabilityChecker.isApplicable(action)) { return; } Command command = commandManager.getCommand(actionDefinitionId); ExecutionEvent executionEvent = new ExecutionEvent(command, Collections.EMPTY_MAP, event, null); commandManager.firePreExecute(actionDefinitionId, executionEvent); }
@SuppressWarnings("restriction") @Override public void commandManagerChanged(CommandManagerEvent commandManagerEvent) { if (commandManagerEvent.isCommandChanged()) { if (commandManagerEvent.isCommandDefined()) { final String commandId = commandManagerEvent.getCommandId(); if (findCommand(commandId) != null) { return; } final Command command = commandManagerEvent.getCommandManager().getCommand( commandId); if (command.getHandler() == null) { command.setHandler(HandlerServiceImpl.getHandler(commandId)); } try { MCategory categoryModel = findCategory(command.getCategory().getId()); final MCommand createdCommand = createCommand(command, modelService, categoryModel); application.getCommands().add(createdCommand); } catch (NotDefinedException e) { Activator.getDefault().getLogService() .log(0, "Failed to create command " + commandId, e); //$NON-NLS-1$ } } } } };