1 11 12 package org.eclipse.ui.internal.activities; 13 14 import java.util.ArrayList ; 15 import java.util.Collections ; 16 import java.util.List ; 17 18 public abstract class AbstractActivityRegistry implements IActivityRegistry { 19 protected List activityRequirementBindingDefinitions = Collections.EMPTY_LIST; 20 21 protected List activityDefinitions = Collections.EMPTY_LIST; 22 23 protected List activityPatternBindingDefinitions = Collections.EMPTY_LIST; 24 25 private ActivityRegistryEvent activityRegistryEvent; 26 27 private List activityRegistryListeners; 28 29 protected List categoryActivityBindingDefinitions = Collections.EMPTY_LIST; 30 31 protected List categoryDefinitions = Collections.EMPTY_LIST; 32 33 protected List 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 (); 42 } 43 44 if (activityRegistryListeners == null) { 45 activityRegistryListeners = new ArrayList (); 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 getActivityRequirementBindingDefinitions() { 67 return activityRequirementBindingDefinitions; 68 } 69 70 public List getActivityDefinitions() { 71 return activityDefinitions; 72 } 73 74 public List getActivityPatternBindingDefinitions() { 75 return activityPatternBindingDefinitions; 76 } 77 78 public List getCategoryActivityBindingDefinitions() { 79 return categoryActivityBindingDefinitions; 80 } 81 82 public List getCategoryDefinitions() { 83 return categoryDefinitions; 84 } 85 86 public void removeActivityRegistryListener( 87 IActivityRegistryListener activityRegistryListener) { 88 if (activityRegistryListener == null) { 89 throw new NullPointerException (); 90 } 91 92 if (activityRegistryListeners != null) { 93 activityRegistryListeners.remove(activityRegistryListener); 94 } 95 } 96 97 public List getDefaultEnabledActivities() { 98 return defaultEnabledActivities; 99 } 100 } 101 | Popular Tags |