Hi,

We have a large part of the drag and drop infrastructure, but no Toolkit
that actually supports it. That confuses applications a bit. This patch
adds "no-support" for drag and drop when the Toolkit doesn't support it
so applications can at least try to create a DragSource for their ui (it
just won't work).

2006-02-18  Mark Wielaard  <[EMAIL PROTECTED]>

    * java/awt/dnd/DragSource.java (getDefaultDragSource): Return new
    DragSource.
    (NoDragGestureRecognizer): New static class.
    (createDragGestureRecognizer): Return NoDragGestureRecognizer when
    Toolkit doesn't support drag and drop.

Committed,

Mark
Index: java/awt/dnd/DragSource.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/dnd/DragSource.java,v
retrieving revision 1.5
diff -u -r1.5 DragSource.java
--- java/awt/dnd/DragSource.java	2 Jul 2005 20:32:26 -0000	1.5
+++ java/awt/dnd/DragSource.java	18 Feb 2006 15:19:08 -0000
@@ -90,7 +90,7 @@
    */
   public static DragSource getDefaultDragSource()
   {
-    return null;
+    return new DragSource();
   }
 
   public static boolean isDragImageSupported()
@@ -172,13 +172,34 @@
     return flavorMap;
   }
 
+  /**
+   * Dummy DragGestureRecognizer when Toolkit doesn't support drag and drop.
+   */
+  static class NoDragGestureRecognizer extends DragGestureRecognizer
+  {
+    NoDragGestureRecognizer(DragSource ds, Component c, int actions,
+                            DragGestureListener dgl)
+    {
+      super(ds, c, actions, dgl);
+    }
+
+    protected void registerListeners() { }
+    protected void unregisterListeners() { }
+  }
+
   public DragGestureRecognizer
     createDragGestureRecognizer(Class recognizer, Component c, int actions,
                                 DragGestureListener dgl)
   {
-    return Toolkit.getDefaultToolkit ()
+    DragGestureRecognizer dgr;
+    dgr = Toolkit.getDefaultToolkit ()
                   .createDragGestureRecognizer (recognizer, this, c, actions,
                                                 dgl);
+
+    if (dgr == null)
+      dgr = new NoDragGestureRecognizer(this, c, actions, dgl);
+
+    return dgr;
   }
 
   public DragGestureRecognizer

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to