1 11 package org.eclipse.jface.viewers.deferred; 12 13 import org.eclipse.core.runtime.ListenerList; 14 15 16 22 public abstract class AbstractConcurrentModel implements 23 IConcurrentModel { 24 25 private ListenerList listeners = new ListenerList(); 26 27 30 public void addListener(IConcurrentModelListener listener) { 31 listeners.add(listener); 32 } 33 34 39 protected final void fireAdd(Object [] added) { 40 Object [] listenerArray = listeners.getListeners(); 41 42 for (int i = 0; i < listenerArray.length; i++) { 43 IConcurrentModelListener next = (IConcurrentModelListener) listenerArray[i]; 44 45 next.add(added); 46 } 47 } 48 49 54 protected final void fireRemove(Object [] removed) { 55 Object [] listenerArray = listeners.getListeners(); 56 57 for (int i = 0; i < listenerArray.length; i++) { 58 IConcurrentModelListener next = (IConcurrentModelListener) listenerArray[i]; 59 60 next.remove(removed); 61 } 62 } 63 64 69 protected final void fireUpdate(Object [] updated) { 70 Object [] listenerArray = listeners.getListeners(); 71 72 for (int i = 0; i < listenerArray.length; i++) { 73 IConcurrentModelListener next = (IConcurrentModelListener) listenerArray[i]; 74 75 next.update(updated); 76 } 77 } 78 79 84 protected final IConcurrentModelListener[] getListeners() { 85 Object [] l = listeners.getListeners(); 86 IConcurrentModelListener[] result = new IConcurrentModelListener[l.length]; 87 88 for (int i = 0; i < l.length; i++) { 89 result[i] = (IConcurrentModelListener)l[i]; 90 } 91 92 return result; 93 } 94 95 98 public void removeListener(IConcurrentModelListener listener) { 99 listeners.remove(listener); 100 } 101 } 102 | Popular Tags |