Interface ICommandService
- All Superinterfaces:
- IDisposable
Provides services related to the command architecture within the workbench. This service can be used to access the set of commands and command categories.
This service can be acquired from your service locator:
ICommandService service = (ICommandService) getSite().getService(ICommandService.class);
- This service is available globally.
- Since:
- 3.1
- Restriction:
- This interface is not intended to be implemented by clients.
- Restriction:
- This interface is not intended to be extended by clients.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe identifier of the category in which all auto-generated commands will appear.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddExecutionListener(IExecutionListener listener) Adds an execution listener to the command service.voiddefineUncategorizedCategory(String name, String description) Sets the name and description of the category for uncategorized commands.deserialize(String serializedParameterizedCommand) Returns aParameterizedCommandwith a command and parameterizations as specified in the providedserializedParameterizedCommandstring.getCategory(String categoryId) Retrieves the category with the given identifier.getCommand(String commandId) Retrieves the command with the given identifier.Category[]Returns the collection of all of the defined categories in the workbench.Returns the collection of the identifiers for all of the defined categories in the workbench.Returns the collection of the identifiers for all of the defined commands in the workbench.Command[]Returns the collection of all of the defined commands in the workbench.Returns the collection of the identifiers for all of the defined command parameter types in the workbench.Returns the collection of all of the defined command parameter types in the workbench.getHelpContextId(String commandId) Gets the help context identifier for a particular command.getHelpContextId(Command command) Gets the help context identifier for a particular command.getParameterType(String parameterTypeId) Retrieves the command parameter type with the given identifier.voidReads the command information from the registry and the preferences.voidrefreshElements(String commandId, Map filter) Refresh any elements registered against the command with the given id.voidregisterElement(IElementReference elementReference) Re-register a callback element provided by the ICommandService.registerElementForCommand(ParameterizedCommand command, UIElement element) Register that this element accepts callbacks for this parameterized command.voidremoveExecutionListener(IExecutionListener listener) Removes an execution listener from the command service.voidsetHelpContextId(IHandler handler, String helpContextId) Sets the help context identifier to associate with a particular handler.voidunregisterElement(IElementReference elementReference) Unregister an element callback.Methods inherited from interface org.eclipse.ui.services.IDisposabledispose
- 
Field Details- 
AUTOGENERATED_CATEGORY_IDThe identifier of the category in which all auto-generated commands will appear. This value must never benull.- Since:
- 3.2
- See Also:
 
 
- 
- 
Method Details- 
addExecutionListenerAdds an execution listener to the command service. This listener will be notified as commands are executed.Note: listeners should be removed when no longer necessary. If not, they will be removed when the IServiceLocator used to acquire this service is disposed. - Parameters:
- listener- The listener to add; must not be- null.
- See Also:
 
- 
defineUncategorizedCategorySets the name and description of the category for uncategorized commands. This is the category that will be returned ifgetCategory(String)is called withnull.- Parameters:
- name- The name of the category for uncategorized commands; must not be- null.
- description- The description of the category for uncategorized commands; may be- null.
- Since:
- 3.2
 
- 
deserializeParameterizedCommand deserialize(String serializedParameterizedCommand) throws NotDefinedException, SerializationException Returns a ParameterizedCommandwith a command and parameterizations as specified in the providedserializedParameterizedCommandstring. TheserializedParameterizedCommandmust use the format returned byParameterizedCommand.serialize()and described in the Javadoc for that method.If a parameter id encoded in the serializedParameterizedCommanddoes not exist in the encoded command, that parameter id and value are ignored. A given parameter id should not be used more than once inserializedParameterizedCommand. This will not result in an exception, but the value of the parameter when the command is executed cannot be specified here.This method will never return null, however it may throw an exception if there is a problem processing the serialization string or the encoded command is undefined.- Parameters:
- serializedParameterizedCommand- a- Stringrepresenting a command id and parameter ids and values
- Returns:
- a ParameterizedCommandwith the command and parameterizations encoded in theserializedParameterizedCommand
- Throws:
- NotDefinedException- if the command indicated in- serializedParameterizedCommandis not defined
- SerializationException- if there is an error deserializing- serializedParameterizedCommand
- Since:
- 3.2
- See Also:
 
- 
getCategoryRetrieves the category with the given identifier. If no such category exists, then an undefined category with the given id is created.- Parameters:
- categoryId- The identifier to find. If the category is- null, then a category suitable for uncategorized items is defined and returned.
- Returns:
- A category with the given identifier, either defined or undefined.
 
- 
getCommandRetrieves the command with the given identifier. If no such command exists, then an undefined command with the given id is created.- Parameters:
- commandId- The identifier to find; must not be- null.
- Returns:
- A command with the given identifier, either defined or undefined.
 
- 
getDefinedCategoriesCategory[] getDefinedCategories()Returns the collection of all of the defined categories in the workbench.- Returns:
- The collection of categories (Category) that are defined; nevernull, but may be empty.
- Since:
- 3.2
 
- 
getDefinedCategoryIdsCollection getDefinedCategoryIds()Returns the collection of the identifiers for all of the defined categories in the workbench.- Returns:
- The collection of category identifiers (String) that are defined; nevernull, but may be empty.
 
- 
getDefinedCommandIdsCollection getDefinedCommandIds()Returns the collection of the identifiers for all of the defined commands in the workbench.- Returns:
- The collection of command identifiers (String) that are defined; nevernull, but may be empty.
 
- 
getDefinedCommandsCommand[] getDefinedCommands()Returns the collection of all of the defined commands in the workbench.- Returns:
- The collection of commands (Command) that are defined; nevernull, but may be empty.
- Since:
- 3.2
 
- 
getDefinedParameterTypeIdsCollection getDefinedParameterTypeIds()Returns the collection of the identifiers for all of the defined command parameter types in the workbench.- Returns:
- The collection of command parameter type identifiers
         (String) that are defined; nevernull, but may be empty.
- Since:
- 3.2
 
- 
getDefinedParameterTypesParameterType[] getDefinedParameterTypes()Returns the collection of all of the defined command parameter types in the workbench.- Returns:
- The collection of command parameter types
         (ParameterType) that are defined; nevernull, but may be empty.
- Since:
- 3.2
 
- 
getHelpContextIdGets the help context identifier for a particular command. The command's handler is first checked for a help context identifier. If the handler does not have a help context identifier, then the help context identifier for the command is returned. If neither has a help context identifier, thennullis returned.- Parameters:
- command- The command for which the help context should be retrieved; must not be- null.
- Returns:
- The help context identifier to use for the given command; may be
         null.
- Throws:
- NotDefinedException- If the given command is not defined.
- Since:
- 3.2
 
- 
getHelpContextIdGets the help context identifier for a particular command. The command's handler is first checked for a help context identifier. If the handler does not have a help context identifier, then the help context identifier for the command is returned. If neither has a help context identifier, thennullis returned.- Parameters:
- commandId- The identifier of the command for which the help context should be retrieved; must not be- null.
- Returns:
- The help context identifier to use for the given command; may be
         null.
- Throws:
- NotDefinedException- If the command with the given identifier is not defined.
- Since:
- 3.2
 
- 
getParameterTypeRetrieves the command parameter type with the given identifier. If no such parameter type exists, then an undefined parameter type with the given id is created.- Parameters:
- parameterTypeId- The identifier to find; must not be- null.
- Returns:
- A command parameter type with the given identifier, either defined or undefined.
- Since:
- 3.2
 
- 
readRegistryvoid readRegistry()Reads the command information from the registry and the preferences. This will overwrite any of the existing information in the command service. This method is intended to be called during start-up. When this method completes, this command service will reflect the current state of the registry and preference store. 
- 
removeExecutionListenerRemoves an execution listener from the command service.- Parameters:
- listener- The listener to remove; must not be- null.
 
- 
setHelpContextIdSets the help context identifier to associate with a particular handler.- Parameters:
- handler- The handler with which to register a help context identifier; must not be- null.
- helpContextId- The help context identifier to register; may be- nullif the help context identifier should be removed.
- Since:
- 3.2
 
- 
registerElementRe-register a callback element provided by the ICommandService. This element reference must not currently be held by the ICommandService. i.e. it must have been removed usingunregisterElement(IElementReference).Note: elements should be removed when no longer necessary. If not, they will be removed when the IServiceLocator used to acquire this service is disposed. - Parameters:
- elementReference- The reference to re-register. Must not be- null.
- Since:
- 3.3
- See Also:
 
- 
unregisterElementUnregister an element callback. It will be removed from the ICommandService. The same service that is used to register an element for a command must be used to unregister the element.- Parameters:
- elementReference- The callback reference that was provided by the command service on registration. Must not be- null.
- Since:
- 3.3
 
- 
refreshElementsRefresh any elements registered against the command with the given id. It allows the active handler the opportunity to provide user feedback. If the command is parameterized, some of the parameters can be specified to help narrow down which elements to refresh.The service locator used in registering the element can also be used to scope the search. For example: if you wanted all elements for your command but only within the part's workbench window, you could use: Map filter = new HashMap(); filter.put(IServiceScopes.WINDOW_SCOPE, getSite().getPage().getWorkbenchWindow()); commandService.refreshElements(commandId, filter); - Parameters:
- commandId- The command id to refresh if it has registered eleemnts.
- filter- key-value pairs that can narrow down the callbacks to return. The parameters are ANDed together. This may be- null.
- Since:
- 3.3
 
 
-