summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-03-16 20:35:46 +0200
committerHenri Sara <henri.sara@gmail.com>2017-04-12 14:58:11 +0300
commit1ac4f9724106fcf4abaab892210122231710c6be (patch)
treecd63d9a7d1e689b041ca05d25385d4b39929782d /uitest/src
parent2df1b373aae547275b566fef957322af0b61b427 (diff)
downloadvaadin-framework-1ac4f9724106fcf4abaab892210122231710c6be.tar.gz
vaadin-framework-1ac4f9724106fcf4abaab892210122231710c6be.zip
Make it possible to drop things on top of Grid rows (#8747)
Fixes #8400
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java31
-rw-r--r--uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java9
2 files changed, 27 insertions, 13 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java
index a6036acac8..0c532e8762 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java
@@ -20,28 +20,25 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
-import com.vaadin.annotations.Widgetset;
-import com.vaadin.event.dnd.DropTargetExtension;
+import com.vaadin.event.dnd.grid.GridDropListener;
+import com.vaadin.server.Page;
import com.vaadin.server.VaadinRequest;
-import com.vaadin.shared.ui.grid.GridDragSourceExtensionState;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Grid;
import com.vaadin.ui.GridDragSourceExtension;
+import com.vaadin.ui.GridDropTargetExtension;
import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import elemental.json.Json;
import elemental.json.JsonObject;
-@Widgetset("com.vaadin.DefaultWidgetSet")
public class GridDragAndDrop extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
- // Drag source
+ // Drag source Grid
Grid<Bean> dragSourceComponent = new Grid<>();
-
dragSourceComponent.setItems(createItems(50));
dragSourceComponent.addColumn(Bean::getId).setCaption("ID");
dragSourceComponent.addColumn(Bean::getValue).setCaption("Value");
@@ -54,15 +51,20 @@ public class GridDragAndDrop extends AbstractTestUIWithLog {
return ret;
});
- Label dropTargetComponent = new Label("Drop here");
- DropTargetExtension<Label> dropTarget = new DropTargetExtension<>(
- dropTargetComponent);
+ // Drop target Grid
+ Grid<Bean> dropTargetComponent = new Grid<>();
+ dropTargetComponent.setItems(createItems(5));
+ dropTargetComponent.addColumn(Bean::getId).setCaption("ID");
+ dropTargetComponent.addColumn(Bean::getValue).setCaption("Value");
- dropTarget.addDropListener(event -> {
- log(event.getTransferData(
- GridDragSourceExtensionState.DATA_TYPE_DRAG_DATA));
+ GridDropTargetExtension<Bean> dropTarget = new GridDropTargetExtension<>(
+ dropTargetComponent);
+ dropTarget.addDropListener((GridDropListener<Bean>) event -> {
+ log(event.getDataTransferText() + ", targetId=" + event
+ .getDropTargetRow().getId());
});
+ // Layout grids
Layout layout = new HorizontalLayout();
layout.addComponents(dragSourceComponent, dropTargetComponent);
@@ -77,6 +79,9 @@ public class GridDragAndDrop extends AbstractTestUIWithLog {
selectionModeSwitch.setSelectedItem(Grid.SelectionMode.SINGLE);
addComponents(selectionModeSwitch, layout);
+
+ // Set dragover styling
+ Page.getCurrent().getStyles().add(".v-drag-over {color: red;}");
}
private List<Bean> createItems(int num) {
diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java
index a2fea1ba15..9895a9ea4f 100644
--- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java
+++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java
@@ -15,7 +15,9 @@
*/
package com.vaadin.tests.widgetset.client.grid;
+import java.util.List;
import java.util.Map;
+import java.util.function.Consumer;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.TableRowElement;
@@ -126,6 +128,13 @@ public class EscalatorProxy extends Escalator {
public SpacerUpdater getSpacerUpdater() {
return rowContainer.getSpacerUpdater();
}
+
+ @Override
+ public void setNewEscalatorRowCallback(
+ Consumer<List<TableRowElement>> consumer) {
+ throw new UnsupportedOperationException(
+ "NewEscalatorRowCallback function is not supported");
+ }
}
private class RowContainerProxy implements RowContainer {