diff options
author | Adam Wagner <wbadam@users.noreply.github.com> | 2017-04-13 11:47:45 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-04-13 11:47:45 +0300 |
commit | dd1d288d5fe7b3a1ee3db93afccacae72bc7408c (patch) | |
tree | 27231f5752e0840e6838a2e1885249bac9b6dd56 /server | |
parent | 8cf7b41e3f3dddb0a83cbc422511adb24796f85d (diff) | |
download | vaadin-framework-dd1d288d5fe7b3a1ee3db93afccacae72bc7408c.tar.gz vaadin-framework-dd1d288d5fe7b3a1ee3db93afccacae72bc7408c.zip |
Create combined drop mode to allow both on_top and between drops (#9063)
Resolves #8932
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/GridDropTarget.java | 37 |
1 files changed, 37 insertions, 0 deletions
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<T> extends DropTargetExtension<Grid<T>> { GridDropListener.DROP_METHOD); } + /** + * Sets the threshold between drop locations from the top and the bottom of + * a row in pixels. + * <p> + * Dropping an element + * <ul> + * <li>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}</li> + * <li>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}</li> + * <li>anywhere else within the row results in a drop event with {@link + * com.vaadin.shared.ui.grid.DropLocation#ON_TOP DropLocation.ON_TOP}</li> + * </ul> + * The value only has an effect when drop mode is set to {@link + * DropMode#ON_TOP_OR_BETWEEN}. + * <p> + * 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<T> target) { registerRpc( |