From a773c8c7b365e4041db87b5d9ddaad0bdc244a91 Mon Sep 17 00:00:00 2001 From: Adam Wagner Date: Fri, 7 Apr 2017 09:52:06 +0300 Subject: Make it possible to drop things between Grid rows (#8979) Fixes #8401 --- .../com/vaadin/shared/ui/grid/DropLocation.java | 40 ++++++++++++++++++++++ .../java/com/vaadin/shared/ui/grid/DropMode.java | 38 ++++++++++++++++++++ .../shared/ui/grid/GridDropTargetExtensionRpc.java | 5 ++- .../ui/grid/GridDropTargetExtensionState.java | 4 +++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 shared/src/main/java/com/vaadin/shared/ui/grid/DropLocation.java create mode 100644 shared/src/main/java/com/vaadin/shared/ui/grid/DropMode.java (limited to 'shared/src') diff --git a/shared/src/main/java/com/vaadin/shared/ui/grid/DropLocation.java b/shared/src/main/java/com/vaadin/shared/ui/grid/DropLocation.java new file mode 100644 index 0000000000..1453c05c71 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/grid/DropLocation.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui.grid; + +/** + * Defines drop locations within a Grid row. + * + * @author Vaadin Ltd. + * @since + */ +public enum DropLocation { + + /** + * Drop on top of the row. + */ + ON_TOP, + + /** + * Drop above or before the row. + */ + ABOVE, + + /** + * Drop below or after the row. + */ + BELOW +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/grid/DropMode.java b/shared/src/main/java/com/vaadin/shared/ui/grid/DropMode.java new file mode 100644 index 0000000000..2db639be7d --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/grid/DropMode.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui.grid; + +/** + * Defines the locations within the Grid row where an element can be dropped. + * + * @author Vaadin Ltd. + * @since + */ +public enum DropMode { + + /** + * The drop event can happen between Grid rows. The drop is above a row + * when the cursor is over the top 50% of a row, otherwise below the + * row. + */ + BETWEEN, + + /** + * The drop event can happen on top of Grid rows. The target of the drop + * is the row under the cursor at the time of the drop event. + */ + ON_TOP, +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetExtensionRpc.java b/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetExtensionRpc.java index ef0dc405b5..212081d486 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetExtensionRpc.java +++ b/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetExtensionRpc.java @@ -34,6 +34,9 @@ public interface GridDropTargetExtensionRpc extends ServerRpc { * object. * @param rowKey * Key of the row on which the drop event occured. + * @param dropLocation + * Location of the drop within the row. */ - public void drop(String dataTransferText, String rowKey); + public void drop(String dataTransferText, String rowKey, + DropLocation dropLocation); } diff --git a/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetExtensionState.java b/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetExtensionState.java index c911d529d0..50b50a5d24 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetExtensionState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetExtensionState.java @@ -25,4 +25,8 @@ import com.vaadin.shared.ui.dnd.DropTargetState; */ public class GridDropTargetExtensionState extends DropTargetState { + /** + * Stores the drop mode of the drop target Grid. + */ + public DropMode dropMode; } -- cgit v1.2.3