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;
}-*/;
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());
}
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;
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);
}
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;
if (treeNode == null) {
return null;
}
- VerticalDropLocation verticalDropLocation = VerticalDropLocation.get(
+ VerticalDropLocation verticalDropLocation = DDUtil.getVerticalDropLocation(
treeNode.nodeCaptionDiv, event.getClientY(), 0.2);
return verticalDropLocation;
}
--- /dev/null
+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;
+ }
+ }
+
+}
*/
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
}
*/
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
}