summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2018-02-01 15:04:33 +0200
committerIlia Motornyi <elmot@vaadin.com>2018-02-01 15:04:33 +0200
commit5f5a6ebfd7db9f1fc6de4a515423837280310e86 (patch)
treea49d916a29a5c631e1fd25f5e637fe22a975541a /uitest
parente11b8cc59c68fca6f35e1733a38d566a273028c4 (diff)
downloadvaadin-framework-5f5a6ebfd7db9f1fc6de4a515423837280310e86.tar.gz
vaadin-framework-5f5a6ebfd7db9f1fc6de4a515423837280310e86.zip
Add setters to Payload for JsonCodec to be able to encode
Fixes #10428
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropPayload.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropPayload.java b/uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropPayload.java
new file mode 100644
index 0000000000..050317358e
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropPayload.java
@@ -0,0 +1,55 @@
+package com.vaadin.tests.dnd;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.dnd.criteria.Payload;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.dnd.DragSourceExtension;
+import com.vaadin.ui.dnd.DropTargetExtension;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class DragAndDropPayload extends AbstractTestUIWithLog {
+
+ private final Label stringLabel = new Label(
+ "Drag source with string payload");
+ private final Label integerLabel = new Label(
+ "Drag source with integer payload");
+ private final Label doubleLabel = new Label(
+ "Drag source with double payload");
+
+ private final Label targetLabel = new Label("Drop target");
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ DragSourceExtension<Label> stringDragSource = new DragSourceExtension<>(
+ stringLabel);
+ stringDragSource.setPayload("payload_key", "string_value");
+
+ DragSourceExtension<Label> integerDragSource = new DragSourceExtension<>(
+ integerLabel);
+ integerDragSource.setPayload("payload_key", 42);
+
+ DragSourceExtension<Label> doubleDragSource = new DragSourceExtension<>(
+ doubleLabel);
+ doubleDragSource.setPayload("payload_key", 3.14);
+
+ DropTargetExtension<Label> dropTarget = new DropTargetExtension<>(
+ targetLabel);
+ dropTarget.addDropListener(event ->
+ event.getDataTransferData().entrySet().stream()
+ .filter(entry -> entry.getKey()
+ .startsWith(Payload.ITEM_PREFIX)).forEach(
+ entry -> log.log(entry.getKey() + " -> " + entry
+ .getValue()))
+ );
+
+ VerticalLayout dragSources = new VerticalLayout(stringLabel,
+ integerLabel, doubleLabel);
+ VerticalLayout dropTargets = new VerticalLayout(targetLabel);
+ getLayout()
+ .addComponent(new HorizontalLayout(dragSources, dropTargets));
+ }
+}