1 29 package nextapp.echo2.app.list; 30 31 import java.io.Serializable ; 32 import java.util.EventListener ; 33 34 import nextapp.echo2.app.event.EventListenerList; 35 import nextapp.echo2.app.event.ListDataEvent; 36 import nextapp.echo2.app.event.ListDataListener; 37 38 42 public abstract class AbstractListModel 43 implements ListModel, Serializable { 44 45 48 private EventListenerList listenerList = new EventListenerList(); 49 50 53 public AbstractListModel() { 54 super(); 55 } 56 57 60 public void addListDataListener(ListDataListener l) { 61 listenerList.addListener(ListDataListener.class, l); 62 } 63 64 70 protected EventListenerList getEventListenerList() { 71 return listenerList; 72 } 73 74 82 protected void fireContentsChanged(int index0, int index1) { 83 ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index0, index1); 84 85 EventListener [] listeners = listenerList.getListeners(ListDataListener.class); 86 for (int index = 0; index < listeners.length; ++index) { 87 ((ListDataListener) listeners[index]).contentsChanged(e); 88 } 89 } 90 91 99 protected void fireIntervalAdded(int index0, int index1) { 100 ListDataEvent e = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index0, index1); 101 102 EventListener [] listeners = listenerList.getListeners(ListDataListener.class); 103 for (int index = 0; index < listeners.length; ++index) { 104 ((ListDataListener) listeners[index]).intervalAdded(e); 105 } 106 } 107 108 116 protected void fireIntervalRemoved(int index0, int index1) { 117 ListDataEvent e = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index0, index1); 118 119 EventListener [] listeners = listenerList.getListeners(ListDataListener.class); 120 for (int index = 0; index < listeners.length; ++index) { 121 ((ListDataListener) listeners[index]).intervalRemoved(e); 122 } 123 } 124 125 128 public void removeListDataListener(ListDataListener l) { 129 listenerList.removeListener(ListDataListener.class, l); 130 } 131 } 132 | Popular Tags |