KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > activities > AbstractActivityRegistry


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.internal.activities;
13
14 import java.util.ArrayList JavaDoc;
15 import java.util.Collections JavaDoc;
16 import java.util.List JavaDoc;
17
18 public abstract class AbstractActivityRegistry implements IActivityRegistry {
19     protected List JavaDoc activityRequirementBindingDefinitions = Collections.EMPTY_LIST;
20
21     protected List JavaDoc activityDefinitions = Collections.EMPTY_LIST;
22
23     protected List JavaDoc activityPatternBindingDefinitions = Collections.EMPTY_LIST;
24
25     private ActivityRegistryEvent activityRegistryEvent;
26
27     private List JavaDoc activityRegistryListeners;
28
29     protected List JavaDoc categoryActivityBindingDefinitions = Collections.EMPTY_LIST;
30
31     protected List JavaDoc categoryDefinitions = Collections.EMPTY_LIST;
32
33     protected List JavaDoc defaultEnabledActivities = Collections.EMPTY_LIST;
34
35     protected AbstractActivityRegistry() {
36     }
37
38     public void addActivityRegistryListener(
39             IActivityRegistryListener activityRegistryListener) {
40         if (activityRegistryListener == null) {
41             throw new NullPointerException JavaDoc();
42         }
43
44         if (activityRegistryListeners == null) {
45             activityRegistryListeners = new ArrayList JavaDoc();
46         }
47
48         if (!activityRegistryListeners.contains(activityRegistryListener)) {
49             activityRegistryListeners.add(activityRegistryListener);
50         }
51     }
52
53     protected void fireActivityRegistryChanged() {
54         if (activityRegistryListeners != null) {
55             for (int i = 0; i < activityRegistryListeners.size(); i++) {
56                 if (activityRegistryEvent == null) {
57                     activityRegistryEvent = new ActivityRegistryEvent(this);
58                 }
59
60                 ((IActivityRegistryListener) activityRegistryListeners.get(i))
61                         .activityRegistryChanged(activityRegistryEvent);
62             }
63         }
64     }
65
66     public List JavaDoc getActivityRequirementBindingDefinitions() {
67         return activityRequirementBindingDefinitions;
68     }
69
70     public List JavaDoc getActivityDefinitions() {
71         return activityDefinitions;
72     }
73
74     public List JavaDoc getActivityPatternBindingDefinitions() {
75         return activityPatternBindingDefinitions;
76     }
77
78     public List JavaDoc getCategoryActivityBindingDefinitions() {
79         return categoryActivityBindingDefinitions;
80     }
81
82     public List JavaDoc getCategoryDefinitions() {
83         return categoryDefinitions;
84     }
85
86     public void removeActivityRegistryListener(
87             IActivityRegistryListener activityRegistryListener) {
88         if (activityRegistryListener == null) {
89             throw new NullPointerException JavaDoc();
90         }
91
92         if (activityRegistryListeners != null) {
93             activityRegistryListeners.remove(activityRegistryListener);
94         }
95     }
96
97     public List JavaDoc getDefaultEnabledActivities() {
98         return defaultEnabledActivities;
99     }
100 }
101
Popular Tags