Eclipse Platform
Release 3.2

org.eclipse.ui.commands
Interface ICommandService

All Superinterfaces:
IDisposable

public interface ICommandService
extends 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 interface should not be implemented or extended by clients.

Since:
3.1

Field Summary
static String AUTOGENERATED_CATEGORY_ID
          The identifier of the category in which all auto-generated commands will appear.
 
Method Summary
 void addExecutionListener(IExecutionListener listener)
          Adds an execution listener to the command service.
 void defineUncategorizedCategory(String name, String description)
          Sets the name and description of the category for uncategorized commands.
 ParameterizedCommand deserialize(String serializedParameterizedCommand)
           Returns a ParameterizedCommand with a command and parameterizations as specified in the provided serializedParameterizedCommand string.
 Category getCategory(String categoryId)
          Retrieves the category with the given identifier.
 Command getCommand(String commandId)
          Retrieves the command with the given identifier.
 Category[] getDefinedCategories()
          Returns the collection of all of the defined categories in the workbench.
 Collection getDefinedCategoryIds()
          Returns the collection of the identifiers for all of the defined categories in the workbench.
 Collection getDefinedCommandIds()
          Returns the collection of the identifiers for all of the defined commands in the workbench.
 Command[] getDefinedCommands()
          Returns the collection of all of the defined commands in the workbench.
 Collection getDefinedParameterTypeIds()
          Returns the collection of the identifiers for all of the defined command parameter types in the workbench.
 ParameterType[] getDefinedParameterTypes()
          Returns the collection of all of the defined command parameter types in the workbench.
 String getHelpContextId(Command command)
          Gets the help context identifier for a particular command.
 String getHelpContextId(String commandId)
          Gets the help context identifier for a particular command.
 ParameterType getParameterType(String parameterTypeId)
          Retrieves the command parameter type with the given identifier.
 void readRegistry()
           Reads the command information from the registry and the preferences.
 void removeExecutionListener(IExecutionListener listener)
          Removes an execution listener from the command service.
 void setHelpContextId(IHandler handler, String helpContextId)
          Sets the help context identifier to associate with a particular handler.
 
Methods inherited from interface org.eclipse.ui.services.IDisposable
dispose
 

Field Detail

AUTOGENERATED_CATEGORY_ID

public static final String AUTOGENERATED_CATEGORY_ID
The identifier of the category in which all auto-generated commands will appear. This value must never be null.

Since:
3.2
See Also:
Constant Field Values
Method Detail

addExecutionListener

public void addExecutionListener(IExecutionListener listener)
Adds an execution listener to the command service. This listener will be notified as commands are executed.

Parameters:
listener - The listener to add; must not be null.

defineUncategorizedCategory

public void defineUncategorizedCategory(String name,
                                        String description)
Sets the name and description of the category for uncategorized commands. This is the category that will be returned if getCategory(String) is called with null.

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

deserialize

public ParameterizedCommand deserialize(String serializedParameterizedCommand)
                                 throws NotDefinedException,
                                        SerializationException

Returns a ParameterizedCommand with a command and parameterizations as specified in the provided serializedParameterizedCommand string. The serializedParameterizedCommand must use the format returned by ParameterizedCommand.serialize() and described in the Javadoc for that method.

If a parameter id encoded in the serializedParameterizedCommand does not exist in the encoded command, that parameter id and value are ignored. A given parameter id should not be used more than once in serializedParameterizedCommand. 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 String representing a command id and parameter ids and values
Returns:
a ParameterizedCommand with the command and parameterizations encoded in the serializedParameterizedCommand
Throws:
NotDefinedException - if the command indicated in serializedParameterizedCommand is not defined
SerializationException - if there is an error deserializing serializedParameterizedCommand
NotDefinedException
Since:
3.2
See Also:
ParameterizedCommand.serialize(), CommandManager.deserialize(String)

getCategory

public Category getCategory(String categoryId)
Retrieves 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.

getCommand

public Command getCommand(String commandId)
Retrieves 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.

getDefinedCategories

public Category[] getDefinedCategories()
Returns the collection of all of the defined categories in the workbench.

Returns:
The collection of categories (Category) that are defined; never null, but may be empty.
Since:
3.2

getDefinedCategoryIds

public Collection 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; never null, but may be empty.

getDefinedCommandIds

public Collection 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; never null, but may be empty.

getDefinedCommands

public Command[] getDefinedCommands()
Returns the collection of all of the defined commands in the workbench.

Returns:
The collection of commands (Command) that are defined; never null, but may be empty.
Since:
3.2

getDefinedParameterTypeIds

public Collection 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; never null, but may be empty.
Since:
3.2

getDefinedParameterTypes

public ParameterType[] 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; never null, but may be empty.
Since:
3.2

getHelpContextId

public String getHelpContextId(Command command)
                        throws NotDefinedException
Gets 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, then null is 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.
NotDefinedException
Since:
3.2

getHelpContextId

public String getHelpContextId(String commandId)
                        throws NotDefinedException
Gets 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, then null is 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.
NotDefinedException
Since:
3.2

getParameterType

public ParameterType getParameterType(String parameterTypeId)
Retrieves 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

readRegistry

public void 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.


removeExecutionListener

public void removeExecutionListener(IExecutionListener listener)
Removes an execution listener from the command service.

Parameters:
listener - The listener to remove; must not be null.

setHelpContextId

public void setHelpContextId(IHandler handler,
                             String helpContextId)
Sets 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 null if the help context identifier should be removed.
Since:
3.2

Eclipse Platform
Release 3.2

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.