KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 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.Set JavaDoc;
14
15 import org.eclipse.ui.internal.util.Util;
16
17 /**
18  * An instance of this class describes changes to an instance of
19  * <code>ICommandManager</code>.
20  * <p>
21  * This class is not intended to be extended by clients.
22  * </p>
23  *
24  * @since 3.0
25  * @see ICommandManagerListener#commandManagerChanged(CommandManagerEvent)
26  * @see org.eclipse.core.commands.CommandManagerEvent
27  * @deprecated Please use the "org.eclipse.core.commands" plug-in instead.
28  */

29 public final class CommandManagerEvent {
30
31     /**
32      * Whether the set of active contexts has changed.
33      */

34     private final boolean activeContextIdsChanged;
35
36     /**
37      * Whether the active key configuration has changed.
38      */

39     private final boolean activeKeyConfigurationIdChanged;
40
41     /**
42      * Whether the locale has changed.
43      */

44     private final boolean activeLocaleChanged;
45
46     /**
47      * Whether the platform has changed.
48      */

49     private final boolean activePlatformChanged;
50
51     /**
52      * Whether the command manager has changed.
53      */

54     private final ICommandManager commandManager;
55
56     /**
57      * Whether the list of defined categories has changed.
58      */

59     private final boolean definedCategoryIdsChanged;
60
61     /**
62      * Whether the list of defined commands has changed.
63      */

64     private final boolean definedCommandIdsChanged;
65
66     /**
67      * Whether the list of defined key configurations has changed.
68      */

69     private final boolean definedKeyConfigurationIdsChanged;
70
71     /**
72      * The set of the defined categories before the change occurred. This is a
73      * set of strings (category identifiers).
74      */

75     private final Set JavaDoc previouslyDefinedCategoryIds;
76
77     /**
78      * The set of the defined commands before the change occurred. This is a
79      * set of strings (command identifiers).
80      */

81     private final Set JavaDoc previouslyDefinedCommandIds;
82
83     /**
84      * The set of the defined key configurations before the change occurred.
85      * This is a set of strings (key configuration identifiers).
86      */

87     private final Set JavaDoc previouslyDefinedKeyConfigurationIds;
88
89     /**
90      * Creates a new instance of this class.
91      *
92      * @param commandManager
93      * the instance of the interface that changed.
94      * @param activeContextIdsChanged
95      * true, iff the activeContextIdsChanged property changed.
96      * @param activeKeyConfigurationIdChanged
97      * true, iff the activeKeyConfigurationIdChanged property
98      * changed.
99      * @param activeLocaleChanged
100      * true, iff the activeLocaleChanged property changed.
101      * @param activePlatformChanged
102      * true, iff the activePlatformChanged property changed.
103      * @param definedCategoryIdsChanged
104      * true, iff the definedCategoryIdsChanged property changed.
105      * @param definedCommandIdsChanged
106      * true, iff the definedCommandIdsChanged property changed.
107      * @param definedKeyConfigurationIdsChanged
108      * true, iff the definedKeyConfigurationIdsChanged property
109      * changed.
110      * @param previouslyDefinedCategoryIds
111      * the set of identifiers to previously defined categories. This
112      * set may be empty. If this set is not empty, it must only
113      * contain instances of <code>String</code>. This set must be
114      * <code>null</code> if definedCategoryIdsChanged is
115      * <code>false</code> and must not be null if
116      * definedCategoryIdsChanged is <code>true</code>.
117      * @param previouslyDefinedCommandIds
118      * the set of identifiers to previously defined commands. This
119      * set may be empty. If this set is not empty, it must only
120      * contain instances of <code>String</code>. This set must be
121      * <code>null</code> if definedCommandIdsChanged is
122      * <code>false</code> and must not be null if
123      * definedContextIdsChanged is <code>true</code>.
124      * @param previouslyDefinedKeyConfigurationIds
125      * the set of identifiers to previously defined key
126      * configurations. This set may be empty. If this set is not
127      * empty, it must only contain instances of <code>String</code>.
128      * This set must be <code>null</code> if
129      * definedKeyConfigurationIdsChanged is <code>false</code> and
130      * must not be null if definedKeyConfigurationIdsChanged is
131      * <code>true</code>.
132      */

133     public CommandManagerEvent(ICommandManager commandManager,
134             boolean activeContextIdsChanged,
135             boolean activeKeyConfigurationIdChanged,
136             boolean activeLocaleChanged, boolean activePlatformChanged,
137             boolean definedCategoryIdsChanged,
138             boolean definedCommandIdsChanged,
139             boolean definedKeyConfigurationIdsChanged,
140             Set JavaDoc previouslyDefinedCategoryIds, Set JavaDoc previouslyDefinedCommandIds,
141             Set JavaDoc previouslyDefinedKeyConfigurationIds) {
142         if (commandManager == null) {
143             throw new NullPointerException JavaDoc();
144         }
145
146         if (!definedCategoryIdsChanged && previouslyDefinedCategoryIds != null) {
147             throw new IllegalArgumentException JavaDoc();
148         }
149
150         if (!definedCommandIdsChanged && previouslyDefinedCommandIds != null) {
151             throw new IllegalArgumentException JavaDoc();
152         }
153
154         if (!definedKeyConfigurationIdsChanged
155                 && previouslyDefinedKeyConfigurationIds != null) {
156             throw new IllegalArgumentException JavaDoc();
157         }
158
159         if (definedCategoryIdsChanged) {
160             this.previouslyDefinedCategoryIds = Util.safeCopy(
161                     previouslyDefinedCategoryIds, String JavaDoc.class);
162         } else {
163             this.previouslyDefinedCategoryIds = null;
164         }
165
166         if (definedCommandIdsChanged) {
167             this.previouslyDefinedCommandIds = Util.safeCopy(
168                     previouslyDefinedCommandIds, String JavaDoc.class);
169         } else {
170             this.previouslyDefinedCommandIds = null;
171         }
172
173         if (definedKeyConfigurationIdsChanged) {
174             this.previouslyDefinedKeyConfigurationIds = Util.safeCopy(
175                     previouslyDefinedKeyConfigurationIds, String JavaDoc.class);
176         } else {
177             this.previouslyDefinedKeyConfigurationIds = null;
178         }
179
180         this.commandManager = commandManager;
181         this.activeContextIdsChanged = activeContextIdsChanged;
182         this.activeKeyConfigurationIdChanged = activeKeyConfigurationIdChanged;
183         this.activeLocaleChanged = activeLocaleChanged;
184         this.activePlatformChanged = activePlatformChanged;
185         this.definedCategoryIdsChanged = definedCategoryIdsChanged;
186         this.definedCommandIdsChanged = definedCommandIdsChanged;
187         this.definedKeyConfigurationIdsChanged = definedKeyConfigurationIdsChanged;
188     }
189
190     /**
191      * Returns the instance of the interface that changed.
192      *
193      * @return the instance of the interface that changed. Guaranteed not to be
194      * <code>null</code>.
195      */

196     public ICommandManager getCommandManager() {
197         return commandManager;
198     }
199
200     /**
201      * Returns the set of identifiers to previously defined categories.
202      *
203      * @return the set of identifiers to previously defined categories. This set
204      * may be empty. If this set is not empty, it is guaranteed to only
205      * contain instances of <code>String</code>. This set is
206      * guaranteed to be <code>null</code> if
207      * haveDefinedCategoryIdsChanged() is <code>false</code> and is
208      * guaranteed to not be null if haveDefinedCategoryIdsChanged() is
209      * <code>true</code>.
210      */

211     public Set JavaDoc getPreviouslyDefinedCategoryIds() {
212         return previouslyDefinedCategoryIds;
213     }
214
215     /**
216      * Returns the set of identifiers to previously defined commands.
217      *
218      * @return the set of identifiers to previously defined commands. This set
219      * may be empty. If this set is not empty, it is guaranteed to only
220      * contain instances of <code>String</code>. This set is
221      * guaranteed to be <code>null</code> if
222      * haveDefinedCommandIdsChanged() is <code>false</code> and is
223      * guaranteed to not be null if haveDefinedCommandIdsChanged() is
224      * <code>true</code>.
225      */

226     public Set JavaDoc getPreviouslyDefinedCommandIds() {
227         return previouslyDefinedCommandIds;
228     }
229
230     /**
231      * Returns the set of identifiers to previously defined key conigurations.
232      *
233      * @return the set of identifiers to previously defined key configurations.
234      * This set may be empty. If this set is not empty, it is guaranteed
235      * to only contain instances of <code>String</code>. This set is
236      * guaranteed to be <code>null</code> if
237      * haveDefinedKeyConfigurationIdsChanged() is <code>false</code>
238      * and is guaranteed to not be null if
239      * haveDefinedKeyConfigurationIdsChanged() is <code>true</code>.
240      */

241     public Set JavaDoc getPreviouslyDefinedKeyConfigurationIds() {
242         return previouslyDefinedKeyConfigurationIds;
243     }
244
245     /**
246      * Returns whether or not the activeKeyConfigurationId property changed.
247      *
248      * @return true, iff the activeKeyConfigurationId property changed.
249      */

250     public boolean hasActiveKeyConfigurationIdChanged() {
251         return activeKeyConfigurationIdChanged;
252     }
253
254     /**
255      * Returns whether or not the activeLocale property changed.
256      *
257      * @return true, iff the activeLocale property changed.
258      */

259     public boolean hasActiveLocaleChanged() {
260         return activeLocaleChanged;
261     }
262
263     /**
264      * Returns whether or not the activePlatform property changed.
265      *
266      * @return true, iff the activePlatform property changed.
267      */

268     public boolean hasActivePlatformChanged() {
269         return activePlatformChanged;
270     }
271
272     /**
273      * Returns whether or not the activeContextIds property changed.
274      *
275      * @return true, iff the activeContextIds property changed.
276      */

277     public boolean haveActiveContextIdsChanged() {
278         return activeContextIdsChanged;
279     }
280
281     /**
282      * Returns whether or not the definedCategoryIds property changed.
283      *
284      * @return true, iff the definedCategoryIds property changed.
285      */

286     public boolean haveDefinedCategoryIdsChanged() {
287         return definedCategoryIdsChanged;
288     }
289
290     /**
291      * Returns whether or not the definedCommandIds property changed.
292      *
293      * @return true, iff the definedCommandIds property changed.
294      */

295     public boolean haveDefinedCommandIdsChanged() {
296         return definedCommandIdsChanged;
297     }
298
299     /**
300      * Returns whether or not the definedKeyConfigurationIds property changed.
301      *
302      * @return true, iff the definedKeyConfigurationIds property changed.
303      */

304     public boolean haveDefinedKeyConfigurationIdsChanged() {
305         return definedKeyConfigurationIdsChanged;
306     }
307 }
308
Popular Tags