1 11 12 package org.eclipse.ui.internal.contexts; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 import org.eclipse.ui.contexts.ContextManagerEvent; 18 import org.eclipse.ui.contexts.IContextManager; 19 import org.eclipse.ui.contexts.IContextManagerListener; 20 21 public abstract class AbstractContextManager implements IContextManager { 22 private List contextManagerListeners; 23 24 protected AbstractContextManager() { 25 } 26 27 public void addContextManagerListener(IContextManagerListener contextManagerListener) { 28 if (contextManagerListener == null) 29 throw new NullPointerException (); 30 31 if (contextManagerListeners == null) 32 contextManagerListeners = new ArrayList (); 33 34 if (!contextManagerListeners.contains(contextManagerListener)) 35 contextManagerListeners.add(contextManagerListener); 36 } 37 38 protected void fireContextManagerChanged(ContextManagerEvent contextManagerEvent) { 39 if (contextManagerEvent == null) 40 throw new NullPointerException (); 41 42 if (contextManagerListeners != null) 43 for (int i = 0; i < contextManagerListeners.size(); i++) 44 ( 45 (IContextManagerListener) contextManagerListeners.get( 46 i)).contextManagerChanged( 47 contextManagerEvent); 48 } 49 50 public void removeContextManagerListener(IContextManagerListener contextManagerListener) { 51 if (contextManagerListener == null) 52 throw new NullPointerException (); 53 54 if (contextManagerListeners != null) 55 contextManagerListeners.remove(contextManagerListener); 56 } 57 } 58 | Popular Tags |