]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #4391 + optimization (store only one pending criteria check)
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 23 Mar 2010 13:51:33 +0000 (13:51 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 23 Mar 2010 13:51:33 +0000 (13:51 +0000)
svn changeset:12042/svn branch:6.3

src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
src/com/vaadin/terminal/gwt/client/ui/VTree.java
src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java

index 2ac0f04966cf9f7db0b871a180d01f56c43718cc..4a4164004c8c1f2bb7d0277af05f77ce938828f8 100644 (file)
@@ -3235,9 +3235,15 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             updateDropDetails(drag);
             if (!oldDetails.equals(dropDetails)) {
                 deEmphasis();
+                final TableDDDetails newDetails = dropDetails;
                 VAcceptCallback cb = new VAcceptCallback() {
                     public void accepted(VDragEvent event) {
-                        dragAccepted(event);
+                        if (newDetails.equals(dropDetails)) {
+                            dragAccepted(event);
+                        }
+                        /*
+                         * Else new target slot already defined, ignore
+                         */
                     }
                 };
                 validate(cb, drag);
index 3fc71c0047f2eb312dd9249a5a0aa7e9de0056cb..4fcca723da38a24c01a2b0b3263c2a1a34b0166f 100644 (file)
@@ -162,6 +162,7 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler {
 
         currentMouseOverKey = findCurrentMouseOverKey(drag.getElementOver());
 
+        drag.getDropDetails().put("itemIdOver", currentMouseOverKey);
         if (currentMouseOverKey != null) {
             TreeNode treeNode = keyToNode.get(currentMouseOverKey);
             VerticalDropLocation detail = treeNode.getDropDetail(drag
@@ -171,11 +172,13 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler {
                     && detail == VerticalDropLocation.MIDDLE) {
                 overTreeNode = true;
             }
-            drag.getDropDetails().put("itemIdOver", currentMouseOverKey);
             drag.getDropDetails().put("itemIdOverIsNode", overTreeNode);
             drag.getDropDetails().put("detail", detail);
-
+        } else {
+            drag.getDropDetails().put("itemIdOverIsNode", null);
+            drag.getDropDetails().put("detail", null);
         }
+
     }
 
     private String findCurrentMouseOverKey(Element elementOver) {
@@ -221,13 +224,23 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler {
                             // clear old styles
                             treeNode.emphasis(null);
                         }
-                        validate(new VAcceptCallback() {
-                            public void accepted(VDragEvent event) {
-                                if (newKey != null) {
-                                    keyToNode.get(newKey).emphasis(detail);
+                        if (newKey != null) {
+                            validate(new VAcceptCallback() {
+                                public void accepted(VDragEvent event) {
+                                    VerticalDropLocation curDetail = (VerticalDropLocation) event
+                                            .getDropDetails().get("detail");
+                                    if (curDetail == detail
+                                            && newKey
+                                                    .equals(currentMouseOverKey)) {
+                                        keyToNode.get(newKey).emphasis(detail);
+                                    }
+                                    /* Else drag is already on a different
+                                    * node-detail pair,
+                                    * new criteria check is going on */
                                 }
-                            }
-                        }, currentDrag);
+                            }, currentDrag);
+
+                        }
                     }
 
                 }
index fdb5801a28c7e39c6c401e8ff2b0bacc4b55672e..7fdf2139561c704bd7bb6d27c45f4bec8b367cc8 100644 (file)
@@ -3,8 +3,6 @@
  */
 package com.vaadin.terminal.gwt.client.ui.dd;
 
-import java.util.LinkedList;
-
 import com.google.gwt.dom.client.Element;
 import com.google.gwt.dom.client.NativeEvent;
 import com.google.gwt.dom.client.Node;
@@ -508,6 +506,11 @@ public class VDragAndDropManager {
     }
 
     private void doRequest(DragEventType drop) {
+        if (currentDropHandler == null) {
+            ApplicationConnection.getConsole().log(
+                    "DD request ignored, drop handler is null");
+            return;
+        }
         Paintable paintable = currentDropHandler.getPaintable();
         ApplicationConnection client = currentDropHandler
                 .getApplicationConnection();
@@ -571,8 +574,9 @@ public class VDragAndDropManager {
     }
 
     private void runDeferredCommands() {
-        if (deferredCommands != null && !deferredCommands.isEmpty()) {
-            Command command = deferredCommands.poll();
+        if (deferredCommand != null) {
+            Command command = deferredCommand;
+            deferredCommand = null;
             command.execute();
             if (!isBusy()) {
                 runDeferredCommands();
@@ -622,7 +626,7 @@ public class VDragAndDropManager {
         }
     };
 
-    private LinkedList<Command> deferredCommands;
+    private Command deferredCommand;
 
     private boolean isBusy() {
         return serverCallback != null;
@@ -634,10 +638,7 @@ public class VDragAndDropManager {
      * @param command
      */
     private void defer(Command command) {
-        if (deferredCommands == null) {
-            deferredCommands = new LinkedList<Command>();
-        }
-        deferredCommands.add(command);
+        deferredCommand = command;
     }
 
     /**