diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2005-09-23 21:31:04 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-09-23 21:31:04 +0000 |
commit | 1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06 (patch) | |
tree | 3ca4b2e68dc14c3128b9c781d23f1d0b1f2bee49 /libjava/classpath/javax/swing/event | |
parent | 9b044d19517541c95681d35a92dbc81e6e21d94f (diff) | |
download | gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.zip gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.gz gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.bz2 |
Imported Classpath 0.18.
* sources.am, Makefile.in: Updated.
* Makefile.am (nat_source_files): Removed natProxy.cc.
* java/lang/reflect/natProxy.cc: Removed.
* gnu/classpath/jdwp/VMFrame.java,
gnu/classpath/jdwp/VMIdManager.java,
gnu/classpath/jdwp/VMVirtualMachine.java,
java/lang/reflect/VMProxy.java: New files.
2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC
list.
2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/net/DefaultContentHandlerFactory.java (getContent):
Remove ClasspathToolkit references.
2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/awt/xlib/XCanvasPeer.java: Add new peer methods.
* gnu/awt/xlib/XFramePeer.java: Likewise.
* gnu/awt/xlib/XGraphicsConfiguration.java: Likewise.
2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add
classpath/native/jawt/jawt.c.
* Makefile.in: Regenerate.
* jawt.c: Remove file.
* include/Makefile.am (tool_include__HEADERS): Remove jawt.h and
jawt_md.h. Add ../classpath/include/jawt.h and
../classpath/include/jawt_md.h.
* include/Makefile.in: Regenerate.
* include/jawt.h: Regenerate.
* include/jawt_md.h: Regenerate.
From-SVN: r104586
Diffstat (limited to 'libjava/classpath/javax/swing/event')
5 files changed, 355 insertions, 283 deletions
diff --git a/libjava/classpath/javax/swing/event/DocumentEvent.java b/libjava/classpath/javax/swing/event/DocumentEvent.java index 6a005ea..6cd8e61 100644 --- a/libjava/classpath/javax/swing/event/DocumentEvent.java +++ b/libjava/classpath/javax/swing/event/DocumentEvent.java @@ -1,5 +1,5 @@ /* DocumentEvent.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,47 +45,38 @@ import javax.swing.text.Element; * @author Andrew Selkirk * @author Ronald Veldema */ -public interface DocumentEvent { - - //------------------------------------------------------------- - // Classes ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * ElementChange public interface - */ - public interface ElementChange { - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * getIndex - * @returns int - */ - int getIndex(); - - /** - * getElement - * @returns Element - */ - Element getElement(); - - /** - * getChildrenRemoved - * @returns Element[] - */ - Element[] getChildrenRemoved(); +public interface DocumentEvent +{ + /** + * ElementChange public interface + */ + public static interface ElementChange + { + /** + * getIndex + * @returns int + */ + int getIndex(); - /** - * getChildrenAdded - * @returns Element[] - */ - Element[] getChildrenAdded(); + /** + * getElement + * @returns Element + */ + Element getElement(); + /** + * getChildrenRemoved + * @returns Element[] + */ + Element[] getChildrenRemoved(); - } // ElementChange + /** + * getChildrenAdded + * @returns Element[] + */ + Element[] getChildrenAdded(); + + } /** * EventType @@ -131,36 +122,35 @@ public interface DocumentEvent { } } - /** - * getType - * @returns EventType - */ - EventType getType(); - - /** - * getOffset - * @returns int - */ - int getOffset(); - - /** - * getLength - * @returns int - */ - int getLength(); - - /** - * getDocument - * @returns Document - */ - Document getDocument(); - - /** - * getChange - * @param element TODO - * @returns ElementChange - */ - ElementChange getChange(Element element); - - -} // DocumentEvent + /** + * getType + * @returns EventType + */ + EventType getType(); + + /** + * getOffset + * @returns int + */ + int getOffset(); + + /** + * getLength + * @returns int + */ + int getLength(); + + /** + * getDocument + * @returns Document + */ + Document getDocument(); + + /** + * getChange + * @param element TODO + * @returns ElementChange + */ + ElementChange getChange(Element element); + +} diff --git a/libjava/classpath/javax/swing/event/EventListenerList.java b/libjava/classpath/javax/swing/event/EventListenerList.java index ea14d4d..3b9f4c8 100644 --- a/libjava/classpath/javax/swing/event/EventListenerList.java +++ b/libjava/classpath/javax/swing/event/EventListenerList.java @@ -133,7 +133,7 @@ public class EventListenerList * @throws IllegalArgumentException if <code>listener</code> is not * an instance of <code>t</code> (or a subclass thereof). * - * @throws Exception if <code>t</code> is <code>null</code>. + * @throws NullPointerException if <code>t</code> is <code>null</code>. */ public void add(Class t, EventListener listener) { @@ -246,7 +246,7 @@ public class EventListenerList * @throws IllegalArgumentException if <code>listener</code> is not * an instance of <code>t</code> (or a subclass thereof). * - * @throws Exception if <code>t</code> is <code>null</code>. + * @throws NullPointerException if <code>t</code> is <code>null</code>. */ public void remove(Class t, EventListener listener) { diff --git a/libjava/classpath/javax/swing/event/MenuKeyEvent.java b/libjava/classpath/javax/swing/event/MenuKeyEvent.java index 48fcb45..511cb22 100644 --- a/libjava/classpath/javax/swing/event/MenuKeyEvent.java +++ b/libjava/classpath/javax/swing/event/MenuKeyEvent.java @@ -76,7 +76,7 @@ public class MenuKeyEvent extends KeyEvent { * @param when Time * @param modifiers Modifier keys * @param keyCode Key code - * @param keyhar Key char + * @param keyChar Key char * @param path Path * @param manager MenuSelectionManager */ diff --git a/libjava/classpath/javax/swing/event/SwingPropertyChangeSupport.java b/libjava/classpath/javax/swing/event/SwingPropertyChangeSupport.java index ddbb486..408ca95 100644 --- a/libjava/classpath/javax/swing/event/SwingPropertyChangeSupport.java +++ b/libjava/classpath/javax/swing/event/SwingPropertyChangeSupport.java @@ -1,5 +1,5 @@ /* SwingPropertyChangeSupport.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,217 +39,299 @@ package javax.swing.event; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeListenerProxy; import java.beans.PropertyChangeSupport; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import java.util.ArrayList; import java.util.EventListener; import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; /** - * SwingPropertyChangeSupport + * Provides a mechanism for registering {@link PropertyChangeListener}s and + * forwarding {@link PropertyChangeEvent}s to those listeners. + * * @author Andrew Selkirk -*/ -public final class SwingPropertyChangeSupport - extends PropertyChangeSupport { + */ +public final class SwingPropertyChangeSupport + extends PropertyChangeSupport +{ private static final long serialVersionUID = 7162625831330845068L; - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * listeners - */ - private transient EventListenerList listeners; - - /** - * propertyListeners - */ - private Hashtable propertyListeners; - - /** - * source - */ - private Object source; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor SwingPropertyChangeSupport - * @param source TODO - */ - public SwingPropertyChangeSupport(Object source) { - super(source); - this.source = source; - this.listeners = new EventListenerList(); - this.propertyListeners = new Hashtable(); - } // SwingPropertyChangeSupport() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * writeObject - * @param stream TODO - * @exception IOException TODO - */ - private void writeObject(ObjectOutputStream stream) throws IOException { - // TODO - } // writeObject() - - /** - * readObject - * @param stream TODO - * @exception ClassNotFoundException TODO - * @exception IOException TODO - */ - private void readObject(ObjectInputStream stream) throws ClassNotFoundException, IOException { - // TODO - } // readObject() - - /** - * addPropertyChangeListener - * @param listener TODO - */ - public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { - listeners.add(PropertyChangeListener.class, listener); - } // addPropertyChangeListener() - - /** - * addPropertyChangeListener - * @param propertyName TODO - * @param listener TODO - */ - public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - - // Variables - EventListenerList list; - - // Get Listener list - list = (EventListenerList) propertyListeners.get(propertyName); - if (list == null) { - list = new EventListenerList(); - propertyListeners.put(propertyName, list); - } // if - - // Add Listeners - list.add(PropertyChangeListener.class, listener); - - } // addPropertyChangeListener() - - /** - * removePropertyChangeListener - * @param listener TODO - */ - public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { - listeners.remove(PropertyChangeListener.class, listener); - } // removePropertyChangeListener() - - /** - * removePropertyChangeListener - * @param propertyName TODO - * @param listener TODO - */ - public synchronized void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - - // Variables - EventListenerList list; - - // Get Listener list - list = (EventListenerList) propertyListeners.get(propertyName); - if (list == null) { - return; - } // if - - // Remove Listeners - list.remove(PropertyChangeListener.class, listener); - - // Clean up propertyListeners - if (list.getListenerCount() == 0) { - propertyListeners.remove(propertyName); - } // if - - } // removePropertyChangeListener() - - /** - * firePropertyChange - * @param propertyName TODO - * @param oldValue TODO - * @param newValue TODO - */ - public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - - // Variables - PropertyChangeEvent event; - - // Create Property Change Event - event = new PropertyChangeEvent(source, propertyName, oldValue, newValue); - - // Fire Event - firePropertyChange(event); - - } // firePropertyChange() - - /** - * firePropertyChange - * @param event TODO - */ - public void firePropertyChange(PropertyChangeEvent event) { - - // Variables - EventListenerList list; - EventListener[] listenerList; - int index; - PropertyChangeListener listener; - - // Check Values if they are equal - if (event.getOldValue() == null && event.getNewValue() == null || - (event.getOldValue() != null && event.getNewValue() != null && - event.getOldValue().equals(event.getNewValue()))) { - return; - } // if - - // Process Main Listener List - listenerList = listeners.getListeners(PropertyChangeListener.class); - for (index = 0; index < listenerList.length; index++) { - listener = (PropertyChangeListener) listenerList[index]; - listener.propertyChange(event); - } // for - - // Process Property Listener List - list = (EventListenerList) propertyListeners.get(event.getPropertyName()); - if (list != null) { - listenerList = list.getListeners(PropertyChangeListener.class); - for (index = 0; index < listenerList.length; index++) { - listener = (PropertyChangeListener) listenerList[index]; - listener.propertyChange(event); - } // for - } // if - - } // firePropertyChange() - - /** - * hasListeners - * @param propertyName TODO - * @returns boolean - */ - public synchronized boolean hasListeners(String propertyName) { - - // Get Listener list - if (propertyListeners.get(propertyName) == null) { - return false; - } // if - - return true; - - } // hasListeners() - - -} // SwingPropertyChangeSupport + /** + * Storage for the listeners that are not linked to a specific property. + */ + private transient EventListenerList listeners; + + /** + * Storage for the listeners that are linked (by name) to a specific property. + * The hash table maps <code>String</code> objects (the property names) to + * {@link EventListenerList} instances (which record the listener(s) for the + * given property). + */ + private Hashtable propertyListeners; + + /** + * The object that is used as the default source for the + * {@link PropertyChangeEvent}s generated by this class. + */ + private Object source; + + /** + * Creates a new instance. + * + * @param source the source (<code>null</code> not permitted). + * + * @throws NullPointerException if <code>source</code> is <code>null</code>. + */ + public SwingPropertyChangeSupport(Object source) + { + super(source); + this.source = source; + this.listeners = new EventListenerList(); + this.propertyListeners = new Hashtable(); + } + + /** + * Registers <code>listener</code> to receive notification of any future + * {@link PropertyChangeEvent}s generated by this instance. + * + * @param listener the listener (<code>null</code> is ignored). + * + * @see #removePropertyChangeListener(PropertyChangeListener) + */ + public synchronized void addPropertyChangeListener(PropertyChangeListener + listener) + { + listeners.add(PropertyChangeListener.class, listener); + } + + /** + * Registers <code>listener</code> to receive notification of any future + * {@link PropertyChangeEvent}s generated by this instance for the named + * property. + * + * @param propertyName the property name. + * @param listener the listener. + * + * @see #removePropertyChangeListener(String, PropertyChangeListener) + */ + public synchronized void addPropertyChangeListener(String propertyName, + PropertyChangeListener listener) + { + EventListenerList list; + list = (EventListenerList) propertyListeners.get(propertyName); + if (list == null) + { + list = new EventListenerList(); + propertyListeners.put(propertyName, list); + } + list.add(PropertyChangeListener.class, listener); + } + + /** + * Removes <code>listener</code> from the list of registered listeners, so + * that it will no longer receive notification of property change events. + * + * @param listener the listener to remove. + */ + public synchronized void removePropertyChangeListener(PropertyChangeListener + listener) + { + listeners.remove(PropertyChangeListener.class, listener); + } + + /** + * Removes <code>listener</code> from the list of registered listeners for + * the named property, so that it will no longer receive notification of + * property change events. + * + * @param propertyName the property name. + * @param listener the listener to remove. + */ + public synchronized void removePropertyChangeListener(String propertyName, + PropertyChangeListener listener) + { + EventListenerList list; + list = (EventListenerList) propertyListeners.get(propertyName); + if (list == null) + return; + list.remove(PropertyChangeListener.class, listener); + if (list.getListenerCount() == 0) + { + propertyListeners.remove(propertyName); + } + } + + /** + * Returns an array of the {@link PropertyChangeListener}s registered with + * this <code>SwingPropertyChangeSupport</code> instance. + * + * @return The array of listeners. + * + * @since 1.4 + */ + public synchronized PropertyChangeListener[] getPropertyChangeListeners() + { + // fetch the named listeners first so we know how many there are + List namedListeners = new ArrayList(); + Set namedListenerEntries = propertyListeners.entrySet(); + Iterator iterator = namedListenerEntries.iterator(); + while (iterator.hasNext()) + { + Map.Entry e = (Map.Entry) iterator.next(); + String propertyName = (String) e.getKey(); + EventListenerList ell = (EventListenerList) e.getValue(); + if (ell != null) + { + Object[] list = ell.getListenerList(); + for (int i = 0; i < list.length; i += 2) + { + namedListeners.add(new PropertyChangeListenerProxy(propertyName, + (PropertyChangeListener) list[i + 1])); + } + } + } + + // create an array that can hold everything + int size = listeners.getListenerCount() + namedListeners.size(); + PropertyChangeListener[] result = new PropertyChangeListener[size]; + + // copy in the general listeners + Object[] list = listeners.getListenerList(); + int index = 0; + for (int i = 0; i < list.length; i += 2) + result[index++] = (PropertyChangeListener) list[i + 1]; + + // ...and the named listeners + Iterator iterator2 = namedListeners.iterator(); + while (iterator2.hasNext()) + result[index++] = (PropertyChangeListenerProxy) iterator2.next(); + + return result; + } + + /** + * Returns an array of all listeners that are registered to receive + * notification of changes to the named property. This includes the general + * listeners as well as those registered specifically for the named + * property. + * + * @param propertyName the property name. + * + * @return An array of all listeners for the named property. + */ + public synchronized PropertyChangeListener[] getPropertyChangeListeners( + String propertyName) + { + EventListenerList list + = (EventListenerList) propertyListeners.get(propertyName); + if (list == null) + return getPropertyChangeListeners(); + int size = listeners.getListenerCount() + list.getListenerCount(); + PropertyChangeListener[] result = new PropertyChangeListener[size]; + + // copy in the general listeners + int index = 0; + for (int i = 0; i < listeners.listenerList.length; i += 2) + { + result[index++] + = (PropertyChangeListener) listeners.listenerList[i + 1]; + } + + // copy in the specific listeners + Object[] specificListeners = list.getListenerList(); + for (int i = 0; i < specificListeners.length; i += 2) + { + result[index++] = (PropertyChangeListener) specificListeners[i + 1]; + } + return result; + } + + /** + * Creates a new {@link PropertyChangeEvent} using the given arguments (and + * the default <code>source</code> for this + * <code>SwingPropertyChangeSupport</code> instance) and forwards it to all + * registered listeners via the + * {@link PropertyChangeListener#propertyChange(PropertyChangeEvent)} method. + * <p> + * Note that if <code>oldValue</code> and <code>newValue</code> are non-null + * and equal, no listeners will be notified. + * + * @param propertyName the property name. + * @param oldValue the old value + * @param newValue the new value. + */ + public void firePropertyChange(String propertyName, Object oldValue, + Object newValue) + { + PropertyChangeEvent event; + event = new PropertyChangeEvent(source, propertyName, oldValue, newValue); + firePropertyChange(event); + } + + /** + * Forwards <code>event</code> to registered listeners. + * <p> + * Note that if the event's <code>getOldValue()</code> and + * <code>getNewValue()</code> methods return non-null and equal values, no + * listeners will be notified. + * + * @param event the event. + */ + public void firePropertyChange(PropertyChangeEvent event) + { + EventListenerList list; + EventListener[] listenerList; + int index; + PropertyChangeListener listener; + + // Check Values if they are equal + if (event.getOldValue() == null && event.getNewValue() == null || + (event.getOldValue() != null && event.getNewValue() != null && + event.getOldValue().equals(event.getNewValue()))) + return; + + // Process Main Listener List + listenerList = listeners.getListeners(PropertyChangeListener.class); + for (index = 0; index < listenerList.length; index++) + { + listener = (PropertyChangeListener) listenerList[index]; + listener.propertyChange(event); + } + + // Process Property Listener List + list = (EventListenerList) propertyListeners.get(event.getPropertyName()); + if (list != null) + { + listenerList = list.getListeners(PropertyChangeListener.class); + for (index = 0; index < listenerList.length; index++) + { + listener = (PropertyChangeListener) listenerList[index]; + listener.propertyChange(event); + } + } + + } + + /** + * Tell whether the specified property is being listened on or not. This + * will only return <code>true</code> if there are listeners on all + * properties or if there is a listener specifically on this property. + * + * @param propertyName the property that may be listened on + * @return whether the property is being listened on + * @throws NullPointerException if propertyName is null + */ + public synchronized boolean hasListeners(String propertyName) + { + if (listeners.getListenerCount() > 0) + return true; + else + return (propertyListeners.get(propertyName) != null); + } + +} diff --git a/libjava/classpath/javax/swing/event/TreeSelectionEvent.java b/libjava/classpath/javax/swing/event/TreeSelectionEvent.java index df4e0ff..9b87667 100644 --- a/libjava/classpath/javax/swing/event/TreeSelectionEvent.java +++ b/libjava/classpath/javax/swing/event/TreeSelectionEvent.java @@ -100,8 +100,8 @@ public class TreeSelectionEvent extends EventObject { /** * Constructor TreeSelectionEvent * @param source TODO - * @param paths TODO - * @param areNew TODO + * @param path TODO + * @param isNew TODO * @param oldLeadSelectionPath TODO * @param newLeadSelectionPath TODO */ |