001: /*******************************************************************************
002: * Copyright (c) 2000, 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.internal.activities;
011:
012: import java.util.ArrayList;
013: import java.util.Collections;
014: import java.util.List;
015:
016: public abstract class AbstractActivityRegistry implements
017: IActivityRegistry {
018: protected List activityRequirementBindingDefinitions = Collections.EMPTY_LIST;
019:
020: protected List activityDefinitions = Collections.EMPTY_LIST;
021:
022: protected List activityPatternBindingDefinitions = Collections.EMPTY_LIST;
023:
024: private ActivityRegistryEvent activityRegistryEvent;
025:
026: private List activityRegistryListeners;
027:
028: protected List categoryActivityBindingDefinitions = Collections.EMPTY_LIST;
029:
030: protected List categoryDefinitions = Collections.EMPTY_LIST;
031:
032: protected List defaultEnabledActivities = Collections.EMPTY_LIST;
033:
034: protected AbstractActivityRegistry() {
035: }
036:
037: public void addActivityRegistryListener(
038: IActivityRegistryListener activityRegistryListener) {
039: if (activityRegistryListener == null) {
040: throw new NullPointerException();
041: }
042:
043: if (activityRegistryListeners == null) {
044: activityRegistryListeners = new ArrayList();
045: }
046:
047: if (!activityRegistryListeners
048: .contains(activityRegistryListener)) {
049: activityRegistryListeners.add(activityRegistryListener);
050: }
051: }
052:
053: protected void fireActivityRegistryChanged() {
054: if (activityRegistryListeners != null) {
055: for (int i = 0; i < activityRegistryListeners.size(); i++) {
056: if (activityRegistryEvent == null) {
057: activityRegistryEvent = new ActivityRegistryEvent(
058: this );
059: }
060:
061: ((IActivityRegistryListener) activityRegistryListeners
062: .get(i))
063: .activityRegistryChanged(activityRegistryEvent);
064: }
065: }
066: }
067:
068: public List getActivityRequirementBindingDefinitions() {
069: return activityRequirementBindingDefinitions;
070: }
071:
072: public List getActivityDefinitions() {
073: return activityDefinitions;
074: }
075:
076: public List getActivityPatternBindingDefinitions() {
077: return activityPatternBindingDefinitions;
078: }
079:
080: public List getCategoryActivityBindingDefinitions() {
081: return categoryActivityBindingDefinitions;
082: }
083:
084: public List getCategoryDefinitions() {
085: return categoryDefinitions;
086: }
087:
088: public void removeActivityRegistryListener(
089: IActivityRegistryListener activityRegistryListener) {
090: if (activityRegistryListener == null) {
091: throw new NullPointerException();
092: }
093:
094: if (activityRegistryListeners != null) {
095: activityRegistryListeners.remove(activityRegistryListener);
096: }
097: }
098:
099: public List getDefaultEnabledActivities() {
100: return defaultEnabledActivities;
101: }
102: }
|