]> source.dussan.org Git - vaadin-framework.git/commitdiff
#8234 Split test drag source and drop target into paintable + widget
authorArtur Signell <artur@vaadin.com>
Tue, 31 Jan 2012 12:13:56 +0000 (14:13 +0200)
committerArtur Signell <artur@vaadin.com>
Tue, 31 Jan 2012 13:09:31 +0000 (15:09 +0200)
tests/testbench/com/vaadin/tests/dd/CustomDDImplementation.java
tests/testbench/com/vaadin/tests/dd/VMyDragSource.java
tests/testbench/com/vaadin/tests/dd/VMyDragSourcePaintable.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/dd/VMyDropTarget.java
tests/testbench/com/vaadin/tests/dd/VMyDropTargetPaintable.java [new file with mode: 0644]

index c789ead11326a27fb57a45b4382924ee4610a003..de3312d1a8b069755818f0525d9ee5bfe5a3c11d 100644 (file)
@@ -38,7 +38,7 @@ public class CustomDDImplementation extends CustomComponent {
      * Check the @ClientWidget
      * 
      */
-    @ClientWidget(VMyDropTarget.class)
+    @ClientWidget(VMyDropTargetPaintable.class)
     class MyDropTarget extends AbstractComponent implements DropTarget {
         public DropHandler getDropHandler() {
             return new DropHandler() {
@@ -76,7 +76,7 @@ public class CustomDDImplementation extends CustomComponent {
      * operations that are controlled via server side api.
      * 
      */
-    @ClientWidget(VMyDragSource.class)
+    @ClientWidget(VMyDragSourcePaintable.class)
     public class MyDragSource extends AbstractComponent implements Component {
 
     }
index eb77bfefd7956e440055ac9f77f2583c753fef62..7e91d2b9aacac3d9258858eb5f5e02ec9668b438 100644 (file)
@@ -11,23 +11,19 @@ import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
-import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
 import com.vaadin.terminal.gwt.client.ui.dd.VTransferable;
 
 /**
  * Example code to implement Component that has something to drag.
  */
-public class VMyDragSource extends Composite implements VPaintableWidget,
-        MouseDownHandler, MouseMoveHandler, MouseOutHandler {
+public class VMyDragSource extends Composite implements MouseDownHandler,
+        MouseMoveHandler, MouseOutHandler {
 
     private boolean mouseDown;
     private MouseDownEvent mDownEvent;
-    @SuppressWarnings("unused")
-    private ApplicationConnection client;
 
+    @SuppressWarnings("unused")
     public VMyDragSource() {
         FlowPanel fp = new FlowPanel();
         initWidget(fp);
@@ -42,13 +38,6 @@ public class VMyDragSource extends Composite implements VPaintableWidget,
 
     }
 
-    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-        if (client.updateComponent(this, uidl, true)) {
-            return;
-        }
-        this.client = client;
-    }
-
     /*
      * Below a sophisticated drag start implementation. Drag event is started if
      * mouse is moved 5 pixels with left mouse key down.
diff --git a/tests/testbench/com/vaadin/tests/dd/VMyDragSourcePaintable.java b/tests/testbench/com/vaadin/tests/dd/VMyDragSourcePaintable.java
new file mode 100644 (file)
index 0000000..976638f
--- /dev/null
@@ -0,0 +1,22 @@
+package com.vaadin.tests.dd;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;\r
+\r
+public class VMyDragSourcePaintable extends VAbstractPaintableWidget {\r
+\r
+    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+        if (client.updateComponent(this, uidl, true)) {\r
+            return;\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected Widget createWidget() {\r
+        return GWT.create(VMyDragSource.class);\r
+    }\r
+\r
+}\r
index 8efec186cb41203d7ca11c0cd2d62119b805a756..81bbb09a5c663afdba554e5edd2dab6e1cf06d91 100644 (file)
@@ -1,18 +1,16 @@
 package com.vaadin.tests.dd;
 
 import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.VPaintableWidget;
-import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.ui.dd.VDragEvent;
 import com.vaadin.terminal.gwt.client.ui.dd.VDropHandler;
 import com.vaadin.terminal.gwt.client.ui.dd.VHasDropHandler;
 
 public class VMyDropTarget extends Composite implements VHasDropHandler,
-        VDropHandler, VPaintableWidget {
+        VDropHandler {
 
-    private ApplicationConnection client;
+    ApplicationConnection client;
 
     public void dragEnter(VDragEvent drag) {
     }
@@ -31,27 +29,18 @@ public class VMyDropTarget extends Composite implements VHasDropHandler,
         return false;
     }
 
-    public VPaintableWidget getPaintable() {
-        // Drophandler implemented by Paintable itself
+    public VDropHandler getDropHandler() {
+        // Drophandler implemented by widget itself
         return this;
     }
 
-    public VDropHandler getDropHandler() {
-        // Drophandler implemented by Paintable itself
-        return this;
+    public VPaintableWidget getPaintable() {
+        // TODO Auto-generated method stub
+        return null;
     }
 
     public ApplicationConnection getApplicationConnection() {
         return client;
     }
 
-    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-        this.client = client;
-
-    }
-
-    public Widget getWidgetForPaintable() {
-        return this;
-    }
-
 }
diff --git a/tests/testbench/com/vaadin/tests/dd/VMyDropTargetPaintable.java b/tests/testbench/com/vaadin/tests/dd/VMyDropTargetPaintable.java
new file mode 100644 (file)
index 0000000..88455c4
--- /dev/null
@@ -0,0 +1,28 @@
+package com.vaadin.tests.dd;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;\r
+\r
+public class VMyDropTargetPaintable extends VAbstractPaintableWidget {\r
+\r
+    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+        if (client.updateComponent(this, uidl, true)) {\r
+            return;\r
+        }\r
+        getWidgetForPaintable().client = client;\r
+    }\r
+\r
+    @Override\r
+    public VMyDropTarget getWidgetForPaintable() {\r
+        return (VMyDropTarget) super.getWidgetForPaintable();\r
+    }\r
+\r
+    @Override\r
+    protected Widget createWidget() {\r
+        return GWT.create(VMyDropTarget.class);\r
+    }\r
+\r
+}\r