KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > contexts > ContextManagerEvent


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

30 public final class ContextManagerEvent {
31
32     /**
33      * The context manager which has changed. This value is never
34      * <code>null</code>.
35      */

36     private final IContextManager contextManager;
37
38     /**
39      * Whether the set of defined contexts has changed.
40      */

41     private final boolean definedContextIdsChanged;
42
43     /**
44      * Whether the set of enabled contexts has changed.
45      */

46     private final boolean enabledContextIdsChanged;
47
48     /**
49      * The set of context identifiers (strings) that were defined before the
50      * change occurred. If the defined contexts did not changed, then this value
51      * is <code>null</code>.
52      */

53     private final Set JavaDoc previouslyDefinedContextIds;
54
55     /**
56      * The set of context identifiers (strings) that were enabled before the
57      * change occurred. If the enabled contexts did not changed, then this value
58      * is <code>null</code>.
59      */

60     private final Set JavaDoc previouslyEnabledContextIds;
61
62     /**
63      * Creates a new instance of this class.
64      *
65      * @param contextManager
66      * the instance of the interface that changed.
67      * @param definedContextIdsChanged
68      * true, iff the definedContextIds property changed.
69      * @param enabledContextIdsChanged
70      * true, iff the enabledContextIds property changed.
71      * @param previouslyDefinedContextIds
72      * the set of identifiers to previously defined contexts. This
73      * set may be empty. If this set is not empty, it must only
74      * contain instances of <code>String</code>. This set must be
75      * <code>null</code> if definedContextIdsChanged is
76      * <code>false</code> and must not be null if
77      * definedContextIdsChanged is <code>true</code>.
78      * @param previouslyEnabledContextIds
79      * the set of identifiers to previously enabled contexts. This
80      * set may be empty. If this set is not empty, it must only
81      * contain instances of <code>String</code>. This set must be
82      * <code>null</code> if enabledContextIdsChanged is
83      * <code>false</code> and must not be null if
84      * enabledContextIdsChanged is <code>true</code>.
85      */

86     public ContextManagerEvent(IContextManager contextManager,
87             boolean definedContextIdsChanged, boolean enabledContextIdsChanged,
88             Set JavaDoc previouslyDefinedContextIds, Set JavaDoc previouslyEnabledContextIds) {
89         if (contextManager == null) {
90             throw new NullPointerException JavaDoc();
91         }
92
93         if (!definedContextIdsChanged && previouslyDefinedContextIds != null) {
94             throw new IllegalArgumentException JavaDoc();
95         }
96
97         if (!enabledContextIdsChanged && previouslyEnabledContextIds != null) {
98             throw new IllegalArgumentException JavaDoc();
99         }
100
101         if (definedContextIdsChanged) {
102             this.previouslyDefinedContextIds = Util.safeCopy(
103                     previouslyDefinedContextIds, String JavaDoc.class);
104         } else {
105             this.previouslyDefinedContextIds = null;
106         }
107
108         if (enabledContextIdsChanged) {
109             this.previouslyEnabledContextIds = Util.safeCopy(
110                     previouslyEnabledContextIds, String JavaDoc.class);
111         } else {
112             this.previouslyEnabledContextIds = null;
113         }
114
115         this.contextManager = contextManager;
116         this.definedContextIdsChanged = definedContextIdsChanged;
117         this.enabledContextIdsChanged = enabledContextIdsChanged;
118     }
119
120     /**
121      * Returns the instance of the interface that changed.
122      *
123      * @return the instance of the interface that changed. Guaranteed not to be
124      * <code>null</code>.
125      */

126     public IContextManager getContextManager() {
127         return contextManager;
128     }
129
130     /**
131      * Returns the set of identifiers to previously defined contexts.
132      *
133      * @return the set of identifiers to previously defined contexts. This set
134      * may be empty. If this set is not empty, it is guaranteed to only
135      * contain instances of <code>String</code>. This set is
136      * guaranteed to be <code>null</code> if
137      * haveDefinedContextIdsChanged() is <code>false</code> and is
138      * guaranteed to not be null if haveDefinedContextIdsChanged() is
139      * <code>true</code>.
140      */

141     public Set JavaDoc getPreviouslyDefinedContextIds() {
142         return previouslyDefinedContextIds;
143     }
144
145     /**
146      * Returns the set of identifiers to previously enabled contexts.
147      *
148      * @return the set of identifiers to previously enabled contexts. This set
149      * may be empty. If this set is not empty, it is guaranteed to only
150      * contain instances of <code>String</code>. This set is
151      * guaranteed to be <code>null</code> if
152      * haveEnabledContextIdsChanged() is <code>false</code> and is
153      * guaranteed to not be null if haveEnabledContextIdsChanged() is
154      * <code>true</code>.
155      */

156     public Set JavaDoc getPreviouslyEnabledContextIds() {
157         return previouslyEnabledContextIds;
158     }
159
160     /**
161      * Returns whether or not the definedContextIds property changed.
162      *
163      * @return true, iff the definedContextIds property changed.
164      */

165     public boolean haveDefinedContextIdsChanged() {
166         return definedContextIdsChanged;
167     }
168
169     /**
170      * Returns whether or not the enabledContextIds property changed.
171      *
172      * @return true, iff the enabledContextIds property changed.
173      */

174     public boolean haveEnabledContextIdsChanged() {
175         return enabledContextIdsChanged;
176     }
177 }
178
Popular Tags