1 11 12 package org.eclipse.ui.internal.activities; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 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 activityManagerListeners; 23 24 protected AbstractActivityManager() { 25 } 26 27 public void addActivityManagerListener( 28 IActivityManagerListener activityManagerListener) { 29 if (activityManagerListener == null) { 30 throw new NullPointerException (); 31 } 32 33 if (activityManagerListeners == null) { 34 activityManagerListeners = new ArrayList (); 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 (); 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 (); 60 } 61 62 if (activityManagerListeners != null) { 63 activityManagerListeners.remove(activityManagerListener); 64 } 65 } 66 } 67 | Popular Tags |