KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
16
17 import org.eclipse.ui.activities.ActivityManagerEvent;
18 import org.eclipse.ui.activities.IActivityManager;
19 import org.eclipse.ui.activities.IActivityManagerListener;
20
21 public abstract class AbstractActivityManager implements IActivityManager {
22     private List JavaDoc activityManagerListeners;
23
24     protected AbstractActivityManager() {
25     }
26
27     public void addActivityManagerListener(
28             IActivityManagerListener activityManagerListener) {
29         if (activityManagerListener == null) {
30             throw new NullPointerException JavaDoc();
31         }
32
33         if (activityManagerListeners == null) {
34             activityManagerListeners = new ArrayList JavaDoc();
35         }
36
37         if (!activityManagerListeners.contains(activityManagerListener)) {
38             activityManagerListeners.add(activityManagerListener);
39         }
40     }
41
42     protected void fireActivityManagerChanged(
43             ActivityManagerEvent activityManagerEvent) {
44         if (activityManagerEvent == null) {
45             throw new NullPointerException JavaDoc();
46         }
47
48         if (activityManagerListeners != null) {
49             for (int i = 0; i < activityManagerListeners.size(); i++) {
50                 ((IActivityManagerListener) activityManagerListeners.get(i))
51                         .activityManagerChanged(activityManagerEvent);
52             }
53         }
54     }
55
56     public void removeActivityManagerListener(
57             IActivityManagerListener activityManagerListener) {
58         if (activityManagerListener == null) {
59             throw new NullPointerException JavaDoc();
60         }
61
62         if (activityManagerListeners != null) {
63             activityManagerListeners.remove(activityManagerListener);
64         }
65     }
66 }
67
Popular Tags