Eclipse Platform
Release 3.1

org.eclipse.core.commands
Class CommandManager

java.lang.Object
  extended byorg.eclipse.core.commands.CommandManager
All Implemented Interfaces:
ICategoryListener, ICommandListener

public final class CommandManager
extends Object
implements ICategoryListener, ICommandListener

A central repository for commands -- both in the defined and undefined states. Commands can be created and retrieved using this manager. It is possible to listen to changes in the collection of commands by attaching a listener to the manager.

Since:
3.1
See Also:
getCommand(String)

Constructor Summary
CommandManager()
           
 
Method Summary
 void addCommandManagerListener(ICommandManagerListener listener)
          Adds a listener to this command manager.
 void addExecutionListener(IExecutionListener listener)
          Adds an execution listener to this manager.
 void categoryChanged(CategoryEvent categoryEvent)
          Notifies that one or more properties of an instance of Category have changed.
 void commandChanged(CommandEvent commandEvent)
          Notifies that one or more properties of an instance of Command have changed.
 Category getCategory(String categoryId)
          Gets the category with the given identifier.
 Command getCommand(String commandId)
          Gets the command with the given identifier.
 Set getDefinedCategoryIds()
          Returns the set of identifiers for those category that are defined.
 Set getDefinedCommandIds()
          Returns the set of identifiers for those commands that are defined.
 void removeCommandManagerListener(ICommandManagerListener listener)
          Removes a listener from this command manager.
 void removeExecutionListener(IExecutionListener listener)
          Removes an execution listener from this command manager.
 void setHandlersByCommandId(Map handlersByCommandId)
          Block updates all of the handlers for all of the commands.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandManager

public CommandManager()
Method Detail

addCommandManagerListener

public final void addCommandManagerListener(ICommandManagerListener listener)
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.

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

addExecutionListener

public final void addExecutionListener(IExecutionListener 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.

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

categoryChanged

public final void categoryChanged(CategoryEvent categoryEvent)
Description copied from interface: ICategoryListener
Notifies that one or more properties of an instance of Category have changed. Specific details are described in the CategoryEvent.

Specified by:
categoryChanged in interface ICategoryListener
Parameters:
categoryEvent - the category event. Guaranteed not to be null.

commandChanged

public final void commandChanged(CommandEvent commandEvent)
Description copied from interface: ICommandListener
Notifies that one or more properties of an instance of Command have changed. Specific details are described in the CommandEvent.

Specified by:
commandChanged in interface ICommandListener
Parameters:
commandEvent - the command event. Guaranteed not to be null.

getCategory

public final Category getCategory(String categoryId)
Gets the category with the given identifier. If no such category currently exists, then the category will be created (but be undefined).

Parameters:
categoryId - The identifier to find; must not be null.
Returns:
The category with the given identifier; this value will never be null, but it might be undefined.
See Also:
Category

getCommand

public final Command getCommand(String commandId)
Gets the command with the given identifier. If no such command currently exists, then the command will be created (but will be undefined).

Parameters:
commandId - The identifier to find; must not be null and must not be zero-length.
Returns:
The command with the given identifier; this value will never be null, but it might be undefined.
See Also:
Command

getDefinedCategoryIds

public final Set getDefinedCategoryIds()
Returns the set of identifiers for those category that are defined.

Returns:
The set of defined category identifiers; this value may be empty, but it is never null.

getDefinedCommandIds

public final Set getDefinedCommandIds()
Returns the set of identifiers for those commands that are defined.

Returns:
The set of defined command identifiers; this value may be empty, but it is never null.

removeCommandManagerListener

public final void removeCommandManagerListener(ICommandManagerListener listener)
Removes a listener from this command manager.

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

removeExecutionListener

public final void removeExecutionListener(IExecutionListener listener)
Removes an execution listener from this command manager.

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

setHandlersByCommandId

public final void setHandlersByCommandId(Map handlersByCommandId)
Block updates all of the handlers for all of the commands. If the handler is null or the command id does not exist in the map, then the command becomes unhandled. Otherwise, the handler is set to the corresponding value in the map.

Parameters:
handlersByCommandId - A map of command identifiers (String) to handlers (IHandler). This map may be null if all handlers should be cleared. Similarly, if the map is empty, then all commands will become unhandled.

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

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