001: /*******************************************************************************
002: * Copyright (c) 2003, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.commands;
011:
012: import java.util.Set;
013:
014: import org.eclipse.ui.internal.util.Util;
015:
016: /**
017: * An instance of this class describes changes to an instance of
018: * <code>ICommandManager</code>.
019: * <p>
020: * This class is not intended to be extended by clients.
021: * </p>
022: *
023: * @since 3.0
024: * @see ICommandManagerListener#commandManagerChanged(CommandManagerEvent)
025: * @see org.eclipse.core.commands.CommandManagerEvent
026: * @deprecated Please use the "org.eclipse.core.commands" plug-in instead.
027: */
028: public final class CommandManagerEvent {
029:
030: /**
031: * Whether the set of active contexts has changed.
032: */
033: private final boolean activeContextIdsChanged;
034:
035: /**
036: * Whether the active key configuration has changed.
037: */
038: private final boolean activeKeyConfigurationIdChanged;
039:
040: /**
041: * Whether the locale has changed.
042: */
043: private final boolean activeLocaleChanged;
044:
045: /**
046: * Whether the platform has changed.
047: */
048: private final boolean activePlatformChanged;
049:
050: /**
051: * Whether the command manager has changed.
052: */
053: private final ICommandManager commandManager;
054:
055: /**
056: * Whether the list of defined categories has changed.
057: */
058: private final boolean definedCategoryIdsChanged;
059:
060: /**
061: * Whether the list of defined commands has changed.
062: */
063: private final boolean definedCommandIdsChanged;
064:
065: /**
066: * Whether the list of defined key configurations has changed.
067: */
068: private final boolean definedKeyConfigurationIdsChanged;
069:
070: /**
071: * The set of the defined categories before the change occurred. This is a
072: * set of strings (category identifiers).
073: */
074: private final Set previouslyDefinedCategoryIds;
075:
076: /**
077: * The set of the defined commands before the change occurred. This is a
078: * set of strings (command identifiers).
079: */
080: private final Set previouslyDefinedCommandIds;
081:
082: /**
083: * The set of the defined key configurations before the change occurred.
084: * This is a set of strings (key configuration identifiers).
085: */
086: private final Set previouslyDefinedKeyConfigurationIds;
087:
088: /**
089: * Creates a new instance of this class.
090: *
091: * @param commandManager
092: * the instance of the interface that changed.
093: * @param activeContextIdsChanged
094: * true, iff the activeContextIdsChanged property changed.
095: * @param activeKeyConfigurationIdChanged
096: * true, iff the activeKeyConfigurationIdChanged property
097: * changed.
098: * @param activeLocaleChanged
099: * true, iff the activeLocaleChanged property changed.
100: * @param activePlatformChanged
101: * true, iff the activePlatformChanged property changed.
102: * @param definedCategoryIdsChanged
103: * true, iff the definedCategoryIdsChanged property changed.
104: * @param definedCommandIdsChanged
105: * true, iff the definedCommandIdsChanged property changed.
106: * @param definedKeyConfigurationIdsChanged
107: * true, iff the definedKeyConfigurationIdsChanged property
108: * changed.
109: * @param previouslyDefinedCategoryIds
110: * the set of identifiers to previously defined categories. This
111: * set may be empty. If this set is not empty, it must only
112: * contain instances of <code>String</code>. This set must be
113: * <code>null</code> if definedCategoryIdsChanged is
114: * <code>false</code> and must not be null if
115: * definedCategoryIdsChanged is <code>true</code>.
116: * @param previouslyDefinedCommandIds
117: * the set of identifiers to previously defined commands. This
118: * set may be empty. If this set is not empty, it must only
119: * contain instances of <code>String</code>. This set must be
120: * <code>null</code> if definedCommandIdsChanged is
121: * <code>false</code> and must not be null if
122: * definedContextIdsChanged is <code>true</code>.
123: * @param previouslyDefinedKeyConfigurationIds
124: * the set of identifiers to previously defined key
125: * configurations. This set may be empty. If this set is not
126: * empty, it must only contain instances of <code>String</code>.
127: * This set must be <code>null</code> if
128: * definedKeyConfigurationIdsChanged is <code>false</code> and
129: * must not be null if definedKeyConfigurationIdsChanged is
130: * <code>true</code>.
131: */
132: public CommandManagerEvent(ICommandManager commandManager,
133: boolean activeContextIdsChanged,
134: boolean activeKeyConfigurationIdChanged,
135: boolean activeLocaleChanged, boolean activePlatformChanged,
136: boolean definedCategoryIdsChanged,
137: boolean definedCommandIdsChanged,
138: boolean definedKeyConfigurationIdsChanged,
139: Set previouslyDefinedCategoryIds,
140: Set previouslyDefinedCommandIds,
141: Set previouslyDefinedKeyConfigurationIds) {
142: if (commandManager == null) {
143: throw new NullPointerException();
144: }
145:
146: if (!definedCategoryIdsChanged
147: && previouslyDefinedCategoryIds != null) {
148: throw new IllegalArgumentException();
149: }
150:
151: if (!definedCommandIdsChanged
152: && previouslyDefinedCommandIds != null) {
153: throw new IllegalArgumentException();
154: }
155:
156: if (!definedKeyConfigurationIdsChanged
157: && previouslyDefinedKeyConfigurationIds != null) {
158: throw new IllegalArgumentException();
159: }
160:
161: if (definedCategoryIdsChanged) {
162: this .previouslyDefinedCategoryIds = Util.safeCopy(
163: previouslyDefinedCategoryIds, String.class);
164: } else {
165: this .previouslyDefinedCategoryIds = null;
166: }
167:
168: if (definedCommandIdsChanged) {
169: this .previouslyDefinedCommandIds = Util.safeCopy(
170: previouslyDefinedCommandIds, String.class);
171: } else {
172: this .previouslyDefinedCommandIds = null;
173: }
174:
175: if (definedKeyConfigurationIdsChanged) {
176: this .previouslyDefinedKeyConfigurationIds = Util.safeCopy(
177: previouslyDefinedKeyConfigurationIds, String.class);
178: } else {
179: this .previouslyDefinedKeyConfigurationIds = null;
180: }
181:
182: this .commandManager = commandManager;
183: this .activeContextIdsChanged = activeContextIdsChanged;
184: this .activeKeyConfigurationIdChanged = activeKeyConfigurationIdChanged;
185: this .activeLocaleChanged = activeLocaleChanged;
186: this .activePlatformChanged = activePlatformChanged;
187: this .definedCategoryIdsChanged = definedCategoryIdsChanged;
188: this .definedCommandIdsChanged = definedCommandIdsChanged;
189: this .definedKeyConfigurationIdsChanged = definedKeyConfigurationIdsChanged;
190: }
191:
192: /**
193: * Returns the instance of the interface that changed.
194: *
195: * @return the instance of the interface that changed. Guaranteed not to be
196: * <code>null</code>.
197: */
198: public ICommandManager getCommandManager() {
199: return commandManager;
200: }
201:
202: /**
203: * Returns the set of identifiers to previously defined categories.
204: *
205: * @return the set of identifiers to previously defined categories. This set
206: * may be empty. If this set is not empty, it is guaranteed to only
207: * contain instances of <code>String</code>. This set is
208: * guaranteed to be <code>null</code> if
209: * haveDefinedCategoryIdsChanged() is <code>false</code> and is
210: * guaranteed to not be null if haveDefinedCategoryIdsChanged() is
211: * <code>true</code>.
212: */
213: public Set getPreviouslyDefinedCategoryIds() {
214: return previouslyDefinedCategoryIds;
215: }
216:
217: /**
218: * Returns the set of identifiers to previously defined commands.
219: *
220: * @return the set of identifiers to previously defined commands. This set
221: * may be empty. If this set is not empty, it is guaranteed to only
222: * contain instances of <code>String</code>. This set is
223: * guaranteed to be <code>null</code> if
224: * haveDefinedCommandIdsChanged() is <code>false</code> and is
225: * guaranteed to not be null if haveDefinedCommandIdsChanged() is
226: * <code>true</code>.
227: */
228: public Set getPreviouslyDefinedCommandIds() {
229: return previouslyDefinedCommandIds;
230: }
231:
232: /**
233: * Returns the set of identifiers to previously defined key conigurations.
234: *
235: * @return the set of identifiers to previously defined key configurations.
236: * This set may be empty. If this set is not empty, it is guaranteed
237: * to only contain instances of <code>String</code>. This set is
238: * guaranteed to be <code>null</code> if
239: * haveDefinedKeyConfigurationIdsChanged() is <code>false</code>
240: * and is guaranteed to not be null if
241: * haveDefinedKeyConfigurationIdsChanged() is <code>true</code>.
242: */
243: public Set getPreviouslyDefinedKeyConfigurationIds() {
244: return previouslyDefinedKeyConfigurationIds;
245: }
246:
247: /**
248: * Returns whether or not the activeKeyConfigurationId property changed.
249: *
250: * @return true, iff the activeKeyConfigurationId property changed.
251: */
252: public boolean hasActiveKeyConfigurationIdChanged() {
253: return activeKeyConfigurationIdChanged;
254: }
255:
256: /**
257: * Returns whether or not the activeLocale property changed.
258: *
259: * @return true, iff the activeLocale property changed.
260: */
261: public boolean hasActiveLocaleChanged() {
262: return activeLocaleChanged;
263: }
264:
265: /**
266: * Returns whether or not the activePlatform property changed.
267: *
268: * @return true, iff the activePlatform property changed.
269: */
270: public boolean hasActivePlatformChanged() {
271: return activePlatformChanged;
272: }
273:
274: /**
275: * Returns whether or not the activeContextIds property changed.
276: *
277: * @return true, iff the activeContextIds property changed.
278: */
279: public boolean haveActiveContextIdsChanged() {
280: return activeContextIdsChanged;
281: }
282:
283: /**
284: * Returns whether or not the definedCategoryIds property changed.
285: *
286: * @return true, iff the definedCategoryIds property changed.
287: */
288: public boolean haveDefinedCategoryIdsChanged() {
289: return definedCategoryIdsChanged;
290: }
291:
292: /**
293: * Returns whether or not the definedCommandIds property changed.
294: *
295: * @return true, iff the definedCommandIds property changed.
296: */
297: public boolean haveDefinedCommandIdsChanged() {
298: return definedCommandIdsChanged;
299: }
300:
301: /**
302: * Returns whether or not the definedKeyConfigurationIds property changed.
303: *
304: * @return true, iff the definedKeyConfigurationIds property changed.
305: */
306: public boolean haveDefinedKeyConfigurationIdsChanged() {
307: return definedKeyConfigurationIdsChanged;
308: }
309: }
|