01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.activities;
11:
12: import java.util.ArrayList;
13: import java.util.List;
14:
15: import org.eclipse.ui.activities.ActivityManagerEvent;
16: import org.eclipse.ui.activities.IActivityManager;
17: import org.eclipse.ui.activities.IActivityManagerListener;
18:
19: public abstract class AbstractActivityManager implements
20: IActivityManager {
21: private List activityManagerListeners;
22:
23: protected AbstractActivityManager() {
24: }
25:
26: public void addActivityManagerListener(
27: IActivityManagerListener activityManagerListener) {
28: if (activityManagerListener == null) {
29: throw new NullPointerException();
30: }
31:
32: if (activityManagerListeners == null) {
33: activityManagerListeners = new ArrayList();
34: }
35:
36: if (!activityManagerListeners.contains(activityManagerListener)) {
37: activityManagerListeners.add(activityManagerListener);
38: }
39: }
40:
41: protected void fireActivityManagerChanged(
42: ActivityManagerEvent activityManagerEvent) {
43: if (activityManagerEvent == null) {
44: throw new NullPointerException();
45: }
46:
47: if (activityManagerListeners != null) {
48: for (int i = 0; i < activityManagerListeners.size(); i++) {
49: ((IActivityManagerListener) activityManagerListeners
50: .get(i))
51: .activityManagerChanged(activityManagerEvent);
52: }
53: }
54: }
55:
56: public void removeActivityManagerListener(
57: IActivityManagerListener activityManagerListener) {
58: if (activityManagerListener == null) {
59: throw new NullPointerException();
60: }
61:
62: if (activityManagerListeners != null) {
63: activityManagerListeners.remove(activityManagerListener);
64: }
65: }
66: }
|