]> source.dussan.org Git - vaadin-framework.git/commitdiff
changed the code to be java 1.6 compatible
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 11 Mar 2010 12:52:37 +0000 (12:52 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 11 Mar 2010 12:52:37 +0000 (12:52 +0000)
svn changeset:11784/svn branch:6.3

src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java
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/DDUtil.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/ui/dd/HorizontalDropLocation.java
src/com/vaadin/terminal/gwt/client/ui/dd/VerticalDropLocation.java

index 17bee7f318075f6313d5b877634bd6c3b6787c91..be86089b389c01176b7c110bf4b7fefb1e0a7443 100644 (file)
@@ -19,6 +19,7 @@ import com.vaadin.terminal.gwt.client.RenderInformation;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
 import com.vaadin.terminal.gwt.client.RenderInformation.Size;
+import com.vaadin.terminal.gwt.client.ui.dd.DDUtil;
 import com.vaadin.terminal.gwt.client.ui.dd.HorizontalDropLocation;
 import com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler;
 import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCallback;
@@ -325,12 +326,12 @@ public class VDragAndDropWrapper extends VCustomComponent implements
     }-*/;
 
     public void updateDropDetails(VDragEvent drag) {
-        verticalDropLocation = VerticalDropLocation.get(getElement(), drag
-                .getCurrentGwtEvent().getClientY(), 0.2);
+        verticalDropLocation = DDUtil.getVerticalDropLocation(getElement(),
+                drag.getCurrentGwtEvent().getClientY(), 0.2);
         drag.getDropDetails().put("verticalLocation",
                 verticalDropLocation.toString());
-        horizontalDropLocation = HorizontalDropLocation.get(getElement(), drag
-                .getCurrentGwtEvent().getClientX(), 0.2);
+        horizontalDropLocation = DDUtil.getHorizontalDropLocation(getElement(),
+                drag.getCurrentGwtEvent().getClientX(), 0.2);
         drag.getDropDetails().put("horizontalLocation",
                 horizontalDropLocation.toString());
     }
index b6c22e9a85abf7f515788097cefdf9676a121462..a1c909c7ef91df79e6aab5183ab0cb7cf3cc46ca 100644 (file)
@@ -42,6 +42,7 @@ import com.vaadin.terminal.gwt.client.RenderSpace;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
 import com.vaadin.terminal.gwt.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow;
+import com.vaadin.terminal.gwt.client.ui.dd.DDUtil;
 import com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler;
 import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCallback;
 import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
@@ -3202,7 +3203,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                 int childIndex = DOM.getChildIndex(tr, element);
                 dropDetails.colkey = tHead.getHeaderCell(childIndex)
                         .getColKey();
-                dropDetails.dropLocation = VerticalDropLocation.get(row
+                dropDetails.dropLocation = DDUtil.getVerticalDropLocation(row
                         .getElement(), drag.getCurrentGwtEvent().getClientY(),
                         0.2);
             }
index d78196ed43adab7f12ccbd3afaf665a85808ae1f..b5a1a7013e2de260f91263f791abe657bbdf2e66 100644 (file)
@@ -24,6 +24,7 @@ import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.terminal.gwt.client.Paintable;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
+import com.vaadin.terminal.gwt.client.ui.dd.DDUtil;
 import com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler;
 import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCallback;
 import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
@@ -270,7 +271,7 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler {
         if (treeNode == null) {
             return null;
         }
-        VerticalDropLocation verticalDropLocation = VerticalDropLocation.get(
+        VerticalDropLocation verticalDropLocation = DDUtil.getVerticalDropLocation(
                 treeNode.nodeCaptionDiv, event.getClientY(), 0.2);
         return verticalDropLocation;
     }
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java b/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java
new file mode 100644 (file)
index 0000000..60e81b3
--- /dev/null
@@ -0,0 +1,41 @@
+package com.vaadin.terminal.gwt.client.ui.dd;
+
+import com.google.gwt.user.client.Element;
+
+public class DDUtil {
+
+    public static VerticalDropLocation getVerticalDropLocation(Element element,
+            int clientY, double topBottomRatio) {
+
+        int absoluteTop = element.getAbsoluteTop();
+        int offsetHeight = element.getOffsetHeight();
+        int fromTop = clientY - absoluteTop;
+
+        float percentageFromTop = (fromTop / (float) offsetHeight);
+        if (percentageFromTop < topBottomRatio) {
+            return VerticalDropLocation.TOP;
+        } else if (percentageFromTop > 1 - topBottomRatio) {
+            return VerticalDropLocation.BOTTOM;
+        } else {
+            return VerticalDropLocation.MIDDLE;
+        }
+    }
+
+    public static HorizontalDropLocation getHorizontalDropLocation(
+            Element element, int clientX, double leftRightRatio) {
+
+        int absoluteLeft = element.getAbsoluteLeft();
+        int offsetWidth = element.getOffsetWidth();
+        int fromTop = clientX - absoluteLeft;
+
+        float percentageFromTop = (fromTop / (float) offsetWidth);
+        if (percentageFromTop < leftRightRatio) {
+            return HorizontalDropLocation.LEFT;
+        } else if (percentageFromTop > 1 - leftRightRatio) {
+            return HorizontalDropLocation.RIGHT;
+        } else {
+            return HorizontalDropLocation.CENTER;
+        }
+    }
+
+}
index c8a09cbc8f468dd1fc9b2617b5a5bb8000dc4f18..70f5793257b63fcea60bacb65f902b67f91aeaf0 100644 (file)
@@ -3,25 +3,7 @@
  */
 package com.vaadin.terminal.gwt.client.ui.dd;
 
-import com.google.gwt.user.client.Element;
 
 public enum HorizontalDropLocation {
-    LEFT, RIGHT, CENTER;
-
-    public static HorizontalDropLocation get(Element element, int clientX,
-            double leftRightRatio) {
-
-        int absoluteLeft = element.getAbsoluteLeft();
-        int offsetWidth = element.getOffsetWidth();
-        int fromTop = clientX - absoluteLeft;
-
-        float percentageFromTop = (fromTop / (float) offsetWidth);
-        if (percentageFromTop < leftRightRatio) {
-            return LEFT;
-        } else if (percentageFromTop > 1 - leftRightRatio) {
-            return RIGHT;
-        } else {
-            return CENTER;
-        }
-    }
+    LEFT, RIGHT, CENTER
 }
index 8c011d8bd8ea1fb06a92dd4a403a73034dca47c4..afd16992786e81c13c6543fc25a132fcd45e4d8b 100644 (file)
@@ -3,25 +3,6 @@
  */
 package com.vaadin.terminal.gwt.client.ui.dd;
 
-import com.google.gwt.user.client.Element;
-
 public enum VerticalDropLocation {
-    TOP, BOTTOM, MIDDLE;
-
-    public static VerticalDropLocation get(Element element, int clientY,
-            double topBottomRatio) {
-
-        int absoluteTop = element.getAbsoluteTop();
-        int offsetHeight = element.getOffsetHeight();
-        int fromTop = clientY - absoluteTop;
-
-        float percentageFromTop = (fromTop / (float) offsetHeight);
-        if (percentageFromTop < topBottomRatio) {
-            return TOP;
-        } else if (percentageFromTop > 1 - topBottomRatio) {
-            return BOTTOM;
-        } else {
-            return MIDDLE;
-        }
-    }
+    TOP, BOTTOM, MIDDLE
 }