KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > activities > ActivityManagerEvent


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.activities;
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>IActivityManager</code>. This class does not give details as to the
21  * specifics of a change, only that the given property on the source object has
22  * changed.
23  *
24  * <p>
25  * This class is not intended to be extended by clients.
26  * </p>
27  *
28  * @since 3.0
29  * @see IActivityManagerListener#activityManagerChanged(ActivityManagerEvent)
30  */

31 public final class ActivityManagerEvent {
32     private IActivityManager activityManager;
33
34     private boolean definedActivityIdsChanged;
35
36     private boolean definedCategoryIdsChanged;
37
38     private boolean enabledActivityIdsChanged;
39
40     /**
41      * The set of activity identifiers (strings) that were defined before the
42      * change occurred. If the defined activities did not changed, then this
43      * value is <code>null</code>.
44      */

45     private final Set JavaDoc previouslyDefinedActivityIds;
46
47     /**
48      * The set of category identifiers (strings) that were defined before the
49      * change occurred. If the defined category did not changed, then this value
50      * is <code>null</code>.
51      */

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

59     private final Set JavaDoc previouslyEnabledActivityIds;
60
61     /**
62      * Creates a new instance of this class.
63      *
64      * @param activityManager
65      * the instance of the interface that changed.
66      * @param definedActivityIdsChanged
67      * <code>true</code>, iff the definedActivityIds property
68      * changed.
69      * @param definedCategoryIdsChanged
70      * <code>true</code>, iff the definedCategoryIds property
71      * changed.
72      * @param enabledActivityIdsChanged
73      * <code>true</code>, iff the enabledActivityIds property
74      * changed.
75      * @param previouslyDefinedActivityIds
76      * the set of identifiers to previously defined activities. This
77      * set may be empty. If this set is not empty, it must only
78      * contain instances of <code>String</code>. This set must be
79      * <code>null</code> if definedActivityIdsChanged is
80      * <code>false</code> and must not be null if
81      * definedActivityIdsChanged is <code>true</code>.
82      * @param previouslyDefinedCategoryIds
83      * the set of identifiers to previously defined category. This
84      * set may be empty. If this set is not empty, it must only
85      * contain instances of <code>String</code>. This set must be
86      * <code>null</code> if definedCategoryIdsChanged is
87      * <code>false</code> and must not be null if
88      * definedCategoryIdsChanged is <code>true</code>.
89      * @param previouslyEnabledActivityIds
90      * the set of identifiers to previously enabled activities. This
91      * set may be empty. If this set is not empty, it must only
92      * contain instances of <code>String</code>. This set must be
93      * <code>null</code> if enabledActivityIdsChanged is
94      * <code>false</code> and must not be null if
95      * enabledActivityIdsChanged is <code>true</code>.
96      */

97     public ActivityManagerEvent(IActivityManager activityManager,
98             boolean definedActivityIdsChanged,
99             boolean definedCategoryIdsChanged,
100             boolean enabledActivityIdsChanged,
101             final Set JavaDoc previouslyDefinedActivityIds,
102             final Set JavaDoc previouslyDefinedCategoryIds,
103             final Set JavaDoc previouslyEnabledActivityIds) {
104         if (activityManager == null) {
105             throw new NullPointerException JavaDoc();
106         }
107
108         if (!definedActivityIdsChanged && previouslyDefinedActivityIds != null) {
109             throw new IllegalArgumentException JavaDoc();
110         }
111
112         if (!definedCategoryIdsChanged && previouslyDefinedCategoryIds != null) {
113             throw new IllegalArgumentException JavaDoc();
114         }
115
116         if (!enabledActivityIdsChanged && previouslyEnabledActivityIds != null) {
117             throw new IllegalArgumentException JavaDoc();
118         }
119
120         if (definedActivityIdsChanged) {
121             this.previouslyDefinedActivityIds = Util.safeCopy(
122                     previouslyDefinedActivityIds, String JavaDoc.class);
123         } else {
124             this.previouslyDefinedActivityIds = null;
125         }
126
127         if (definedCategoryIdsChanged) {
128             this.previouslyDefinedCategoryIds = Util.safeCopy(
129                     previouslyDefinedCategoryIds, String JavaDoc.class);
130         } else {
131             this.previouslyDefinedCategoryIds = null;
132         }
133
134         if (enabledActivityIdsChanged) {
135             this.previouslyEnabledActivityIds = Util.safeCopy(
136                     previouslyEnabledActivityIds, String JavaDoc.class);
137         } else {
138             this.previouslyEnabledActivityIds = null;
139         }
140
141         this.activityManager = activityManager;
142         this.definedActivityIdsChanged = definedActivityIdsChanged;
143         this.definedCategoryIdsChanged = definedCategoryIdsChanged;
144         this.enabledActivityIdsChanged = enabledActivityIdsChanged;
145     }
146
147     /**
148      * Returns the instance of the interface that changed.
149      *
150      * @return the instance of the interface that changed. Guaranteed not to be
151      * <code>null</code>.
152      */

153     public IActivityManager getActivityManager() {
154         return activityManager;
155     }
156
157     /**
158      * Returns the activity identifiers that were previously defined.
159      *
160      * @return The set of defined activity identifiers before the changed; may
161      * be empty, but never <code>null</code>. This set will only
162      * contain strings.
163      */

164     public final Set JavaDoc getPreviouslyDefinedActivityIds() {
165         return previouslyDefinedActivityIds;
166     }
167
168     /**
169      * Returns the category identifiers that were previously defined.
170      *
171      * @return The set of defined category identifiers before the changed; may
172      * be empty, but never <code>null</code>. This set will only
173      * contain strings.
174      */

175     public final Set JavaDoc getPreviouslyDefinedCategoryIds() {
176         return previouslyDefinedCategoryIds;
177     }
178
179     /**
180      * Returns the activity identifiers that were previously enabled.
181      *
182      * @return The set of enabled activity identifiers before the changed; may
183      * be empty, but never <code>null</code>. This set will only
184      * contain strings.
185      */

186     public final Set JavaDoc getPreviouslyEnabledActivityIds() {
187         return previouslyEnabledActivityIds;
188     }
189
190     /**
191      * Returns whether or not the definedActivityIds property changed.
192      *
193      * @return <code>true</code>, iff the definedActivityIds property changed.
194      */

195     public boolean haveDefinedActivityIdsChanged() {
196         return definedActivityIdsChanged;
197     }
198
199     /**
200      * Returns whether or not the definedCategoryIds property changed.
201      *
202      * @return <code>true</code>, iff the definedCategoryIds property changed.
203      */

204     public boolean haveDefinedCategoryIdsChanged() {
205         return definedCategoryIdsChanged;
206     }
207
208     /**
209      * Returns whether or not the enabledActivityIds property changed.
210      *
211      * @return <code>true</code>, iff the enabledActivityIds property changed.
212      */

213     public boolean haveEnabledActivityIdsChanged() {
214         return enabledActivityIdsChanged;
215     }
216 }
217
Popular Tags