summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-03-22 16:41:35 +0200
committerHenri Sara <henri.sara@gmail.com>2017-03-22 16:41:35 +0200
commitacbb5a787b8623745aa440b37705e76dfab21d4e (patch)
treeb85b2e1fae185c54f88123c77db2b8b0c34177a7 /client
parent52359708adb2033eab2765377d7bcba0b8a97b54 (diff)
downloadvaadin-framework-acbb5a787b8623745aa440b37705e76dfab21d4e.tar.gz
vaadin-framework-acbb5a787b8623745aa440b37705e76dfab21d4e.zip
Remove support for transfer data type (#8910)
* Remove API for setting arbitrary drag data * Store the drag source component in the UI Fixes #8893
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java21
-rw-r--r--client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java26
2 files changed, 7 insertions, 40 deletions
diff --git a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java
index 051554f913..da14466666 100644
--- a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java
+++ b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java
@@ -15,9 +15,6 @@
*/
package com.vaadin.client.extensions;
-import java.util.List;
-import java.util.Map;
-
import com.google.gwt.dom.client.DataTransfer;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
@@ -45,11 +42,6 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector {
private static final String CLASS_DRAGGABLE = "v-draggable";
- /**
- * Data type for storing drag source extension connector's ID
- */
- static final String DATA_TYPE_DRAG_SOURCE_ID = "drag-source-id";
-
// Create event listeners
private final EventListener dragStartListener = this::onDragStart;
private final EventListener dragEndListener = this::onDragEnd;
@@ -105,16 +97,9 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector {
getState().effectAllowed.getValue());
}
- // Set data parameter
- List<String> types = getState().types;
- Map<String, String> data = getState().data;
- for (String format : types) {
- nativeEvent.getDataTransfer().setData(format, data.get(format));
- }
-
- // Store the extension's connector ID in DataTransfer.data
- nativeEvent.getDataTransfer()
- .setData(DATA_TYPE_DRAG_SOURCE_ID, getConnectorId());
+ // Set text data parameter
+ nativeEvent.getDataTransfer().setData(DragSourceState.DATA_TYPE_TEXT,
+ getState().dataTransferText);
// Initiate firing server side dragstart event when there is a
// DragStartListener attached on the server side
diff --git a/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java b/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java
index a8e25f261c..a1ac662987 100644
--- a/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java
+++ b/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java
@@ -15,12 +15,6 @@
*/
package com.vaadin.client.extensions;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.dom.client.BrowserEvents;
import com.google.gwt.dom.client.DataTransfer;
import com.google.gwt.dom.client.Element;
@@ -30,6 +24,7 @@ import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ServerConnector;
import com.vaadin.event.dnd.DropTargetExtension;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.dnd.DragSourceState;
import com.vaadin.shared.ui.dnd.DropTargetRpc;
import com.vaadin.shared.ui.dnd.DropTargetState;
@@ -184,20 +179,11 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector {
nativeEvent.preventDefault();
nativeEvent.stopPropagation();
- // Initiate firing server side drop event
- JsArrayString typesJsArray = getTypes(
- nativeEvent.getDataTransfer());
- List<String> types = new ArrayList<>();
- Map<String, String> data = new HashMap<>();
- for (int i = 0; i < typesJsArray.length(); i++) {
- types.add(typesJsArray.get(i));
- data.put(typesJsArray.get(i), nativeEvent.getDataTransfer()
- .getData(typesJsArray.get(i)));
- }
+ String dataTransferText = nativeEvent.getDataTransfer().getData(
+ DragSourceState.DATA_TYPE_TEXT);
getRpcProxy(DropTargetRpc.class)
- .drop(types, data, getState().dropEffect, data.get(
- DragSourceExtensionConnector.DATA_TYPE_DRAG_SOURCE_ID));
+ .drop(dataTransferText, getState().dropEffect);
}
removeTargetIndicator(getDropTargetElement());
@@ -224,10 +210,6 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector {
return new Function('event', script)(event);
}-*/;
- private native JsArrayString getTypes(DataTransfer dataTransfer)/*-{
- return dataTransfer.types;
- }-*/;
-
@Override
public DropTargetState getState() {
return (DropTargetState) super.getState();