From dd1d288d5fe7b3a1ee3db93afccacae72bc7408c Mon Sep 17 00:00:00 2001 From: Adam Wagner Date: Thu, 13 Apr 2017 11:47:45 +0300 Subject: Create combined drop mode to allow both on_top and between drops (#9063) Resolves #8932 --- .../main/java/com/vaadin/ui/GridDropTarget.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'server/src/main/java/com/vaadin/ui/GridDropTarget.java') diff --git a/server/src/main/java/com/vaadin/ui/GridDropTarget.java b/server/src/main/java/com/vaadin/ui/GridDropTarget.java index 0cd51d8634..97b9a80ac6 100644 --- a/server/src/main/java/com/vaadin/ui/GridDropTarget.java +++ b/server/src/main/java/com/vaadin/ui/GridDropTarget.java @@ -90,6 +90,43 @@ public class GridDropTarget extends DropTargetExtension> { GridDropListener.DROP_METHOD); } + /** + * Sets the threshold between drop locations from the top and the bottom of + * a row in pixels. + *

+ * Dropping an element + *

    + *
  • within {@code threshold} pixels from the top of a row results in a + * drop event with {@link com.vaadin.shared.ui.grid.DropLocation#ABOVE + * DropLocation.ABOVE}
  • + *
  • within {@code threshold} pixels from the bottom of a row results in + * a drop event with {@link com.vaadin.shared.ui.grid.DropLocation#BELOW + * DropLocation.BELOW}
  • + *
  • anywhere else within the row results in a drop event with {@link + * com.vaadin.shared.ui.grid.DropLocation#ON_TOP DropLocation.ON_TOP}
  • + *
+ * The value only has an effect when drop mode is set to {@link + * DropMode#ON_TOP_OR_BETWEEN}. + *

+ * Default is 5 pixels. + * + * @param threshold + * The threshold from the top and bottom of the row in pixels. + */ + public void setDropThreshold(int threshold) { + getState().dropThreshold = threshold; + } + + /** + * Gets the threshold between drop locations from the top and the bottom of + * the row. + * + * @return The threshold in pixels. + */ + public int getDropThreshold() { + return getState(false).dropThreshold; + } + @Override protected void registerDropTargetRpc(Grid target) { registerRpc( -- cgit v1.2.3