1 11 package org.eclipse.pde.internal.core; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 16 import org.eclipse.pde.core.IModelProviderEvent; 17 import org.eclipse.pde.core.IModelProviderListener; 18 19 public abstract class AbstractModelManager { 20 21 private ArrayList fListeners = new ArrayList (); 22 23 public synchronized void removeModelProviderListener(IModelProviderListener listener) { 24 fListeners.remove(listener); 25 } 26 27 public synchronized void addModelProviderListener(IModelProviderListener listener) { 28 if (!fListeners.contains(listener)) 29 fListeners.add(listener); 30 } 31 32 public void fireModelProviderEvent(IModelProviderEvent event) { 33 for (Iterator iter = fListeners.iterator(); iter.hasNext();) { 34 ((IModelProviderListener) iter.next()).modelsChanged(event); 35 } 36 } 37 38 public void shutdown() { 39 removeListeners(); 40 } 41 42 protected void removeListeners() { 43 if (fListeners.size() > 0) { 44 fListeners.clear(); 45 } 46 } 47 48 } 49 | Popular Tags |