org.eclipse.ui.commands.ICommand Maven / Gradle / Ivy
Show all versions of workbench Show documentation
/*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.commands;
import java.util.List;
import java.util.Map;
/**
*
* An instance of ICommand
is a handle representing a command as
* defined by the extension point org.eclipse.ui.commands
. The
* identifier of the handle is identifier of the command being represented.
*
*
* An instance of ICommand
can be obtained from an instance of
* ICommandManager
for any identifier, whether or not a command
* with that identifier defined in the plugin registry.
*
*
* The handle-based nature of this API allows it to work well with runtime
* plugin activation and deactivation. If a command is defined, that means that
* its corresponding plug-in is active. If the plug-in is then deactivated, the
* command will still exist but it will be undefined. An attempts to use an
* undefined command will result in a NotDefinedException
being
* thrown.
*
*
* This interface is not intended to be extended or implemented by clients.
*
*
* @since 3.0
* @see ICommandListener
* @see ICommandManager
* @see org.eclipse.core.commands.Command
* @deprecated Please use the "org.eclipse.core.commands" plug-in instead.
*/
public interface ICommand extends Comparable {
/**
* Registers an instance of ICommandListener
to listen for
* changes to attributes of this instance.
*
* @param commandListener
* the instance of ICommandListener
to register.
* Must not be null
. If an attempt is made to
* register an instance of ICommandListener
which
* is already registered with this instance, no operation is
* performed.
*/
void addCommandListener(ICommandListener commandListener);
/**
* Executes with the map of parameter values by name.
*
* @param parameterValuesByName
* the map of parameter values by name. Reserved for future use,
* must be null
.
* @return the result of the execution. Reserved for future use, must be
* null
.
* @throws ExecutionException
* if an exception occurred during execution.
* @throws NotHandledException
* if this is not handled.
*/
Object execute(Map parameterValuesByName) throws ExecutionException,
NotHandledException;
/**
* Returns the map of attribute values by name.
*
* Notification is sent to all registered listeners if this property
* changes.
*
*
* @return the map of attribute values by name. This map may be empty, but
* is guaranteed not to be null
. If this map is not
* empty, its collection of keys is guaranteed to only contain
* instances of String
.
* @throws NotHandledException
* if this is not handled.
*/
Map getAttributeValuesByName() throws NotHandledException;
/**
*
* Returns the identifier of the category of the command represented by this
* handle.
*
*
* Notification is sent to all registered listeners if this attribute
* changes.
*
*
* @return the identifier of the category of the command represented by this
* handle. May be null
.
* @throws NotDefinedException
* if the command represented by this handle is not defined.
*/
String getCategoryId() throws NotDefinedException;
/**
*
* Returns the description of the command represented by this handle,
* suitable for display to the user.
*
*
* Notification is sent to all registered listeners if this attribute
* changes.
*
*
* @return the description of the command represented by this handle.
* Guaranteed not to be null
.
* @throws NotDefinedException
* if the command represented by this handle is not defined.
*/
String getDescription() throws NotDefinedException;
/**
* Returns the identifier of this handle.
*
* @return the identifier of this handle. Guaranteed not to be
* null
.
*/
String getId();
/**
*
* Returns the list of key sequence bindings for this handle. This method
* will return all key sequence bindings for this handle's identifier,
* whether or not the command represented by this handle is defined.
*
*
* Notification is sent to all registered listeners if this attribute
* changes.
*
*
* @return the list of key sequence bindings. This list may be empty, but is
* guaranteed not to be null
. If this list is not
* empty, it is guaranteed to only contain instances of
* IKeySequenceBinding
.
*/
List getKeySequenceBindings();
/**
*
* Returns the name of the command represented by this handle, suitable for
* display to the user.
*
*
* Notification is sent to all registered listeners if this attribute
* changes.
*
*
* @return the name of the command represented by this handle. Guaranteed
* not to be null
.
* @throws NotDefinedException
* if the command represented by this handle is not defined.
*/
String getName() throws NotDefinedException;
/**
*
* Returns whether or not the command represented by this handle is defined.
*
*
* Notification is sent to all registered listeners if this attribute
* changes.
*
*
* @return true
, iff the command represented by this handle
* is defined.
*/
boolean isDefined();
/**
*
* Returns whether or not this command is handled. A command is handled if
* it currently has an IHandler
instance associated with it.
* A command needs a handler to carry out the {@link ICommand#execute(Map)}
* method.
*
*
* Notification is sent to all registered listeners if this attribute
* changes.
*
*
* @return true
, iff this command is enabled.
*/
boolean isHandled();
/**
* Unregisters an instance of ICommandListener
listening for
* changes to attributes of this instance.
*
* @param commandListener
* the instance of ICommandListener
to unregister.
* Must not be null
. If an attempt is made to
* unregister an instance of ICommandListener
* which is not already registered with this instance, no
* operation is performed.
*/
void removeCommandListener(ICommandListener commandListener);
}