diff options
author | Michael Koch <konqueror@gmx.de> | 2003-04-29 09:26:29 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2003-04-29 09:26:29 +0000 |
commit | cac9b0bcb14159dc05310d74adad4378a0e339bf (patch) | |
tree | fd553118dbf7dedb7aaf77964f83aa6880900415 /libjava/javax/swing/AbstractListModel.java | |
parent | 7e89296c0b9f89ccfbd4c3dd12b64b6d2096fe60 (diff) | |
download | gcc-cac9b0bcb14159dc05310d74adad4378a0e339bf.zip gcc-cac9b0bcb14159dc05310d74adad4378a0e339bf.tar.gz gcc-cac9b0bcb14159dc05310d74adad4378a0e339bf.tar.bz2 |
AbstractListModel.java, [...]: New Versions from classpath.
2003-04-29 Michael Koch <konqueror@gmx.de>
* javax/swing/AbstractListModel.java,
javax/swing/DefaultBoundedRangeModel.java,
javax/swing/DefaultSingleSelectionModel.java:
New Versions from classpath.
From-SVN: r66212
Diffstat (limited to 'libjava/javax/swing/AbstractListModel.java')
-rw-r--r-- | libjava/javax/swing/AbstractListModel.java | 319 |
1 files changed, 154 insertions, 165 deletions
diff --git a/libjava/javax/swing/AbstractListModel.java b/libjava/javax/swing/AbstractListModel.java index 4f7e827..4e227b4 100644 --- a/libjava/javax/swing/AbstractListModel.java +++ b/libjava/javax/swing/AbstractListModel.java @@ -37,10 +37,11 @@ exception statement from your version. */ package javax.swing; -// Imports -import java.io.*; -import java.util.*; -import javax.swing.event.*; +import java.io.Serializable; +import java.util.EventListener; +import javax.swing.event.EventListenerList; +import javax.swing.event.ListDataListener; +import javax.swing.event.ListDataEvent; /** * AbstractListModel @@ -53,164 +54,152 @@ public abstract class AbstractListModel { static final long serialVersionUID = -3285184064379168730L; - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * listenerList - */ - protected EventListenerList listenerList = new EventListenerList(); - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor AbstractListModel - */ - public AbstractListModel() { - } // AbstractListModel() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * addListDataListener - * @param listener TODO - */ - public void addListDataListener(ListDataListener listener) { - listenerList.add(ListDataListener.class, (EventListener) listener); - } // addListDataListener() - - /** - * removeListDataListener - * @param listener TODO - */ - public void removeListDataListener(ListDataListener listener) { - listenerList.remove(ListDataListener.class, (EventListener) listener); - } // removeListDataListener() - - /** - * fireContentsChanged - * @param source TODO - * @param startIndex TODO - * @param endIndex TODO - */ - protected void fireContentsChanged(Object source, int startIndex, int endIndex) { - - // Variables - ListDataEvent event; - EventListener[] listeners; - ListDataListener listener; - int index; - - // Create Event - event = new ListDataEvent(source, ListDataEvent.CONTENTS_CHANGED, - startIndex, endIndex); - - // Get Listeners - listeners = listenerList.getListeners(ListDataListener.class); - - // Process Listeners - for (index = 0; index < listeners.length; index++) { - listener = (ListDataListener) listeners[index]; - listener.contentsChanged(event); - } // for - - } // fireContentsChanged() - - /** - * fireIntervalAdded - * @param source TODO - * @param startIndex TODO - * @param endIndex TODO - */ - protected void fireIntervalAdded(Object source, int startIndex, int endIndex) { - - // Variables - ListDataEvent event; - EventListener[] listeners; - ListDataListener listener; - int index; - - // Create Event - event = new ListDataEvent(source, ListDataEvent.INTERVAL_ADDED, - startIndex, endIndex); - - // Get Listeners - listeners = listenerList.getListeners(ListDataListener.class); - - // Process Listeners - for (index = 0; index < listeners.length; index++) { - listener = (ListDataListener) listeners[index]; - listener.intervalAdded(event); - } // for - - } // fireIntervalAdded() - - /** - * fireIntervalRemoved - * @param source TODO - * @param startIndex TODO - * @param endIndex TODO - */ - protected void fireIntervalRemoved(Object source, int startIndex, int endIndex) { - - // Variables - ListDataEvent event; - EventListener[] listeners; - ListDataListener listener; - int index; - - // Create Event - event = new ListDataEvent(source, ListDataEvent.INTERVAL_REMOVED, - startIndex, endIndex); - - // Get Listeners - listeners = listenerList.getListeners(ListDataListener.class); - - // Process Listeners - for (index = 0; index < listeners.length; index++) { - listener = (ListDataListener) listeners[index]; - listener.intervalRemoved(event); - } // for - - } // fireIntervalRemoved() - - /** - * getListeners - * @param listenerType TODO - * @returns EventListener[] - */ - public EventListener[] getListeners(Class listenerType) { - return listenerList.getListeners(listenerType); - } // getListeners() - - /** - * getListDataListeners - */ - public ListDataListener[] getListDataListeners() - { - // FIXME: implement this - return null; - } - - /** - * getElementAt - * @param index TODO - * @returns Object - */ - public abstract Object getElementAt(int index); - - /** - * getSize - * @returns int - */ - public abstract int getSize(); - - -} // AbstractListModel + /** + * listenerList + */ + protected EventListenerList listenerList = new EventListenerList (); + + /** + * Constructor AbstractListModel + */ + public AbstractListModel () + { + } + + /** + * addListDataListener + * @param listener TODO + */ + public void addListDataListener(ListDataListener listener) + { + listenerList.add (ListDataListener.class, listener); + } + + /** + * removeListDataListener + * @param listener TODO + */ + public void removeListDataListener(ListDataListener listener) + { + listenerList.remove (ListDataListener.class, listener); + } + + /** + * fireContentsChanged + * @param source TODO + * @param startIndex TODO + * @param endIndex TODO + */ + protected void fireContentsChanged(Object source, int startIndex, int endIndex) + { + // Variables + ListDataEvent event; + ListDataListener[] listeners; + ListDataListener listener; + int index; + + // Create Event + event = new ListDataEvent(source, ListDataEvent.CONTENTS_CHANGED, + startIndex, endIndex); + + // Get Listeners + listeners = getListDataListeners (); + + // Process Listeners + for (index = 0; index < listeners.length; index++) + { + listener = (ListDataListener) listeners[index]; + listener.contentsChanged(event); + } + } + + /** + * fireIntervalAdded + * @param source TODO + * @param startIndex TODO + * @param endIndex TODO + */ + protected void fireIntervalAdded (Object source, int startIndex, int endIndex) + { + // Variables + ListDataEvent event; + ListDataListener[] listeners; + ListDataListener listener; + int index; + + // Create Event + event = new ListDataEvent (source, ListDataEvent.INTERVAL_ADDED, startIndex, + endIndex); + + // Get Listeners + listeners = getListDataListeners (); + + // Process Listeners + for (index = 0; index < listeners.length; index++) + { + listener = listeners [index]; + listener.intervalAdded (event); + } + } + + /** + * fireIntervalRemoved + * @param source TODO + * @param startIndex TODO + * @param endIndex TODO + */ + protected void fireIntervalRemoved (Object source, int startIndex, + int endIndex) + { + // Variables + ListDataEvent event; + ListDataListener[] listeners; + ListDataListener listener; + int index; + + // Create Event + event = new ListDataEvent (source, ListDataEvent.INTERVAL_REMOVED, + startIndex, endIndex); + + // Get Listeners + listeners = getListDataListeners (); + + // Process Listeners + for (index = 0; index < listeners.length; index++) + { + listener = listeners [index]; + listener.intervalRemoved (event); + } + } + + /** + * getListeners + * @param listenerType TODO + * @returns EventListener[] + */ + public EventListener[] getListeners (Class listenerType) + { + return listenerList.getListeners (listenerType); + } + + /** + * getListDataListeners + */ + public ListDataListener[] getListDataListeners () + { + return (ListDataListener[]) getListeners (ListDataListener.class); + } + + /** + * getElementAt + * @param index TODO + * @returns Object + */ + public abstract Object getElementAt (int index); + + /** + * getSize + * @returns int + */ + public abstract int getSize (); +} |