This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[PATCH] java.awt.dnd
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Sat, 15 Feb 2003 16:27:44 +0100
- Subject: [PATCH] java.awt.dnd
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
Here another java.awt patch for review. It fixes some glitches in
java.awt.dnd. Please review and comment.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+TlxwWSOgCCdjSDsRAu0PAJ40FMavVsoZnrLi+Tik2SV72i8CCACfV4mk
KQJwvrR8uJQTWZkZX1JmFyo=
=ZW8q
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1708
diff -u -r1.1708 ChangeLog
--- ChangeLog 15 Feb 2003 13:26:26 -0000 1.1708
+++ ChangeLog 15 Feb 2003 15:22:46 -0000
@@ -1,5 +1,60 @@
2003-02-15 Michael Koch <konqueror@gmx.de>
+ * java/awt/dnd/DragSourceContext.java
+ (addDragSourceListener): Added documentation.
+ * java/awt/dnd/DragSourceDragEvent.java
+ (serialVersionUID): New member variable.
+ (getDropAction): Reformated.
+ * java/awt/dnd/DragSourceDropEvent.java
+ (serialVersionUID): New member variable.
+ (dropSuccess): Renamed from success for serialization issues.
+ * java/awt/dnd/DragSourceEvent.java
+ (serialVersionUID): New member variable.
+ * java/awt/dnd/DropTarget.java
+ (serialVersionUID): New member variable.
+ (DropTarget): Implemented, documentation reworked.
+ (setComponent): Documentation added.
+ (getComponent): Documentation added.
+ (setDefaultActions): Documentation added.
+ (getDefaultActions): Documentation added.
+ (addDropTargetListener): Documentation added.
+ * java/awt/dnd/DropTargetContext.java
+ (DropTargetContext): Documentation added.
+ (TransferableProxy.TransferableProxy): New method.
+ (dropComplete): Fixed documentation.
+ (getTransferable): Fixed documentation.
+ (createTransferableProxy): Implemented.
+ * java/awt/dnd/DropTargetDragEvent.java
+ (DropTargetDragEvent): Documentation added.
+ (serialVersionUID): New member variable.
+ (DropTargetDragEvent): Throw exceptions, documentation added.
+ (acceptDrag): Implemented.
+ (getCurrentDataFlavors): Implemented.3yy
+ (getCurrentDataFlavorsAsList): Implemented.
+ (isDataFlavorSupported): Implemented.
+ (rejectDrag): Implemented.
+ * java/awt/dnd/DropTargetDropEvent.java
+ (DropTargetDropEvent): Documentation added.
+ (serialVersionUID): New member variable.
+ (actions): Renamed from srcActions for serialization issues.
+ (isLocalTx): Renamed from isLocalTx for serialization issues.
+ (DropTargetDropEvent): New implementation, throw exceptions,
+ documentation added.
+ (getCurrentDataFlavors): Implemented.
+ (getCurrentDataFlavorsAsList): Implemented.
+ (isDataFlavorSupported): Implemented.
+ (getSourceActions): Implemented.
+ (getDropAction): Implemented.
+ (getTransferable): Implemented.
+ (acceptDrop): Implemented.
+ (rejectDrop): Implemented.
+ * java/awt/dnd/DropTargetListener.java
+ (drop): Fixed documentation.
+ * java/awt/dnd/MouseDragGestureRecognizer.java
+ (MouseDragGestureRecognizer): Documentation added.
+
+2003-02-15 Michael Koch <konqueror@gmx.de>
+
* java/awt/datatransfer/DataFlavor.java
(isRepresentationClassByteBuffer): Removed try-catch block.
(isRepresentationClassCharBuffer): Removed try-catch block.
Index: java/awt/dnd/DragSourceContext.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DragSourceContext.java,v
retrieving revision 1.3
diff -u -r1.3 DragSourceContext.java
--- java/awt/dnd/DragSourceContext.java 10 Nov 2002 00:16:43 -0000 1.3
+++ java/awt/dnd/DragSourceContext.java 15 Feb 2003 15:22:46 -0000
@@ -92,7 +92,13 @@
return null;
}
- public void addDragSourceListener(DragSourceListener l)
+ /**
+ * Adds a <code>DragSourceListener</code>.
+ *
+ * @exception TooManyListenersException If a <code>DragSourceListener</code>
+ * has already been added.
+ */
+ public void addDragSourceListener (DragSourceListener dsl)
throws TooManyListenersException
{
}
Index: java/awt/dnd/DragSourceDragEvent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DragSourceDragEvent.java,v
retrieving revision 1.1
diff -u -r1.1 DragSourceDragEvent.java
--- java/awt/dnd/DragSourceDragEvent.java 9 Aug 2002 04:26:15 -0000 1.1
+++ java/awt/dnd/DragSourceDragEvent.java 15 Feb 2003 15:22:46 -0000
@@ -41,10 +41,16 @@
import gnu.java.awt.EventModifier;
/**
- * STUBBED
+ * @author Michael Koch
+ * @since 1.2
*/
public class DragSourceDragEvent extends DragSourceEvent
{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = 481346297933902471L;
+
private final int dropAction;
private final int targetActions;
private final int gestureModifiers;
@@ -89,7 +95,8 @@
public int getDropAction()
{
- return dropAction & targetActions
- & ((DragSourceContext) source).getSourceActions();
+ return (dropAction
+ & targetActions
+ & ((DragSourceContext) source).getSourceActions());
}
} // class DragSourceDragEvent
Index: java/awt/dnd/DragSourceDropEvent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DragSourceDropEvent.java,v
retrieving revision 1.1
diff -u -r1.1 DragSourceDropEvent.java
--- java/awt/dnd/DragSourceDropEvent.java 3 Oct 2002 14:40:43 -0000 1.1
+++ java/awt/dnd/DragSourceDropEvent.java 15 Feb 2003 15:22:46 -0000
@@ -46,30 +46,35 @@
*/
public class DragSourceDropEvent extends DragSourceEvent
{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = -5571321229470821891L;
+
private final int dropAction;
- private final boolean success;
+ private final boolean dropSuccess;
public DragSourceDropEvent (DragSourceContext context)
{
super (context);
this.dropAction = 0;
- this.success = false;
+ this.dropSuccess = false;
}
public DragSourceDropEvent (DragSourceContext context, int dropAction,
- boolean success)
+ boolean dropSuccess)
{
super (context);
this.dropAction = dropAction;
- this.success = success;
+ this.dropSuccess = dropSuccess;
}
public DragSourceDropEvent (DragSourceContext context, int dropAction,
- boolean success, int x, int y)
+ boolean dropSuccess, int x, int y)
{
super (context, x, y);
this.dropAction = dropAction;
- this.success = success;
+ this.dropSuccess = dropSuccess;
}
public int getDropAction()
@@ -79,6 +84,6 @@
public boolean getDropSuccess()
{
- return success;
+ return dropSuccess;
}
} // class DragSourceDropEvent
Index: java/awt/dnd/DragSourceEvent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DragSourceEvent.java,v
retrieving revision 1.1
diff -u -r1.1 DragSourceEvent.java
--- java/awt/dnd/DragSourceEvent.java 9 Aug 2002 04:26:15 -0000 1.1
+++ java/awt/dnd/DragSourceEvent.java 15 Feb 2003 15:22:46 -0000
@@ -41,8 +41,16 @@
import java.awt.Point;
import java.util.EventObject;
+/**
+ * @since 1.2
+ */
public class DragSourceEvent extends EventObject
{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = -763287114604032641L;
+
private final boolean locationSpecified;
private final int x;
private final int y;
Index: java/awt/dnd/DropTarget.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DropTarget.java,v
retrieving revision 1.4
diff -u -r1.4 DropTarget.java
--- java/awt/dnd/DropTarget.java 2 Jan 2003 00:14:23 -0000 1.4
+++ java/awt/dnd/DropTarget.java 15 Feb 2003 15:22:46 -0000
@@ -50,6 +50,11 @@
public class DropTarget
implements DropTargetListener, EventListener, Serializable
{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = -6283860791671019047L;
+
protected static class DropTargetAutoScroller
implements ActionListener
{
@@ -74,64 +79,85 @@
private boolean isActive = false;
/**
- * FIXME
+ * Creates a <code>DropTarget</code> object.
*
- * @exception HeadlessException FIXME
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
*/
public DropTarget ()
{
+ this (null, 0, null, true, null);
}
/**
- * FIXME
+ * Creates a <code>DropTarget</code> object.
*
- * @exception HeadlessException FIXME
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
*/
public DropTarget (Component c, DropTargetListener dtl)
{
+ this (c, 0, dtl, true, null);
}
/**
- * FIXME
+ * Creates a <code>DropTarget</code> object.
*
- * @exception HeadlessException FIXME
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
*/
public DropTarget (Component c, int i, DropTargetListener dtl)
{
+ this (c, i, dtl, true, null);
}
/**
- * FIXME
+ * Creates a <code>DropTarget</code> object.
*
- * @exception HeadlessException FIXME
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
*/
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b)
{
+ this (c, i, dtl, b, null);
}
/**
- * FIXME
+ * Creates a <code>DropTarget</code> object.
*
- * @exception HeadlessException FIXME
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
*/
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
- FlavorMap fm)
+ FlavorMap fm)
{
}
+ /**
+ * Sets the component assoziated with this dro ptarget object.
+ */
public void setComponent (Component c)
{
}
+ /**
+ * Returns the component assoziated with this drop target object.
+ */
public Component getComponent ()
{
return null;
}
+ /**
+ * Sets the default actions.
+ */
public void setDefaultActions (int ops)
{
}
+ /**
+ * Returns the default actions.
+ */
public int getDefaultActions ()
{
return 0;
@@ -148,7 +174,10 @@
}
/**
- * @exception TooManyListenersException FIXME
+ * Adds a new <code>DropTargetListener</code>.
+ *
+ * @exception TooManyListenersException If there is already a
+ * <code>DropTargetListener</code>.
*/
public void addDropTargetListener (DropTargetListener dtl)
throws TooManyListenersException
Index: java/awt/dnd/DropTargetContext.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DropTargetContext.java,v
retrieving revision 1.2
diff -u -r1.2 DropTargetContext.java
--- java/awt/dnd/DropTargetContext.java 10 Nov 2002 00:16:43 -0000 1.2
+++ java/awt/dnd/DropTargetContext.java 15 Feb 2003 15:22:46 -0000
@@ -46,6 +46,10 @@
import java.awt.datatransfer.UnsupportedFlavorException;
import java.util.List;
+/**
+ * @author Michael Koch <konqueror@gmx.de>
+ * @since 1.2
+ */
public class DropTargetContext implements Serializable
{
static final long serialVersionUID = -634158968993743371L;
@@ -55,6 +59,12 @@
protected boolean isLocal;
protected Transferable transferable;
+ TransferableProxy (Transferable t, boolean local)
+ {
+ this.transferable = t;
+ this.isLocal = local;
+ }
+
public DataFlavor[] getTransferDataFlavors ()
{
// FIXME: implement this
@@ -110,9 +120,9 @@
}
/**
- * FIXME
+ * Signals that the drop is completed.
*
- * @exception InvalidDnDOperationException FIXME
+ * @exception InvalidDnDOperationException If a drop is not outstanding.
*/
public void dropComplete (boolean success)
{
@@ -158,9 +168,9 @@
}
/**
- * FIXME
+ * Return the <code>Transferable</code> operandof this operation.
*
- * @exception InvalidDnDOperationException FIXME
+ * @exception InvalidDnDOperationException If a drag is not outstanding.
*/
protected Transferable getTransferable() throws InvalidDnDOperationException
{
@@ -170,7 +180,6 @@
protected Transferable createTransferableProxy(Transferable t, boolean local)
{
- // FIXME: implement this
- return null;
+ return new TransferableProxy (t, local);
}
} // class DropTargetContext
Index: java/awt/dnd/DropTargetDragEvent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DropTargetDragEvent.java,v
retrieving revision 1.1
diff -u -r1.1 DropTargetDragEvent.java
--- java/awt/dnd/DropTargetDragEvent.java 3 Oct 2002 14:40:43 -0000 1.1
+++ java/awt/dnd/DropTargetDragEvent.java 15 Feb 2003 15:22:46 -0000
@@ -41,21 +41,56 @@
import java.awt.Point;
import java.awt.datatransfer.DataFlavor;
+/**
+ * @since 1.2
+ */
public class DropTargetDragEvent extends DropTargetEvent
{
+ /**
+ * Compatible with 1.2+
+ */
+ private static final long serialVersionUID = -8422265619058953682L;
+
private final int dropAction;
private final int srcActions;
private final Point location;
/**
- * FIXME
+ * Initializes a <code>DropTargetDragEvent</code>.
*
- * @exception NullPointerException FIXME
+ * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
+ * srcActions is not a bitwise mask of DnDConstants, or dtc is null.
+ * @exception NullPointerException If location is null.
*/
public DropTargetDragEvent (DropTargetContext context, Point location,
int dropAction, int srcActions)
{
super (context);
+
+ if (location == null)
+ throw new NullPointerException ();
+
+ if (context == null)
+ throw new IllegalArgumentException ();
+
+ if (dropAction != DnDConstants.ACTION_NONE
+ && dropAction != DnDConstants.ACTION_COPY
+ && dropAction != DnDConstants.ACTION_MOVE
+ && dropAction != DnDConstants.ACTION_COPY_OR_MOVE
+ && dropAction != DnDConstants.ACTION_LINK
+ && dropAction != DnDConstants.ACTION_REFERENCE)
+ throw new IllegalArgumentException ();
+
+ int srcActionsMask = DnDConstants.ACTION_NONE
+ | DnDConstants.ACTION_COPY
+ | DnDConstants.ACTION_MOVE
+ | DnDConstants.ACTION_COPY_OR_MOVE
+ | DnDConstants.ACTION_LINK
+ | DnDConstants.ACTION_REFERENCE;
+
+ if (~(srcActions ^ srcActionsMask) != 0)
+ throw new IllegalArgumentException ();
+
this.dropAction = dropAction;
this.srcActions = srcActions;
this.location = location;
@@ -63,19 +98,17 @@
public void acceptDrag (int dragOperation)
{
- // FIXME: implement this
+ context.acceptDrag (dragOperation);
}
public DataFlavor[] getCurrentDataFlavors ()
{
- // FIXME: implement this
- return null;
+ return context.getCurrentDataFlavors ();
}
public List getCurrentDataFlavorsAsList ()
{
- // FIXME: implement this
- return null;
+ return context.getCurrentDataFlavorsAsList ();
}
public int getDropAction()
@@ -96,12 +129,11 @@
public boolean isDataFlavorSupported (DataFlavor df)
{
- // FIXME: implement this
- return true;
+ return context.isDataFlavorSupported (df);
}
public void rejectDrag ()
{
- // FIXME: implement this
+ context.rejectDrag ();
}
} // class DropTargetDragEvent
Index: java/awt/dnd/DropTargetDropEvent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DropTargetDropEvent.java,v
retrieving revision 1.1
diff -u -r1.1 DropTargetDropEvent.java
--- java/awt/dnd/DropTargetDropEvent.java 3 Oct 2002 14:40:43 -0000 1.1
+++ java/awt/dnd/DropTargetDropEvent.java 15 Feb 2003 15:22:46 -0000
@@ -42,31 +42,75 @@
import java.awt.datatransfer.Transferable;
import java.util.List;
+/**
+ * @since 1.2
+ */
public class DropTargetDropEvent extends DropTargetEvent
{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = -1721911170440459322L;
+
private final int dropAction;
- private final int srcActions;
+ private final int actions;
private final Point location;
- private final boolean isLocal;
+ private final boolean isLocalTx;
+ /**
+ * Initializes a <code>DropTargetDropEvent</code>. By default this constructor
+ * assumes that the target is not int same JVM.
+ *
+ * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
+ * actions is not a bitwise mask of DnDConstants, or dtc is null.
+ * @exception NullPointerException If location is null.
+ */
public DropTargetDropEvent (DropTargetContext dtc, Point location,
- int dropAction, int srcActions)
+ int dropAction, int actions)
{
- super (dtc);
- this.dropAction = dropAction;
- this.srcActions = srcActions;
- this.location = location;
- this.isLocal = false;
+ this (dtc, location, dropAction, actions, false);
}
+ /**
+ * Initializes a <code>DropTargetDropEvent</code>.
+ *
+ * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
+ * actions is not a bitwise mask of DnDConstants, or dtc is null.
+ * @exception NullPointerException If location is null.
+ */
public DropTargetDropEvent (DropTargetContext dtc, Point location,
- int dropAction, int srcActions, boolean isLocal)
+ int dropAction, int actions, boolean isLocalTx)
{
super (dtc);
+
+ if (location == null)
+ throw new NullPointerException ();
+
+ if (dtc == null)
+ throw new IllegalArgumentException ();
+
+ if (dropAction != DnDConstants.ACTION_NONE
+ && dropAction != DnDConstants.ACTION_COPY
+ && dropAction != DnDConstants.ACTION_MOVE
+ && dropAction != DnDConstants.ACTION_COPY_OR_MOVE
+ && dropAction != DnDConstants.ACTION_LINK
+ && dropAction != DnDConstants.ACTION_REFERENCE)
+ throw new IllegalArgumentException ();
+
+ int actionsMask = DnDConstants.ACTION_NONE
+ | DnDConstants.ACTION_COPY
+ | DnDConstants.ACTION_MOVE
+ | DnDConstants.ACTION_COPY_OR_MOVE
+ | DnDConstants.ACTION_LINK
+ | DnDConstants.ACTION_REFERENCE;
+
+ if (~(actions ^ actionsMask) != 0)
+ throw new IllegalArgumentException ();
+
this.dropAction = dropAction;
- this.srcActions = srcActions;
+ this.actions = actions;
this.location = location;
- this.isLocal = isLocal;
+ this.isLocalTx = isLocalTx;
}
public Point getLocation ()
@@ -76,48 +120,42 @@
public DataFlavor[] getCurrentDataFlavors ()
{
- // FIXME: implement this
- return null;
+ return context.getCurrentDataFlavors ();
}
public List getCurrentDataFlavorsAsList ()
{
- // FIXME: implement this
- return null;
+ return context.getCurrentDataFlavorsAsList ();
}
public boolean isDataFlavorSupported (DataFlavor flavor)
{
- // FIXME: implement this
- return false;
+ return context.isDataFlavorSupported (flavor);
}
public int getSourceActions ()
{
- // FIXME: implement this
- return 0;
+ return actions;
}
public int getDropAction ()
{
- // FIXME: implement this
- return 0;
+ return dropAction;
}
public Transferable getTransferable ()
{
- // FIXME: implement this
- return null;
+ return context.getTransferable ();
}
public void acceptDrop (int dropAction)
{
- // FIXME: implement this
+ context.acceptDrop (dropAction);
}
public void rejectDrop ()
{
- // FIXME: implement this
+ context.rejectDrop ();
}
public void dropComplete (boolean success)
@@ -127,6 +165,6 @@
public boolean isLocalTransfer()
{
- return isLocal;
+ return isLocalTx;
}
} // class DropTargetDropEvent
Index: java/awt/dnd/DropTargetListener.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/DropTargetListener.java,v
retrieving revision 1.1
diff -u -r1.1 DropTargetListener.java
--- java/awt/dnd/DropTargetListener.java 3 Oct 2002 14:40:43 -0000 1.1
+++ java/awt/dnd/DropTargetListener.java 15 Feb 2003 15:22:46 -0000
@@ -81,7 +81,7 @@
void dragExit (DropTargetEvent e);
/**
- * FIXME
+ * Called when the drag operation has terminated with a drop.
*
* @param e the drag source drag event
*/
Index: java/awt/dnd/MouseDragGestureRecognizer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/dnd/MouseDragGestureRecognizer.java,v
retrieving revision 1.1
diff -u -r1.1 MouseDragGestureRecognizer.java
--- java/awt/dnd/MouseDragGestureRecognizer.java 3 Oct 2002 14:40:43 -0000 1.1
+++ java/awt/dnd/MouseDragGestureRecognizer.java 15 Feb 2003 15:22:46 -0000
@@ -45,27 +45,38 @@
/**
* @author Michael Koch <konqueror@gmx.de>
*/
-
public abstract class MouseDragGestureRecognizer
extends DragGestureRecognizer
implements MouseListener, MouseMotionListener
{
+ /**
+ * Creates a <code>MouseDragGestureRecognizer</code> object.
+ */
protected MouseDragGestureRecognizer (DragSource ds, Component c, int act,
DragGestureListener dgl)
{
super (ds, c, act, dgl);
}
+ /**
+ * Creates a <code>MouseDragGestureRecognizer</code> object.
+ */
protected MouseDragGestureRecognizer (DragSource ds, Component c, int act)
{
super (ds, c, act);
}
+ /**
+ * Creates a <code>MouseDragGestureRecognizer</code> object.
+ */
protected MouseDragGestureRecognizer (DragSource ds, Component c)
{
super (ds, c);
}
+ /**
+ * Creates a <code>MouseDragGestureRecognizer</code> object.
+ */
protected MouseDragGestureRecognizer (DragSource ds)
{
super (ds);