summaryrefslogtreecommitdiffstats
path: root/libjava/java/awt/dnd/DragSourceContext.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/awt/dnd/DragSourceContext.java')
-rw-r--r--libjava/java/awt/dnd/DragSourceContext.java81
1 files changed, 69 insertions, 12 deletions
diff --git a/libjava/java/awt/dnd/DragSourceContext.java b/libjava/java/awt/dnd/DragSourceContext.java
index 45191d24365..1760cd02065 100644
--- a/libjava/java/awt/dnd/DragSourceContext.java
+++ b/libjava/java/awt/dnd/DragSourceContext.java
@@ -44,12 +44,21 @@ import java.awt.Image;
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;
@@ -57,39 +66,81 @@ public class DragSourceContext
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;
}
/**
@@ -101,10 +152,16 @@ public class DragSourceContext
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()
@@ -137,7 +194,7 @@ public class DragSourceContext
public Transferable getTransferable()
{
- return null;
+ return transferable;
}
protected void updateCurrentCursor(int dropOp, int targetAct, int status)
OpenPOWER on IntegriCloud