KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > commands > ICommand


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.commands;
12
13 import java.util.List JavaDoc;
14 import java.util.Map JavaDoc;
15
16 /**
17  * <p>
18  * An instance of <code>ICommand</code> is a handle representing a command as
19  * defined by the extension point <code>org.eclipse.ui.commands</code>. The
20  * identifier of the handle is identifier of the command being represented.
21  * </p>
22  * <p>
23  * An instance of <code>ICommand</code> can be obtained from an instance of
24  * <code>ICommandManager</code> for any identifier, whether or not a command
25  * with that identifier defined in the plugin registry.
26  * </p>
27  * <p>
28  * The handle-based nature of this API allows it to work well with runtime
29  * plugin activation and deactivation. If a command is defined, that means that
30  * its corresponding plug-in is active. If the plug-in is then deactivated, the
31  * command will still exist but it will be undefined. An attempts to use an
32  * undefined command will result in a <code>NotDefinedException</code> being
33  * thrown.
34  * </p>
35  * <p>
36  * This interface is not intended to be extended or implemented by clients.
37  * </p>
38  *
39  * @since 3.0
40  * @see ICommandListener
41  * @see ICommandManager
42  * @see org.eclipse.core.commands.Command
43  * @deprecated Please use the "org.eclipse.core.commands" plug-in instead.
44  */

45 public interface ICommand extends Comparable JavaDoc {
46
47     /**
48      * Registers an instance of <code>ICommandListener</code> to listen for
49      * changes to attributes of this instance.
50      *
51      * @param commandListener
52      * the instance of <code>ICommandListener</code> to register.
53      * Must not be <code>null</code>. If an attempt is made to
54      * register an instance of <code>ICommandListener</code> which
55      * is already registered with this instance, no operation is
56      * performed.
57      */

58     void addCommandListener(ICommandListener commandListener);
59
60     /**
61      * Executes with the map of parameter values by name.
62      *
63      * @param parameterValuesByName
64      * the map of parameter values by name. Reserved for future use,
65      * must be <code>null</code>.
66      * @return the result of the execution. Reserved for future use, must be
67      * <code>null</code>.
68      * @throws ExecutionException
69      * if an exception occurred during execution.
70      * @throws NotHandledException
71      * if this is not handled.
72      */

73     Object JavaDoc execute(Map JavaDoc parameterValuesByName) throws ExecutionException,
74             NotHandledException;
75
76     /**
77      * Returns the map of attribute values by name.
78      * <p>
79      * Notification is sent to all registered listeners if this property
80      * changes.
81      * </p>
82      *
83      * @return the map of attribute values by name. This map may be empty, but
84      * is guaranteed not to be <code>null</code>. If this map is not
85      * empty, its collection of keys is guaranteed to only contain
86      * instances of <code>String</code>.
87      * @throws NotHandledException
88      * if this is not handled.
89      */

90     Map JavaDoc getAttributeValuesByName() throws NotHandledException;
91
92     /**
93      * <p>
94      * Returns the identifier of the category of the command represented by this
95      * handle.
96      * </p>
97      * <p>
98      * Notification is sent to all registered listeners if this attribute
99      * changes.
100      * </p>
101      *
102      * @return the identifier of the category of the command represented by this
103      * handle. May be <code>null</code>.
104      * @throws NotDefinedException
105      * if the command represented by this handle is not defined.
106      */

107     String JavaDoc getCategoryId() throws NotDefinedException;
108
109     /**
110      * <p>
111      * Returns the description of the command represented by this handle,
112      * suitable for display to the user.
113      * </p>
114      * <p>
115      * Notification is sent to all registered listeners if this attribute
116      * changes.
117      * </p>
118      *
119      * @return the description of the command represented by this handle.
120      * Guaranteed not to be <code>null</code>.
121      * @throws NotDefinedException
122      * if the command represented by this handle is not defined.
123      */

124     String JavaDoc getDescription() throws NotDefinedException;
125
126     /**
127      * Returns the identifier of this handle.
128      *
129      * @return the identifier of this handle. Guaranteed not to be
130      * <code>null</code>.
131      */

132     String JavaDoc getId();
133
134     /**
135      * <p>
136      * Returns the list of key sequence bindings for this handle. This method
137      * will return all key sequence bindings for this handle's identifier,
138      * whether or not the command represented by this handle is defined.
139      * </p>
140      * <p>
141      * Notification is sent to all registered listeners if this attribute
142      * changes.
143      * </p>
144      *
145      * @return the list of key sequence bindings. This list may be empty, but is
146      * guaranteed not to be <code>null</code>. If this list is not
147      * empty, it is guaranteed to only contain instances of
148      * <code>IKeySequenceBinding</code>.
149      */

150     List JavaDoc getKeySequenceBindings();
151
152     /**
153      * <p>
154      * Returns the name of the command represented by this handle, suitable for
155      * display to the user.
156      * </p>
157      * <p>
158      * Notification is sent to all registered listeners if this attribute
159      * changes.
160      * </p>
161      *
162      * @return the name of the command represented by this handle. Guaranteed
163      * not to be <code>null</code>.
164      * @throws NotDefinedException
165      * if the command represented by this handle is not defined.
166      */

167     String JavaDoc getName() throws NotDefinedException;
168
169     /**
170      * <p>
171      * Returns whether or not the command represented by this handle is defined.
172      * </p>
173      * <p>
174      * Notification is sent to all registered listeners if this attribute
175      * changes.
176      * </p>
177      *
178      * @return <code>true</code>, iff the command represented by this handle
179      * is defined.
180      */

181     boolean isDefined();
182
183     /**
184      * <p>
185      * Returns whether or not this command is handled. A command is handled if
186      * it currently has an <code>IHandler</code> instance associated with it.
187      * A command needs a handler to carry out the {@link ICommand#execute(Map)}
188      * method.
189      * </p>
190      * <p>
191      * Notification is sent to all registered listeners if this attribute
192      * changes.
193      * </p>
194      *
195      * @return <code>true</code>, iff this command is enabled.
196      */

197     boolean isHandled();
198
199     /**
200      * Unregisters an instance of <code>ICommandListener</code> listening for
201      * changes to attributes of this instance.
202      *
203      * @param commandListener
204      * the instance of <code>ICommandListener</code> to unregister.
205      * Must not be <code>null</code>. If an attempt is made to
206      * unregister an instance of <code>ICommandListener</code>
207      * which is not already registered with this instance, no
208      * operation is performed.
209      */

210     void removeCommandListener(ICommandListener commandListener);
211 }
212
Popular Tags