+2003-03-02 Michael Koch <konqueror@gmx.de>
+
+ * java/awt/dnd/DnDEventMulticaster.java: New file.
+ * java/awt/dnd/DragSource.java
+ (flavorMap): New member variable.
+ (dragSourceListener): New member variable.
+ (dragSourceMotionListener): New member variable.
+ (getFlavorMap): Implemented.
+ (createDragGestureRecognizer): Implemented.
+ (addDragSourceListener): Implemented.
+ (removeDragSourceListener): Implemented.
+ (getDragSourceListeners): Implemented.
+ (addDragSourceMotionListener): Implemented.
+ (removeDragSourceMotionListener): Implemented.
+ (getDragSourceMotionListeners): Implemented.
+ (getListeners): Implemented.
+ * java/awt/dnd/DragSourceContext.java
+ (peer): New member variable.
+ (cursor): New member variable.
+ (transferable): New member variable.
+ (trigger): New member variable.
+ (dragSourceListener): New member variable.
+ (image): New member variable.
+ (offset): New member variable.
+ (DragSourceContext): Implemented.
+ (getDragSource): Implemented.
+ (getComponent): Implemented.
+ (getTrigger): Implemented.
+ (getSourceActions): Implemented.
+ (setCursor): Implemented.
+ (getCursor): Implemented.
+ (addDragSourceListener): Implemented.
+ (removeDragSourceListener): Implemented.
+ (getTransferable): Implemented.
+ * java/awt/dnd/DropTarget.java
+ (DropTargetAutoScroller.component): New member variable.
+ (DropTargetAutoScroller.point): New member variable.
+ (DropTargetAutoScroller.DropTargetAutoScroller): Implemented.
+ (DropTargetAutoScroller.updateLocation): Implemented.
+ (active): Renamed from isActive, defaults to true now.
+ (component): New member variable.
+ (flavorMap): New member variable.
+ (actions): New member variable.
+ (dropTargetContext): New member variable.
+ (dropTargetListener): New member variable.
+ (DropTarget): Implemented.
+ (getComponent): Implemented.
+ (setComponent): Implemented.
+ (setDefaultActions): Implemented.
+ (getDefaultActions): Implemented.
+ (setActive): Use active instead of isActive.
+ (isActive): Use active instead of isActive.
+ (addDropTargetListener): Implemented.
+ (removeDropTargetListener): Implemented.
+ (getFlavorMap): Implemented.
+ (setFlavorMap): Implemented.
+ (getDropTargetContext): Implemented.
+ (createDropTargetContext): Implemented.
+ (createDropTargetAutoScroller): Implemented.
+ * java/awt/dnd/DropTargetContext.java
+ (TransferableProxy.getTransferDataFlavors): Implemented.
+ (TransferableProxy.isDataFlavorSupported): Implemented.
+ (TransferableProxy.getTransferData): Implemented.
+ (dropTarget): New member variable.
+ (dtcp): New member variable.
+ (DropTargetContext): New package private constructor.
+ (getDropTarget): Implemented.
+ (getComponent): Implemented.
+ (addNotify): Implemented.
+ (removeNotify): Implemented.
+ (getCurrentDataFlavorsAsList): Implemented.
+ (isDataFlavorSupported): Implemented.
+ * java/awt/dnd/MouseDragGestureRecognizer.java
+ (registerListeners): Implemented.
+ (unregisterListeners): Implemented.
+ * Makefile.am
+ (awt_java_source_files): Added java/awt/dnd/DnDEventMulticaster.java.
+ * Makefile.in: Regenerated.
+
2003-03-02 Michael Koch <konqueror@gmx.de>
* java/awt/Component.java
java/awt/dnd/peer/DropTargetContextPeer.java \
java/awt/dnd/peer/DropTargetPeer.java \
java/awt/dnd/DnDConstants.java \
+java/awt/dnd/DnDEventMulticaster.java \
java/awt/dnd/DragGestureEvent.java \
java/awt/dnd/DragGestureListener.java \
java/awt/dnd/DragGestureRecognizer.java \
java/awt/dnd/peer/DropTargetContextPeer.java \
java/awt/dnd/peer/DropTargetPeer.java \
java/awt/dnd/DnDConstants.java \
+java/awt/dnd/DnDEventMulticaster.java \
java/awt/dnd/DragGestureEvent.java \
java/awt/dnd/DragGestureListener.java \
java/awt/dnd/DragGestureRecognizer.java \
.deps/java/awt/datatransfer/Transferable.P \
.deps/java/awt/datatransfer/UnsupportedFlavorException.P \
.deps/java/awt/dnd/Autoscroll.P .deps/java/awt/dnd/DnDConstants.P \
+.deps/java/awt/dnd/DnDEventMulticaster.P \
.deps/java/awt/dnd/DragGestureEvent.P \
.deps/java/awt/dnd/DragGestureListener.P \
.deps/java/awt/dnd/DragGestureRecognizer.P \
--- /dev/null
+/* DnDEventMulticaster.java -- helper class for listener chains in java.awt.dnd
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.dnd;
+
+import java.awt.AWTEventMulticaster;
+import java.util.EventListener;
+
+class DnDEventMulticaster extends AWTEventMulticaster
+{
+ protected DnDEventMulticaster (EventListener a, EventListener b)
+ {
+ super (a, b);
+ }
+
+ public static DragSourceListener add (DragSourceListener a,
+ DragSourceListener b)
+ {
+ return (DragSourceListener) addInternal (a, b);
+ }
+
+ public static DragSourceMotionListener add (DragSourceMotionListener a,
+ DragSourceMotionListener b)
+ {
+ return (DragSourceMotionListener) addInternal (a, b);
+ }
+
+ public static DragSourceListener remove (DragSourceListener a,
+ DragSourceListener b)
+ {
+ return (DragSourceListener) removeInternal (a, b);
+ }
+
+ public static DragSourceMotionListener remove (DragSourceMotionListener a,
+ DragSourceMotionListener b)
+ {
+ return (DragSourceMotionListener) removeInternal (a, b);
+ }
+}
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Point;
+import java.awt.Toolkit;
import java.awt.datatransfer.FlavorMap;
+import java.awt.datatransfer.SystemFlavorMap;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.peer.DragSourceContextPeer;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.EventListener;
+/**
+ * @since 1.2
+ */
public class DragSource implements Serializable
{
/**
public static final Cursor DefaultMoveNoDrop = null;
public static final Cursor DefaultLinkNoDrop = null;
+ private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap ();
+
+ private transient DragSourceListener dragSourceListener;
+ private transient DragSourceMotionListener dragSourceMotionListener;
+
/**
* Initializes the drag source.
*
public FlavorMap getFlavorMap()
{
- return null;
+ return flavorMap;
}
public DragGestureRecognizer
createDragGestureRecognizer(Class recognizer, Component c, int actions,
DragGestureListener dgl)
{
- return null;
+ return Toolkit.getDefaultToolkit ()
+ .createDragGestureRecognizer (recognizer, this, c, actions,
+ dgl);
}
public DragGestureRecognizer
createDefaultDragGestureRecognizer(Component c, int actions,
DragGestureListener dgl)
{
- return null;
+ return createDragGestureRecognizer (MouseDragGestureRecognizer.class, c,
+ actions, dgl);
}
+ /**
+ * @since 1.4
+ */
public void addDragSourceListener(DragSourceListener l)
{
+ DnDEventMulticaster.add (dragSourceListener, l);
}
+ /**
+ * @since 1.4
+ */
public void removeDragSourceListener(DragSourceListener l)
{
+ DnDEventMulticaster.remove (dragSourceListener, l);
}
+ /**
+ * @since 1.4
+ */
public DragSourceListener[] getDragSourceListeners()
{
- return null;
+ return (DragSourceListener[]) getListeners (DragSourceListener.class);
}
+ /**
+ * @since 1.4
+ */
public void addDragSourceMotionListener(DragSourceMotionListener l)
{
+ DnDEventMulticaster.add (dragSourceMotionListener, l);
}
+ /**
+ * @since 1.4
+ */
public void removeDragSourceMotionListener(DragSourceMotionListener l)
{
+ DnDEventMulticaster.remove (dragSourceMotionListener, l);
}
- public DragSourceMotionListener[] getDragSourceMotionListeners()
+ /**
+ * @since 1.4
+ */
+ public DragSourceMotionListener[] getDragSourceMotionListeners ()
{
- return null;
+ return (DragSourceMotionListener[]) getListeners
+ (DragSourceMotionListener.class);
}
- public EventListener[] getListeners(Class type)
+ /**
+ * @since 1.4
+ */
+ public EventListener[] getListeners (Class listenerType)
{
- return null;
+ if (listenerType == DragSourceListener.class)
+ return DnDEventMulticaster.getListeners (dragSourceListener,
+ listenerType);
+
+ if (listenerType == DragSourceMotionListener.class)
+ return DnDEventMulticaster.getListeners (dragSourceMotionListener,
+ listenerType);
+
+ // Return an empty EventListener array.
+ return new EventListener [0];
}
} // class DragSource
import java.awt.Point;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.peer.DragSourceContextPeer;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.TooManyListenersException;
+/**
+ * @since 1.2
+ */
public class DragSourceContext
implements DragSourceListener, DragSourceMotionListener, Serializable
{
+ /**
+ * Compatible with JDK 1.2+
+ */
static final long serialVersionUID = -115407898692194719L;
protected static final int DEFAULT = 0;
protected static final int OVER = 2;
protected static final int CHANGED = 3;
- public DragSourceContext(DragSourceContextPeer peer, DragGestureEvent dge,
- Cursor cursor, Image image, Point offset,
- Transferable trans, DragSourceListener dsl)
- {
+ private DragSourceContextPeer peer;
+ private Cursor cursor;
+ private Transferable transferable;
+ private DragGestureEvent trigger;
+ private DragSourceListener dragSourceListener;
+ private boolean useCustomCursor; // FIXME: currently unused but needed for serialization.
+ private int sourceActions; // FIXME: currently unused but needed for serialization.
+ private Image image;
+ private Point offset;
+
+ /**
+ * Initializes a drag source context.
+ *
+ * @exception IllegalArgumentException If Component or DragSource of trigger
+ * are null, the drag action for the trigger event is DnDConstants.ACTION_NONE
+ * or if the source actions for the DragGestureRecognizer associated with the
+ * trigger event are equal to DnDConstants.ACTION_NONE.
+ * @exception NullPointerException If peer or trigger is null.
+ */
+ public DragSourceContext (DragSourceContextPeer peer,
+ DragGestureEvent trigger, Cursor cursor,
+ Image image, Point offset, Transferable trans,
+ DragSourceListener dsl)
+ {
+ if (peer == null
+ || trigger == null)
+ throw new NullPointerException ();
+
+ if (trigger.getComponent () == null
+ || trigger.getDragSource () == null
+ || trigger.getDragAction () == DnDConstants.ACTION_NONE
+ || trigger.getSourceAsDragGestureRecognizer ()
+ .getSourceActions () == DnDConstants.ACTION_NONE)
+ throw new IllegalArgumentException ();
+
+ this.peer = peer;
+ this.trigger = trigger;
+ this.cursor = cursor;
+ this.image = image;
+ this.offset = offset;
+ this.transferable = trans;
+ this.dragSourceListener = dsl;
+
+ throw new Error ("not implemented");
}
public DragSource getDragSource()
{
- return null;
+ return trigger.getDragSource ();
}
public Component getComponent()
{
- return null;
+ return trigger.getComponent ();
}
public DragGestureEvent getTrigger()
{
- return null;
+ return trigger;
}
public int getSourceActions()
{
- return 0;
+ return trigger.getSourceAsDragGestureRecognizer ().getSourceActions ();
}
- public void setCursor(Cursor c)
+ public void setCursor (Cursor cursor)
{
+ this.cursor = cursor;
+ // FIXME: Check if we need to do more here
}
public Cursor getCursor()
{
- return null;
+ return cursor;
}
/**
public void addDragSourceListener (DragSourceListener dsl)
throws TooManyListenersException
{
+ if (dragSourceListener != null)
+ throw new TooManyListenersException ();
+
+ dragSourceListener = dsl;
}
- public void removeDragSourceListener(DragSourceListener l)
+ public void removeDragSourceListener (DragSourceListener dsl)
{
+ if (dragSourceListener == dsl)
+ dragSourceListener = null;
}
public void transferablesFlavorsChanged()
public Transferable getTransferable()
{
- return null;
+ return transferable;
}
protected void updateCurrentCursor(int dropOp, int targetAct, int status)
import java.awt.Point;
import java.awt.Component;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
import java.awt.datatransfer.FlavorMap;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.EventListener;
import java.util.TooManyListenersException;
-/** STUB CLASS ONLY */
+/**
+ * @author Michael Koch
+ * @since 1.2
+ */
public class DropTarget
implements DropTargetListener, EventListener, Serializable
{
protected static class DropTargetAutoScroller
implements ActionListener
{
+ private Component component;
+ private Point point;
+
protected DropTargetAutoScroller (Component c, Point p)
{
+ component = c;
+ point = p;
}
protected void updateLocation (Point newLocn)
{
+ point = newLocn;
}
protected void stop ()
{
}
}
-
- // FIXME: check the correctness of default value.
- private boolean isActive = false;
+
+ private Component component;
+ private FlavorMap flavorMap;
+ private int actions;
+ private DropTargetContext dropTargetContext;
+ private DropTargetListener dropTargetListener;
+ private boolean active = true;
/**
* Creates a <code>DropTarget</code> object.
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
FlavorMap fm)
{
+ if (GraphicsEnvironment.isHeadless ())
+ throw new HeadlessException ();
+
+ component = c;
+ actions = i;
+ dropTargetListener = dtl;
+ flavorMap = fm;
+
+ setActive (b);
}
/**
*/
public void setComponent (Component c)
{
+ component = c;
}
/**
*/
public Component getComponent ()
{
- return null;
+ return component;
}
/**
*/
public void setDefaultActions (int ops)
{
+ actions = ops;
}
/**
*/
public int getDefaultActions ()
{
- return 0;
+ return actions;
}
- public void setActive(boolean isActive)
+ public void setActive (boolean active)
{
- this.isActive = isActive;
+ this.active = active;
}
public boolean isActive()
{
- return this.isActive;
+ return active;
}
/**
public void addDropTargetListener (DropTargetListener dtl)
throws TooManyListenersException
{
+ if (dtl != null)
+ throw new TooManyListenersException ();
+
+ dropTargetListener = dtl;
}
public void removeDropTargetListener(DropTargetListener dtl)
{
+ // FIXME: Do we need to do something with dtl ?
+ dropTargetListener = null;
}
public void dragEnter(DropTargetDragEvent dtde)
public FlavorMap getFlavorMap()
{
- return null;
+ return flavorMap;
}
public void setFlavorMap(FlavorMap fm)
{
+ flavorMap = fm;
}
public void addNotify(java.awt.peer.ComponentPeer peer)
public DropTargetContext getDropTargetContext()
{
- return null;
+ if (dropTargetContext == null)
+ dropTargetContext = createDropTargetContext ();
+
+ return dropTargetContext;
}
protected DropTargetContext createDropTargetContext()
{
- return null;
+ return new DropTargetContext (this);
}
protected DropTarget.DropTargetAutoScroller createDropTargetAutoScroller
(Component c, Point p)
{
- return null;
+ return new DropTarget.DropTargetAutoScroller (c, p);
}
protected void initializeAutoscrolling(Point p)
public DataFlavor[] getTransferDataFlavors ()
{
- // FIXME: implement this
- return null;
+ return transferable.getTransferDataFlavors ();
}
public boolean isDataFlavorSupported (DataFlavor flavor)
{
- // FIXME: implement this
- return false;
+ return transferable.isDataFlavorSupported (flavor);
}
public Object getTransferData (DataFlavor flavor)
throws UnsupportedFlavorException, IOException
{
- // FIXME: implement this
- return null;
+ return transferable.getTransferData (flavor);
}
}
+ private DropTarget dropTarget;
private int targetActions;
+ private java.awt.dnd.peer.DropTargetContextPeer dtcp;
+
+ // package private
+ DropTargetContext (DropTarget dropTarget)
+ {
+ this.dropTarget = dropTarget;
+ }
public DropTarget getDropTarget ()
{
- // FIXME: implement this
- return null;
+ return dropTarget;
}
public Component getComponent ()
{
- // FIXME: implement this
- return null;
+ return dropTarget.getComponent ();
}
public void addNotify (java.awt.dnd.peer.DropTargetContextPeer dtcp)
{
- // FIXME: implement this
+ this.dtcp = dtcp;
}
public void removeNotify ()
{
- // FIXME: implement this
+ this.dtcp = null;
}
protected void setTargetActions (int actions)
protected List getCurrentDataFlavorsAsList ()
{
- // FIXME: implement this
- return null;
+ return Arrays.asList (getCurrentDataFlavors ());
}
protected boolean isDataFlavorSupported (DataFlavor flavor)
{
- // FIXME: implement this
- return false;
+ return getCurrentDataFlavorsAsList ().contains (flavor);
}
/**
protected void registerListeners ()
{
- // FIXME: implement this
+ component.addMouseListener (this);
+ component.addMouseMotionListener (this);
}
protected void unregisterListeners ()
{
- // FIXME: implement this
+ component.removeMouseListener (this);
+ component.removeMouseMotionListener (this);
}
public void mouseClicked (MouseEvent e)