diff options
author | Adam Wagner <wbadam@users.noreply.github.com> | 2017-05-16 10:21:31 +0300 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-05-16 10:21:31 +0300 |
commit | eb743d965278d263a4c496bb4e39c067fe2b1a8c (patch) | |
tree | f820843370c55216a4ec9612f3e20569b3d1e40f /shared | |
parent | 04e7259fb497e47bcd6d664e87c243db5badd934 (diff) | |
download | vaadin-framework-eb743d965278d263a4c496bb4e39c067fe2b1a8c.tar.gz vaadin-framework-eb743d965278d263a4c496bb4e39c067fe2b1a8c.zip |
Add API to store any type of data in the dataTransfer object (#9319)
Diffstat (limited to 'shared')
3 files changed, 37 insertions, 15 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java index 2ac5c4e438..66323a91c6 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java @@ -15,6 +15,11 @@ */ package com.vaadin.shared.ui.dnd; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import com.vaadin.shared.communication.SharedState; /** @@ -48,8 +53,13 @@ public class DragSourceState extends SharedState { public EffectAllowed effectAllowed = EffectAllowed.UNINITIALIZED; /** - * Used to store text data in {@code DataTransfer} object for the drag - * event. + * {@code DataTransfer.types} parameter. Used to keep track of data formats + * set for the drag event. + */ + public List<String> types = new ArrayList<>(); + + /** + * Used to store data in the {@code DataTransfer} object for the drag event. */ - public String dataTransferText; + public Map<String, String> data = new HashMap<>(); } diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetRpc.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetRpc.java index a889fce098..2d475f51e7 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetRpc.java +++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetRpc.java @@ -15,6 +15,9 @@ */ package com.vaadin.shared.ui.dnd; +import java.util.List; +import java.util.Map; + import com.vaadin.shared.communication.ServerRpc; /** @@ -29,11 +32,14 @@ public interface DropTargetRpc extends ServerRpc { /** * Called when drop event happens on client side. * - * @param dataTransferText - * Data of type {@code "text"} from the {@code DataTransfer} - * object. + * @param types + * List of data types from {@code DataTransfer.types} object. + * @param data + * Map containing all types and corresponding data from the {@code + * DataTransfer} object. * @param dropEffect - * the desired drop effect + * The desired drop effect. */ - public void drop(String dataTransferText, String dropEffect); + public void drop(List<String> types, Map<String, String> data, + String dropEffect); } diff --git a/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetRpc.java b/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetRpc.java index 6fb4f39dd3..1e1242be5a 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetRpc.java +++ b/shared/src/main/java/com/vaadin/shared/ui/grid/GridDropTargetRpc.java @@ -15,6 +15,9 @@ */ package com.vaadin.shared.ui.grid; +import java.util.List; +import java.util.Map; + import com.vaadin.shared.communication.ServerRpc; /** @@ -29,16 +32,19 @@ public interface GridDropTargetRpc extends ServerRpc { /** * Called when drop event happens on client side. * - * @param dataTransferText - * Data of type {@code "text"} from the {@code DataTransfer} - * object. + * @param types + * List of data types from {@code DataTransfer.types} object. + * @param data + * Map containing all types and corresponding data from the {@code + * DataTransfer} object. * @param dropEffect - * the desired drop effect + * the desired drop effect * @param rowKey - * Key of the row on which the drop event occured. + * Key of the row on which the drop event occured. * @param dropLocation - * Location of the drop within the row. + * Location of the drop within the row. */ - public void drop(String dataTransferText, String dropEffect, String rowKey, + public void drop(List<String> types, Map<String, String> data, + String dropEffect, String rowKey, DropLocation dropLocation); } |