@Override public Command getCommand(String commandId) { return commandManager.getCommand(commandId); } }
@Override public Category getCategory(final String categoryId) { return commandManager.getCategory(categoryId); }
@Override public ParameterType getParameterType(final String parameterTypeId) { return commandManager.getParameterType(parameterTypeId); }
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); }
/** * Gets the category with the given identifier. If no such category * currently exists, then the category will be created (but be undefined). * * @param categoryId * The identifier to find; must not be <code>null</code>. If * the category is <code>null</code>, then a category suitable * for uncategorized items is defined and returned. * @return The category with the given identifier; this value will never be * <code>null</code>, but it might be undefined. * @see Category */ public final Category getCategory(final String categoryId) { if (categoryId == null) { return getCategory(AUTOGENERATED_CATEGORY_ID); } checkId(categoryId); Category category = categoriesById.get(categoryId); if (category == null) { category = new Category(categoryId); categoriesById.put(categoryId, category); category.addCategoryListener(this); } return category; }
throws NotDefinedException, SerializationException { final int lparenPosition = unescapedIndexOf( serializedParameterizedCommand, PARAMETER_START_CHAR); final String commandId = unescape(commandIdEscaped); final Command command = getCommand(commandId); final IParameter[] parameters = command.getParameters(); final Parameterization[] parameterizations = getParameterizations( serializedParameters, parameters);
ATT_HELP_CONTEXT_ID); final Command command = commandManager.getCommand(commandId); final Category category = commandManager.getCategory(categoryId); if (!category.isDefined()) { addWarning( returnType = null; } else { returnType = commandManager.getParameterType(returnTypeId);
@Override public final void commandChanged(final CommandEvent commandEvent) { if (commandEvent.isDefinedChanged()) { final Command command = commandEvent.getCommand(); final String commandId = command.getId(); final boolean commandIdAdded = command.isDefined(); if (commandIdAdded) { definedHandleObjects.add(command); } else { definedHandleObjects.remove(command); } if (isListenerAttached()) { fireCommandManagerChanged(new CommandManagerEvent(this, commandId, commandIdAdded, true, null, false, false)); } } }
@Override public Object compute(IEclipseContext context, String contextKey) { if (service == null) { IEclipseContext root = getRootContext(context); manager = new CommandManager(); root.set(CommandManager.class.getName(), manager); service = ContextInjectionFactory.make(CommandServiceImpl.class, root); } return service; }
final int configurationElementCount, final CommandManager commandManager) { Category undefCat = commandManager.getCategory(null); if (!undefCat.isDefined()) { commandManager.defineUncategorizedCategory( WorkbenchMessages.CommandService_AutogeneratedCategoryName, WorkbenchMessages.CommandService_AutogeneratedCategoryDescription); ATT_DESCRIPTION); final Category category = commandManager.getCategory(categoryId); if (!category.isDefined()) { category.define(name, description);
/** * Gets the command {@link ParameterType} with the given identifier. If no * such command parameter type currently exists, then the command parameter * type will be created (but will be undefined). * * @param parameterTypeId * The identifier to find; must not be <code>null</code> and * must not be zero-length. * @return The {@link ParameterType} with the given identifier; this value * will never be <code>null</code>, but it might be undefined. * @since 3.2 */ public final ParameterType getParameterType(final String parameterTypeId) { checkId(parameterTypeId); ParameterType parameterType = parameterTypesById.get(parameterTypeId); if (parameterType == null) { parameterType = new ParameterType(parameterTypeId); parameterTypesById.put(parameterTypeId, parameterType); parameterType.addListener(this); } return parameterType; }
/** * @since 3.4 */ @Override public void notDefined(IAction action, NotDefinedException exception) { String actionDefinitionId = action.getActionDefinitionId(); if (actionDefinitionId==null || !applicabilityChecker.isApplicable(action)) { return; } commandManager.fireNotDefined(actionDefinitionId, exception); }
/** * Adds a listener to this command manager. The listener will be notified * when the set of defined commands changes. This can be used to track the * global appearance and disappearance of commands. * * @param listener * The listener to attach; must not be <code>null</code>. */ public void addCommandManagerListener( final ICommandManagerListener listener) { addListenerObject(listener); }
/** * {@inheritDoc} * * @since 3.2 */ @Override public final void parameterTypeChanged(final ParameterTypeEvent parameterTypeEvent) { if (parameterTypeEvent.isDefinedChanged()) { final ParameterType parameterType = parameterTypeEvent.getParameterType(); final String parameterTypeId = parameterType.getId(); final boolean parameterTypeIdAdded = parameterType.isDefined(); if (parameterTypeIdAdded) { definedParameterTypeIds.add(parameterTypeId); } else { definedParameterTypeIds.remove(parameterTypeId); } fireCommandManagerChanged(new CommandManagerEvent(this, parameterTypeId, parameterTypeIdAdded, true)); } }
throws NotDefinedException, SerializationException { final int lparenPosition = unescapedIndexOf( serializedParameterizedCommand, PARAMETER_START_CHAR); final String commandId = unescape(commandIdEscaped); final Command command = getCommand(commandId); final IParameter[] parameters = command.getParameters(); final Parameterization[] parameterizations = getParameterizations( serializedParameters, parameters);
/** * @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); }
@Override public void categoryChanged(CategoryEvent categoryEvent) { if (categoryEvent.isDefinedChanged()) { final Category category = categoryEvent.getCategory(); final String categoryId = category.getId(); final boolean categoryIdAdded = category.isDefined(); if (categoryIdAdded) { definedCategoryIds.add(categoryId); } else { definedCategoryIds.remove(categoryId); } if (isListenerAttached()) { fireCommandManagerChanged(new CommandManagerEvent(this, null, false, false, categoryId, categoryIdAdded, true)); } } }
/** * Gets the category with the given identifier. If no such category * currently exists, then the category will be created (but be undefined). * * @param categoryId * The identifier to find; must not be <code>null</code>. If * the category is <code>null</code>, then a category suitable * for uncategorized items is defined and returned. * @return The category with the given identifier; this value will never be * <code>null</code>, but it might be undefined. * @see Category */ public Category getCategory(final String categoryId) { if (categoryId == null) { return getCategory(AUTOGENERATED_CATEGORY_ID); } checkId(categoryId); Category category = categoriesById.get(categoryId); if (category == null) { category = new Category(categoryId); categoriesById.put(categoryId, category); category.addCategoryListener(this); } return category; }
@PostConstruct void init(IEclipseContext context) { // global command service. There can be only one ... per application :-) CommandManager manager = context.get(CommandManager.class); if (manager == null) { manager = new CommandManager(); context.set(CommandManager.class, manager); } CommandServiceImpl service = ContextInjectionFactory.make(CommandServiceImpl.class, context); context.set(ECommandService.class, service); // handler service context.set(EHandlerService.class.getName(), new HandlerServiceCreationFunction()); // provide the initial application context, just in case. HandlerServiceImpl.push(context, null); }
/** * Gets the command {@link ParameterType} with the given identifier. If no * such command parameter type currently exists, then the command parameter * type will be created (but will be undefined). * * @param parameterTypeId * The identifier to find; must not be <code>null</code> and * must not be zero-length. * @return The {@link ParameterType} with the given identifier; this value * will never be <code>null</code>, but it might be undefined. * @since 3.2 */ public final ParameterType getParameterType(final String parameterTypeId) { checkId(parameterTypeId); ParameterType parameterType = parameterTypesById.get(parameterTypeId); if (parameterType == null) { parameterType = new ParameterType(parameterTypeId); parameterTypesById.put(parameterTypeId, parameterType); parameterType.addListener(this); } return parameterType; }