aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2017-05-12 11:33:55 +0300
committerGitHub <noreply@github.com>2017-05-12 11:33:55 +0300
commit76892855a7c3f37a1fef5caee3c0debf6aa712e2 (patch)
tree5f990c860d922439528b548c22d3df8bc45c03d4 /server/src/main/java/com
parent22848f3420b5aded4d35c84f368dd9c44041200f (diff)
downloadvaadin-framework-76892855a7c3f37a1fef5caee3c0debf6aa712e2.tar.gz
vaadin-framework-76892855a7c3f37a1fef5caee3c0debf6aa712e2.zip
Refactor Html5 DnD feature based on API review (#9306)
* Refactor Html5 DnD client side based on API review - Moved classes to "correct" packages. - Removed method DragSourceExtension.clearDataTransferText() - Remove ButtonDragSource in favor of more generic API
Diffstat (limited to 'server/src/main/java/com')
-rw-r--r--server/src/main/java/com/vaadin/event/Transferable.java4
-rw-r--r--server/src/main/java/com/vaadin/event/dd/DragAndDropEvent.java2
-rw-r--r--server/src/main/java/com/vaadin/event/dd/DragSource.java2
-rw-r--r--server/src/main/java/com/vaadin/event/dd/DropHandler.java2
-rw-r--r--server/src/main/java/com/vaadin/event/dd/DropTarget.java2
-rw-r--r--server/src/main/java/com/vaadin/event/dd/TargetDetails.java2
-rw-r--r--server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java2
-rw-r--r--server/src/main/java/com/vaadin/event/dnd/ButtonDragSource.java44
-rw-r--r--server/src/main/java/com/vaadin/server/DragAndDropService.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/Html5File.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/UI.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDragEndEvent.java (renamed from server/src/main/java/com/vaadin/event/dnd/grid/GridDragEndEvent.java)10
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDragEndListener.java (renamed from server/src/main/java/com/vaadin/event/dnd/grid/GridDragEndListener.java)3
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDragSource.java (renamed from server/src/main/java/com/vaadin/ui/GridDragSource.java)29
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDragStartEvent.java (renamed from server/src/main/java/com/vaadin/event/dnd/grid/GridDragStartEvent.java)10
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDragStartListener.java (renamed from server/src/main/java/com/vaadin/event/dnd/grid/GridDragStartListener.java)3
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDropEvent.java (renamed from server/src/main/java/com/vaadin/event/dnd/grid/GridDropEvent.java)7
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDropListener.java (renamed from server/src/main/java/com/vaadin/event/dnd/grid/GridDropListener.java)3
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDropTarget.java (renamed from server/src/main/java/com/vaadin/ui/GridDropTarget.java)13
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/DragSourceExtension.java (renamed from server/src/main/java/com/vaadin/event/dnd/DragSourceExtension.java)101
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/DropTargetExtension.java (renamed from server/src/main/java/com/vaadin/event/dnd/DropTargetExtension.java)60
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/FileDropHandler.java (renamed from server/src/main/java/com/vaadin/event/dnd/FileDropHandler.java)5
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/FileDropTarget.java (renamed from server/src/main/java/com/vaadin/ui/FileDropTarget.java)110
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/event/DragEndEvent.java (renamed from server/src/main/java/com/vaadin/event/dnd/DragEndEvent.java)4
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/event/DragEndListener.java (renamed from server/src/main/java/com/vaadin/event/dnd/DragEndListener.java)3
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/event/DragStartEvent.java (renamed from server/src/main/java/com/vaadin/event/dnd/DragStartEvent.java)3
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/event/DragStartListener.java (renamed from server/src/main/java/com/vaadin/event/dnd/DragStartListener.java)3
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/event/DropEvent.java (renamed from server/src/main/java/com/vaadin/event/dnd/DropEvent.java)4
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/event/DropListener.java (renamed from server/src/main/java/com/vaadin/event/dnd/DropListener.java)3
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/event/FileDropEvent.java (renamed from server/src/main/java/com/vaadin/event/dnd/FileDropEvent.java)3
31 files changed, 244 insertions, 217 deletions
diff --git a/server/src/main/java/com/vaadin/event/Transferable.java b/server/src/main/java/com/vaadin/event/Transferable.java
index f75974a1cc..1f0ed866c1 100644
--- a/server/src/main/java/com/vaadin/event/Transferable.java
+++ b/server/src/main/java/com/vaadin/event/Transferable.java
@@ -18,9 +18,9 @@ package com.vaadin.event;
import java.io.Serializable;
import java.util.Collection;
-import com.vaadin.event.dnd.DragSourceExtension;
-import com.vaadin.event.dnd.DropEvent;
import com.vaadin.ui.Component;
+import com.vaadin.ui.dnd.DragSourceExtension;
+import com.vaadin.ui.dnd.event.DropEvent;
/**
* Transferable wraps the data that is to be imported into another component.
diff --git a/server/src/main/java/com/vaadin/event/dd/DragAndDropEvent.java b/server/src/main/java/com/vaadin/event/dd/DragAndDropEvent.java
index 6f66036e5a..6bf8a7f319 100644
--- a/server/src/main/java/com/vaadin/event/dd/DragAndDropEvent.java
+++ b/server/src/main/java/com/vaadin/event/dd/DragAndDropEvent.java
@@ -19,7 +19,7 @@ import java.io.Serializable;
import com.vaadin.event.Transferable;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
-import com.vaadin.event.dnd.DropEvent;
+import com.vaadin.ui.dnd.event.DropEvent;
/**
* DragAndDropEvent wraps information related to drag and drop operation. It is
diff --git a/server/src/main/java/com/vaadin/event/dd/DragSource.java b/server/src/main/java/com/vaadin/event/dd/DragSource.java
index 8a3c8c32dc..6361925864 100644
--- a/server/src/main/java/com/vaadin/event/dd/DragSource.java
+++ b/server/src/main/java/com/vaadin/event/dd/DragSource.java
@@ -19,8 +19,8 @@ import java.util.Map;
import com.vaadin.event.Transferable;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
-import com.vaadin.event.dnd.DragSourceExtension;
import com.vaadin.ui.Component;
+import com.vaadin.ui.dnd.DragSourceExtension;
/**
* DragSource is a {@link Component} that builds a {@link Transferable} for a
diff --git a/server/src/main/java/com/vaadin/event/dd/DropHandler.java b/server/src/main/java/com/vaadin/event/dd/DropHandler.java
index d6183940e9..a96b6206d5 100644
--- a/server/src/main/java/com/vaadin/event/dd/DropHandler.java
+++ b/server/src/main/java/com/vaadin/event/dd/DropHandler.java
@@ -21,7 +21,7 @@ import com.vaadin.event.Transferable;
import com.vaadin.event.dd.acceptcriteria.AcceptAll;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion;
-import com.vaadin.event.dnd.DropListener;
+import com.vaadin.ui.dnd.event.DropListener;
/**
* DropHandlers contain the actual business logic for drag and drop operations.
diff --git a/server/src/main/java/com/vaadin/event/dd/DropTarget.java b/server/src/main/java/com/vaadin/event/dd/DropTarget.java
index 3d346418c0..5202718109 100644
--- a/server/src/main/java/com/vaadin/event/dd/DropTarget.java
+++ b/server/src/main/java/com/vaadin/event/dd/DropTarget.java
@@ -17,8 +17,8 @@ package com.vaadin.event.dd;
import java.util.Map;
-import com.vaadin.event.dnd.DropTargetExtension;
import com.vaadin.ui.Component;
+import com.vaadin.ui.dnd.DropTargetExtension;
/**
* DropTarget is an interface for components supporting drop operations. A
diff --git a/server/src/main/java/com/vaadin/event/dd/TargetDetails.java b/server/src/main/java/com/vaadin/event/dd/TargetDetails.java
index 4a22958952..710fc5792f 100644
--- a/server/src/main/java/com/vaadin/event/dd/TargetDetails.java
+++ b/server/src/main/java/com/vaadin/event/dd/TargetDetails.java
@@ -17,7 +17,7 @@ package com.vaadin.event.dd;
import java.io.Serializable;
-import com.vaadin.event.dnd.DropEvent;
+import com.vaadin.ui.dnd.event.DropEvent;
/**
* TargetDetails wraps drop target related information about
diff --git a/server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java b/server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java
index fadc1877cf..3ede6a20e0 100644
--- a/server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java
+++ b/server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java
@@ -18,8 +18,8 @@ package com.vaadin.event.dd;
import java.util.HashMap;
import java.util.Map;
-import com.vaadin.event.dnd.DropEvent;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.ui.dnd.event.DropEvent;
/**
* A HashMap backed implementation of {@link TargetDetails} for terminal
diff --git a/server/src/main/java/com/vaadin/event/dnd/ButtonDragSource.java b/server/src/main/java/com/vaadin/event/dnd/ButtonDragSource.java
deleted file mode 100644
index 3d0d93dfa2..0000000000
--- a/server/src/main/java/com/vaadin/event/dnd/ButtonDragSource.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.event.dnd;
-
-import com.vaadin.annotations.Widgetset;
-import com.vaadin.shared.ui.dnd.ButtonDragSourceState;
-import com.vaadin.ui.Button;
-
-/**
- * Extension to make Button a drag source for HTML5 drag and drop functionality.
- *
- * @author Vaadin Ltd.
- * @since 8.1
- */
-@Widgetset("com.vaadin.DefaultWidgetSet")
-public class ButtonDragSource extends DragSourceExtension<Button> {
-
- public ButtonDragSource(Button target) {
- super(target);
- }
-
- @Override
- protected ButtonDragSourceState getState() {
- return (ButtonDragSourceState) super.getState();
- }
-
- @Override
- protected ButtonDragSourceState getState(boolean markAsDirty) {
- return (ButtonDragSourceState) super.getState(markAsDirty);
- }
-}
diff --git a/server/src/main/java/com/vaadin/server/DragAndDropService.java b/server/src/main/java/com/vaadin/server/DragAndDropService.java
index 11b830352f..64926c531c 100644
--- a/server/src/main/java/com/vaadin/server/DragAndDropService.java
+++ b/server/src/main/java/com/vaadin/server/DragAndDropService.java
@@ -33,14 +33,14 @@ import com.vaadin.event.dd.DropTarget;
import com.vaadin.event.dd.TargetDetails;
import com.vaadin.event.dd.TargetDetailsImpl;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
-import com.vaadin.event.dnd.DragSourceExtension;
-import com.vaadin.event.dnd.DropTargetExtension;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.SharedState;
import com.vaadin.shared.ui.dd.DragEventType;
import com.vaadin.ui.Component;
import com.vaadin.ui.UI;
+import com.vaadin.ui.dnd.DragSourceExtension;
+import com.vaadin.ui.dnd.DropTargetExtension;
import elemental.json.JsonObject;
diff --git a/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java b/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java
index 591cee6be5..194a354ad0 100644
--- a/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java
+++ b/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java
@@ -33,8 +33,6 @@ import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.DropTarget;
import com.vaadin.event.dd.TargetDetails;
import com.vaadin.event.dd.TargetDetailsImpl;
-import com.vaadin.event.dnd.DragSourceExtension;
-import com.vaadin.event.dnd.DropTargetExtension;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.StreamVariable;
@@ -45,6 +43,8 @@ import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperConstants;
import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperServerRpc;
import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperState;
import com.vaadin.ui.declarative.DesignContext;
+import com.vaadin.ui.dnd.DragSourceExtension;
+import com.vaadin.ui.dnd.DropTargetExtension;
/**
* @author Vaadin Ltd
diff --git a/server/src/main/java/com/vaadin/ui/Html5File.java b/server/src/main/java/com/vaadin/ui/Html5File.java
index b4434e75c9..4480e3d59b 100644
--- a/server/src/main/java/com/vaadin/ui/Html5File.java
+++ b/server/src/main/java/com/vaadin/ui/Html5File.java
@@ -32,7 +32,17 @@ public class Html5File implements Serializable {
private StreamVariable streamVariable;
private final String type;
- Html5File(String name, long size, String mimeType) {
+ /**
+ * Constructs a new Html5 file wrapper.
+ *
+ * @param name
+ * the file name
+ * @param size
+ * the size of the file
+ * @param mimeType
+ * the type of the file
+ */
+ public Html5File(String name, long size, String mimeType) {
this.name = name;
this.size = size;
type = mimeType;
diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java
index 1928aabe87..ed2d58df3c 100644
--- a/server/src/main/java/com/vaadin/ui/UI.java
+++ b/server/src/main/java/com/vaadin/ui/UI.java
@@ -44,8 +44,6 @@ import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.event.UIEvents.PollEvent;
import com.vaadin.event.UIEvents.PollListener;
import com.vaadin.event.UIEvents.PollNotifier;
-import com.vaadin.event.dnd.DragSourceExtension;
-import com.vaadin.event.dnd.DropTargetExtension;
import com.vaadin.navigator.Navigator;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.ComponentSizeValidator;
@@ -83,6 +81,8 @@ import com.vaadin.ui.Component.Focusable;
import com.vaadin.ui.Dependency.Type;
import com.vaadin.ui.Window.WindowOrderChangeListener;
import com.vaadin.ui.declarative.Design;
+import com.vaadin.ui.dnd.DragSourceExtension;
+import com.vaadin.ui.dnd.DropTargetExtension;
import com.vaadin.util.ConnectorHelper;
import com.vaadin.util.CurrentInstance;
import com.vaadin.util.ReflectTools;
diff --git a/server/src/main/java/com/vaadin/event/dnd/grid/GridDragEndEvent.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDragEndEvent.java
index 06c583fc57..27fcf222fa 100644
--- a/server/src/main/java/com/vaadin/event/dnd/grid/GridDragEndEvent.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDragEndEvent.java
@@ -13,14 +13,14 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd.grid;
+package com.vaadin.ui.components.grid;
+import java.util.Collections;
import java.util.Set;
-import com.vaadin.event.dnd.DragEndEvent;
import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.ui.Grid;
-import com.vaadin.ui.GridDragSource;
+import com.vaadin.ui.dnd.event.DragEndEvent;
/**
* Drop event on an HTML5 drop target {@link Grid} row.
@@ -55,9 +55,9 @@ public class GridDragEndEvent<T> extends DragEndEvent<Grid<T>> {
/**
* Get the dragged row items.
*
- * @return Set of row items that were being dragged.
+ * @return an unmodifiable set of items that were being dragged.
*/
public Set<T> getDraggedItems() {
- return draggedItems;
+ return Collections.unmodifiableSet(draggedItems);
}
}
diff --git a/server/src/main/java/com/vaadin/event/dnd/grid/GridDragEndListener.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDragEndListener.java
index eb2b90fa64..d41a58bbb6 100644
--- a/server/src/main/java/com/vaadin/event/dnd/grid/GridDragEndListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDragEndListener.java
@@ -13,12 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd.grid;
+package com.vaadin.ui.components.grid;
import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEventListener;
-import com.vaadin.ui.GridDragSource;
/**
* Drop listener for HTML5 drop on a Grid row.
diff --git a/server/src/main/java/com/vaadin/ui/GridDragSource.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDragSource.java
index a7798b581a..741ba043c6 100644
--- a/server/src/main/java/com/vaadin/ui/GridDragSource.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDragSource.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.ui;
+package com.vaadin.ui.components.grid;
import java.util.List;
import java.util.Optional;
@@ -21,17 +21,14 @@ import java.util.Set;
import java.util.stream.Collectors;
import com.vaadin.data.provider.DataGenerator;
-import com.vaadin.event.dnd.DragSourceExtension;
-import com.vaadin.event.dnd.grid.GridDragEndEvent;
-import com.vaadin.event.dnd.grid.GridDragEndListener;
-import com.vaadin.event.dnd.grid.GridDragStartEvent;
-import com.vaadin.event.dnd.grid.GridDragStartListener;
import com.vaadin.server.SerializableFunction;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.dnd.DragSourceState;
import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.shared.ui.grid.GridDragSourceRpc;
import com.vaadin.shared.ui.grid.GridDragSourceState;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.dnd.DragSourceExtension;
import elemental.json.JsonObject;
@@ -71,18 +68,18 @@ public class GridDragSource<T> extends DragSourceExtension<Grid<T>> {
dragDataGenerator = this::generateDragData;
// Add drag data generator to Grid
- target.addDataGenerator(dragDataGenerator);
+ target.getDataCommunicator().addDataGenerator(dragDataGenerator);
}
@Override
- protected void registerDragSourceRpc(Grid<T> target) {
+ protected void registerDragSourceRpc() {
registerRpc(new GridDragSourceRpc() {
@Override
public void dragStart(List<String> draggedItemKeys) {
- GridDragStartEvent<T> event = new GridDragStartEvent<>(target,
- getState(false).effectAllowed,
- getDraggedItems(target, draggedItemKeys));
+ GridDragStartEvent<T> event = new GridDragStartEvent<>(
+ getParent(), getState(false).effectAllowed,
+ getDraggedItems(getParent(), draggedItemKeys));
fireEvent(event);
}
@@ -91,8 +88,9 @@ public class GridDragSource<T> extends DragSourceExtension<Grid<T>> {
public void dragEnd(DropEffect dropEffect,
List<String> draggedItemKeys) {
- GridDragEndEvent<T> event = new GridDragEndEvent<>(target,
- dropEffect, getDraggedItems(target, draggedItemKeys));
+ GridDragEndEvent<T> event = new GridDragEndEvent<>(getParent(),
+ dropEffect,
+ getDraggedItems(getParent(), draggedItemKeys));
fireEvent(event);
}
@@ -135,7 +133,7 @@ public class GridDragSource<T> extends DragSourceExtension<Grid<T>> {
* {@link JsonObject} to be appended to the row data.
* <p>
* Example:
- *
+ *
* <pre>
* dragSourceExtension.setDragDataGenerator(item -> {
* JsonObject dragData = Json.createObject();
@@ -211,7 +209,8 @@ public class GridDragSource<T> extends DragSourceExtension<Grid<T>> {
public void remove() {
super.remove();
- getParent().removeDataGenerator(dragDataGenerator);
+ getParent().getDataCommunicator()
+ .removeDataGenerator(dragDataGenerator);
}
@Override
diff --git a/server/src/main/java/com/vaadin/event/dnd/grid/GridDragStartEvent.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDragStartEvent.java
index 35691d20c2..576dca4ef5 100644
--- a/server/src/main/java/com/vaadin/event/dnd/grid/GridDragStartEvent.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDragStartEvent.java
@@ -13,14 +13,14 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd.grid;
+package com.vaadin.ui.components.grid;
+import java.util.Collections;
import java.util.Set;
-import com.vaadin.event.dnd.DragStartEvent;
import com.vaadin.shared.ui.dnd.EffectAllowed;
import com.vaadin.ui.Grid;
-import com.vaadin.ui.GridDragSource;
+import com.vaadin.ui.dnd.event.DragStartEvent;
/**
* Drag start event on an HTML5 drag source {@link Grid} row.
@@ -55,9 +55,9 @@ public class GridDragStartEvent<T> extends DragStartEvent<Grid<T>> {
/**
* Get the dragged row items.
*
- * @return Set of row items that are being dragged.
+ * @return an unmodifiable set of items that are being dragged.
*/
public Set<T> getDraggedItems() {
- return draggedItems;
+ return Collections.unmodifiableSet(draggedItems);
}
}
diff --git a/server/src/main/java/com/vaadin/event/dnd/grid/GridDragStartListener.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDragStartListener.java
index 0d1e071eea..10f57e85c1 100644
--- a/server/src/main/java/com/vaadin/event/dnd/grid/GridDragStartListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDragStartListener.java
@@ -13,12 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd.grid;
+package com.vaadin.ui.components.grid;
import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEventListener;
-import com.vaadin.ui.GridDragSource;
/**
* Drag start listener for HTML5 drag start on a Grid row.
diff --git a/server/src/main/java/com/vaadin/event/dnd/grid/GridDropEvent.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDropEvent.java
index df634cf559..40df9f254f 100644
--- a/server/src/main/java/com/vaadin/event/dnd/grid/GridDropEvent.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDropEvent.java
@@ -13,15 +13,14 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd.grid;
+package com.vaadin.ui.components.grid;
-import com.vaadin.event.dnd.DragSourceExtension;
-import com.vaadin.event.dnd.DropEvent;
import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.shared.ui.grid.DropLocation;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Grid;
-import com.vaadin.ui.GridDropTarget;
+import com.vaadin.ui.dnd.DragSourceExtension;
+import com.vaadin.ui.dnd.event.DropEvent;
/**
* Drop event on an HTML5 drop target {@link Grid} row.
diff --git a/server/src/main/java/com/vaadin/event/dnd/grid/GridDropListener.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDropListener.java
index 0bd48db2ca..efac802ae7 100644
--- a/server/src/main/java/com/vaadin/event/dnd/grid/GridDropListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDropListener.java
@@ -13,12 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd.grid;
+package com.vaadin.ui.components.grid;
import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEventListener;
-import com.vaadin.ui.GridDropTarget;
/**
* Drop listener for HTML5 drop on a Grid row.
diff --git a/server/src/main/java/com/vaadin/ui/GridDropTarget.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDropTarget.java
index 021051130c..435f40da6e 100644
--- a/server/src/main/java/com/vaadin/ui/GridDropTarget.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDropTarget.java
@@ -13,16 +13,15 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.ui;
+package com.vaadin.ui.components.grid;
-import com.vaadin.event.dnd.DropTargetExtension;
-import com.vaadin.event.dnd.grid.GridDropEvent;
-import com.vaadin.event.dnd.grid.GridDropListener;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.shared.ui.grid.DropMode;
import com.vaadin.shared.ui.grid.GridDropTargetRpc;
import com.vaadin.shared.ui.grid.GridDropTargetState;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.dnd.DropTargetExtension;
/**
* Makes the rows of a Grid HTML5 drop targets. This is the server side
@@ -130,14 +129,14 @@ public class GridDropTarget<T> extends DropTargetExtension<Grid<T>> {
}
@Override
- protected void registerDropTargetRpc(Grid<T> target) {
+ protected void registerDropTargetRpc() {
registerRpc((GridDropTargetRpc) (dataTransferText, dropEffect, rowKey,
dropLocation) -> {
- T dropTargetRow = target.getDataCommunicator().getKeyMapper()
+ T dropTargetRow = getParent().getDataCommunicator().getKeyMapper()
.get(rowKey);
- GridDropEvent<T> event = new GridDropEvent<>(target,
+ GridDropEvent<T> event = new GridDropEvent<>(getParent(),
dataTransferText,
DropEffect.valueOf(dropEffect.toUpperCase()),
getUI().getActiveDragSource(), dropTargetRow, dropLocation);
diff --git a/server/src/main/java/com/vaadin/event/dnd/DragSourceExtension.java b/server/src/main/java/com/vaadin/ui/dnd/DragSourceExtension.java
index 7ff84757d9..24192fa592 100644
--- a/server/src/main/java/com/vaadin/event/dnd/DragSourceExtension.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/DragSourceExtension.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd;
import java.util.Objects;
@@ -25,18 +25,22 @@ import com.vaadin.shared.ui.dnd.DragSourceState;
import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.shared.ui.dnd.EffectAllowed;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.dnd.event.DragEndEvent;
+import com.vaadin.ui.dnd.event.DragEndListener;
+import com.vaadin.ui.dnd.event.DragStartEvent;
+import com.vaadin.ui.dnd.event.DragStartListener;
/**
* Extension to make a component drag source for HTML5 drag and drop
* functionality.
*
* @param <T>
- * Type of the component to be extended.
+ * Type of the component to be extended.
* @author Vaadin Ltd
* @since 8.1
*/
-public class DragSourceExtension<T extends AbstractComponent> extends
- AbstractExtension {
+public class DragSourceExtension<T extends AbstractComponent>
+ extends AbstractExtension {
private Registration dragStartListenerHandle;
private Registration dragEndListenerHandle;
@@ -51,22 +55,19 @@ public class DragSourceExtension<T extends AbstractComponent> extends
* Extends {@code target} component and makes it a drag source.
*
* @param target
- * Component to be extended.
+ * Component to be extended.
*/
public DragSourceExtension(T target) {
-
- registerDragSourceRpc(target);
-
super.extend(target);
initListeners();
}
/**
- * Initializes the event listeners this drag source is using.
+ * Initializes dragstart and -end event listeners for this drag source to
+ * capture the active drag source for the UI.
*/
- protected void initListeners() {
-
+ private void initListeners() {
// Set current extension as active drag source in the UI
dragStartListenerHandle = addDragStartListener(
event -> getUI().setActiveDragSource(this));
@@ -76,29 +77,58 @@ public class DragSourceExtension<T extends AbstractComponent> extends
event -> getUI().setActiveDragSource(null));
}
+ @Override
+ public void attach() {
+ super.attach();
+
+ registerDragSourceRpc();
+ }
+
/**
- * Register server RPC.
- *
- * @param target
- * Extended component.
+ * Registers the server side RPC methods invoked from client side on
+ * <code>dragstart</code> and <code>dragend</code> events.
+ * <p>
+ * Override this method if you have custom RPC interface for transmitting
+ * those events with more data. If just need to do additional things before
+ * firing the events, then you should override {@link #onDragStart()} and
+ * {@link #onDragEnd(DropEffect)} instead.
*/
- protected void registerDragSourceRpc(T target) {
+ protected void registerDragSourceRpc() {
registerRpc(new DragSourceRpc() {
@Override
public void dragStart() {
- DragStartEvent<T> event = new DragStartEvent<>(target,
- getState(false).effectAllowed);
- fireEvent(event);
+ onDragStart();
}
@Override
public void dragEnd(DropEffect dropEffect) {
- DragEndEvent<T> event = new DragEndEvent<>(target, dropEffect);
- fireEvent(event);
+ onDragEnd(dropEffect);
}
});
}
+ /**
+ * Method invoked when a <code>dragstart</code> has been sent from client
+ * side. Fires the {@link DragStartEvent}.
+ */
+ protected void onDragStart() {
+ DragStartEvent<T> event = new DragStartEvent<>(getParent(),
+ getState(false).effectAllowed);
+ fireEvent(event);
+ }
+
+ /**
+ * Method invoked when a <code>dragend</code> has been sent from client
+ * side. Fires the {@link DragEndEvent}.
+ *
+ * @param dropEffect
+ * the drop effect on the dragend
+ */
+ protected void onDragEnd(DropEffect dropEffect) {
+ DragEndEvent<T> event = new DragEndEvent<>(getParent(), dropEffect);
+ fireEvent(event);
+ }
+
@Override
public void remove() {
super.remove();
@@ -117,7 +147,7 @@ public class DragSourceExtension<T extends AbstractComponent> extends
* equivalent to {@link EffectAllowed#ALL}.
*
* @param effect
- * Effects to allow for this draggable element. Cannot be {@code
+ * Effects to allow for this draggable element. Cannot be {@code
* null}.
*/
public void setEffectAllowed(EffectAllowed effect) {
@@ -146,7 +176,7 @@ public class DragSourceExtension<T extends AbstractComponent> extends
* data)} method.
*
* @param data
- * Data to be set for the client side draggable element.
+ * Data to be set for the client side draggable element.
*/
public void setDataTransferText(String data) {
getState().dataTransferText = data;
@@ -163,19 +193,12 @@ public class DragSourceExtension<T extends AbstractComponent> extends
}
/**
- * Clears data of type {@code "text"} in this drag source element.
- */
- public void clearDataTransferText() {
- getState().dataTransferText = null;
- }
-
- /**
* Set server side drag data. This data is available in the drop event and
* can be used to transfer data between drag source and drop target if they
* are in the same UI.
*
* @param data
- * Data to transfer to drop event.
+ * Data to transfer to drop event.
*/
public void setDragData(Object data) {
dragData = data;
@@ -193,12 +216,12 @@ public class DragSourceExtension<T extends AbstractComponent> extends
}
/**
- * Attaches dragstart listener for the current drag source. {@link
- * DragStartListener#dragStart(DragStartEvent)} is called when dragstart
- * event happens on the client side.
+ * Attaches dragstart listener for the current drag source.
+ * {@link DragStartListener#dragStart(DragStartEvent)} is called when
+ * dragstart event happens on the client side.
*
* @param listener
- * Listener to handle dragstart event.
+ * Listener to handle dragstart event.
* @return Handle to be used to remove this listener.
*/
public Registration addDragStartListener(DragStartListener<T> listener) {
@@ -208,12 +231,12 @@ public class DragSourceExtension<T extends AbstractComponent> extends
}
/**
- * Attaches dragend listener for the current drag source. {@link
- * DragEndListener#dragEnd(DragEndEvent)} is called when dragend
+ * Attaches dragend listener for the current drag source.
+ * {@link DragEndListener#dragEnd(DragEndEvent)} is called when dragend
* event happens on the client side.
*
* @param listener
- * Listener to handle dragend event.
+ * Listener to handle dragend event.
* @return Handle to be used to remove this listener.
*/
public Registration addDragEndListener(DragEndListener<T> listener) {
@@ -225,7 +248,7 @@ public class DragSourceExtension<T extends AbstractComponent> extends
* Set a custom drag image for the current drag source.
*
* @param imageResource
- * Resource of the image to be displayed as drag image.
+ * Resource of the image to be displayed as drag image.
*/
public void setDragImage(Resource imageResource) {
setResource(DragSourceState.RESOURCE_DRAG_IMAGE, imageResource);
diff --git a/server/src/main/java/com/vaadin/event/dnd/DropTargetExtension.java b/server/src/main/java/com/vaadin/ui/dnd/DropTargetExtension.java
index 53266a2eea..24a0372f50 100644
--- a/server/src/main/java/com/vaadin/event/dnd/DropTargetExtension.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/DropTargetExtension.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd;
import java.util.Objects;
@@ -23,10 +23,12 @@ import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.shared.ui.dnd.DropTargetRpc;
import com.vaadin.shared.ui.dnd.DropTargetState;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.dnd.event.DropEvent;
+import com.vaadin.ui.dnd.event.DropListener;
/**
- * Extension to add drop target functionality to a widget for using HTML5 drag
- * and drop.
+ * Extension to make a component a drop target for HTML5 drag and drop
+ * functionality.
*
* @param <T>
* Type of the component to be extended.
@@ -43,29 +45,49 @@ public class DropTargetExtension<T extends AbstractComponent>
* Component to be extended.
*/
public DropTargetExtension(T target) {
+ super.extend(target);
+ }
- registerDropTargetRpc(target);
+ @Override
+ public void attach() {
+ super.attach();
- super.extend(target);
+ registerDropTargetRpc();
}
/**
- * Register server RPC.
- *
- * @param target
- * Extended component.
+ * Registers the server side RPC methods invoked from client side on
+ * <code>drop</code> event.
+ * <p>
+ * Override this method if you need to have a custom RPC interface for
+ * transmitting the drop event with more data. If just need to do additional
+ * things before firing the drop event, then you should override
+ * {@link #onDrop(String, DropEffect)} instead.
*/
- protected void registerDropTargetRpc(T target) {
+ protected void registerDropTargetRpc() {
registerRpc((DropTargetRpc) (dataTransferText, dropEffect) -> {
- DropEvent<T> event = new DropEvent<>(target, dataTransferText,
- DropEffect.valueOf(dropEffect.toUpperCase()),
- getUI().getActiveDragSource());
-
- fireEvent(event);
+ onDrop(dataTransferText,
+ DropEffect.valueOf(dropEffect.toUpperCase()));
});
}
/**
+ * Invoked when a <code>drop</code> has been received from client side.
+ * Fires the {@link DropEvent}.
+ *
+ * @param dataTransferText
+ * the data transfer of type 'text' for the drop
+ * @param dropEffect
+ * the drop effect
+ */
+ protected void onDrop(String dataTransferText, DropEffect dropEffect) {
+ DropEvent<T> event = new DropEvent<>(getParent(), dataTransferText,
+ dropEffect, getUI().getActiveDragSource());
+
+ fireEvent(event);
+ }
+
+ /**
* Sets the drop effect for the current drop target. This is set to the
* dropEffect on {@code dragenter} and {@code dragover} events.
* <p>
@@ -104,9 +126,11 @@ public class DropTargetExtension<T extends AbstractComponent>
}
/**
- * Sets criteria to allow drop on this drop target. The script executes when
- * something is dragged on top of the target, and the drop is not allowed in
- * case the script returns {@code false}.
+ * Sets a criteria script in JavaScript to allow drop on this drop target.
+ * The script is executed when something is dragged on top of the target,
+ * and the drop is not allowed in case the script returns {@code false}. If
+ * no script is set, then the drop is always accepted, if the set
+ * {@link #setDropEffect(DropEffect) dropEffect} matches the drag source.
* <p>
* <b>IMPORTANT:</b> Construct the criteria script carefully and do not
* include untrusted sources such as user input. Always keep in mind that
diff --git a/server/src/main/java/com/vaadin/event/dnd/FileDropHandler.java b/server/src/main/java/com/vaadin/ui/dnd/FileDropHandler.java
index 5e74e44349..b9eb7d90eb 100644
--- a/server/src/main/java/com/vaadin/event/dnd/FileDropHandler.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/FileDropHandler.java
@@ -13,11 +13,12 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd;
import java.io.Serializable;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.dnd.event.FileDropEvent;
/**
* Handles the drop event on a file drop target.
@@ -26,7 +27,7 @@ import com.vaadin.ui.AbstractComponent;
* Type of the file drop target component.
* @author Vaadin Ltd
* @see FileDropEvent
- * @see com.vaadin.ui.FileDropTarget
+ * @see com.vaadin.ui.dnd.FileDropTarget
* @since 8.1
*/
public interface FileDropHandler<T extends AbstractComponent> extends
diff --git a/server/src/main/java/com/vaadin/ui/FileDropTarget.java b/server/src/main/java/com/vaadin/ui/dnd/FileDropTarget.java
index 88d2550691..bfb66c4fc4 100644
--- a/server/src/main/java/com/vaadin/ui/FileDropTarget.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/FileDropTarget.java
@@ -13,15 +13,12 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.ui;
+package com.vaadin.ui.dnd;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
-import com.vaadin.event.dnd.DropTargetExtension;
-import com.vaadin.event.dnd.FileDropEvent;
-import com.vaadin.event.dnd.FileDropHandler;
import com.vaadin.server.ServletPortletHelper;
import com.vaadin.server.StreamVariable;
import com.vaadin.shared.ApplicationConstants;
@@ -29,18 +26,28 @@ import com.vaadin.shared.ui.dnd.FileDropTargetClientRpc;
import com.vaadin.shared.ui.dnd.FileDropTargetRpc;
import com.vaadin.shared.ui.dnd.FileDropTargetState;
import com.vaadin.shared.ui.dnd.FileParameters;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.ConnectorTracker;
+import com.vaadin.ui.Html5File;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.dnd.event.FileDropEvent;
/**
* Extension to add drop target functionality to a widget for accepting and
* uploading files.
+ * <p>
+ * Dropped files are handled in the {@link FileDropHandler} given in the
+ * constructor. The file details are first sent to the handler, which can then
+ * decide which files to upload to server by setting a {@link StreamVariable}
+ * with {@link Html5File#setStreamVariable(StreamVariable)}.
*
* @param <T>
- * Type of the component to be extended.
+ * Type of the component to be extended.
* @author Vaadin Ltd
* @since 8.1
*/
-public class FileDropTarget<T extends AbstractComponent> extends
- DropTargetExtension<T> {
+public class FileDropTarget<T extends AbstractComponent>
+ extends DropTargetExtension<T> {
/**
* Handles the file drop event.
@@ -52,45 +59,57 @@ public class FileDropTarget<T extends AbstractComponent> extends
* drop handler needs to be added to handle the file drop event.
*
* @param target
- * Component to be extended.
+ * Component to be extended.
* @param fileDropHandler
- * File drop handler that handles the file drop event.
+ * File drop handler that handles the file drop event.
* @see FileDropEvent
*/
public FileDropTarget(T target, FileDropHandler<T> fileDropHandler) {
super(target);
this.fileDropHandler = fileDropHandler;
- }
-
- @Override
- protected void registerDropTargetRpc(T target) {
- super.registerDropTargetRpc(target);
registerRpc(new FileDropTargetRpc() {
@Override
public void drop(Map<String, FileParameters> fileParams) {
- Map<String, Html5File> files = new HashMap<>();
- Map<String, String> urls = new HashMap<>();
-
- // Create a collection of html5 files
- fileParams.forEach((id, fileParameters) -> {
- Html5File html5File = new Html5File(
- fileParameters.getName(), fileParameters.getSize(),
- fileParameters.getMime());
- files.put(id, html5File);
- });
+ onDrop(fileParams);
+ }
- // Call drop handler with the collection of dropped files
- FileDropEvent<T> event = new FileDropEvent<>(target,
- files.values());
- fileDropHandler.drop(event);
+ @Override
+ public void poll() {
+ // Polling server for changes after upload finished
+ }
+ });
+ }
- // Create upload URLs for the files that the drop handler
- // attached stream variable to
- files.entrySet().stream()
- .filter(entry -> entry.getValue().getStreamVariable()
- != null).forEach(entry -> {
+ /**
+ * Invoked when a file or files have been dropped on client side. Fires the
+ * {@link FileDropEvent}.
+ *
+ * @param fileParams
+ * map from file ids to actual file details
+ */
+ protected void onDrop(Map<String, FileParameters> fileParams) {
+ Map<String, Html5File> files = new HashMap<>();
+ Map<String, String> urls = new HashMap<>();
+
+ // Create a collection of html5 files
+ fileParams.forEach((id, fileParameters) -> {
+ Html5File html5File = new Html5File(fileParameters.getName(),
+ fileParameters.getSize(), fileParameters.getMime());
+ files.put(id, html5File);
+ });
+
+ // Call drop handler with the collection of dropped files
+ FileDropEvent<T> event = new FileDropEvent<>(getParent(),
+ files.values());
+ fileDropHandler.drop(event);
+
+ // Create upload URLs for the files that the drop handler
+ // attached stream variable to
+ files.entrySet().stream()
+ .filter(entry -> entry.getValue().getStreamVariable() != null)
+ .forEach(entry -> {
String id = entry.getKey();
Html5File file = entry.getValue();
@@ -98,28 +117,20 @@ public class FileDropTarget<T extends AbstractComponent> extends
urls.put(id, url);
});
- // Send upload URLs to the client if there are files to be
- // uploaded
- if (urls.size() > 0) {
- getRpcProxy(FileDropTargetClientRpc.class)
- .sendUploadUrl(urls);
- }
- }
-
- @Override
- public void poll() {
- // Polling server for changes after upload finished
- }
- });
+ // Send upload URLs to the client if there are files to be
+ // uploaded
+ if (urls.size() > 0) {
+ getRpcProxy(FileDropTargetClientRpc.class).sendUploadUrl(urls);
+ }
}
/**
* Creates an upload URL for the given file and file ID.
*
* @param file
- * File to be uploaded.
+ * File to be uploaded.
* @param id
- * Generated ID for the file.
+ * Generated ID for the file.
* @return Upload URL for uploading the file to the server.
*/
private String createUrl(Html5File file, String id) {
@@ -147,7 +158,6 @@ public class FileDropTarget<T extends AbstractComponent> extends
return (FileDropTargetState) super.getState();
}
-
@Override
protected FileDropTargetState getState(boolean markAsDirty) {
return (FileDropTargetState) super.getState(markAsDirty);
@@ -161,7 +171,7 @@ public class FileDropTarget<T extends AbstractComponent> extends
@Override
@SuppressWarnings("unchecked")
public T getParent() {
- return (T) super.getParent();
+ return super.getParent();
}
private class FileReceiver implements StreamVariable {
diff --git a/server/src/main/java/com/vaadin/event/dnd/DragEndEvent.java b/server/src/main/java/com/vaadin/ui/dnd/event/DragEndEvent.java
index 5e0739d2d9..592a81497f 100644
--- a/server/src/main/java/com/vaadin/event/dnd/DragEndEvent.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/event/DragEndEvent.java
@@ -13,12 +13,14 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd.event;
import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.shared.ui.dnd.EffectAllowed;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
+import com.vaadin.ui.dnd.DragSourceExtension;
+import com.vaadin.ui.dnd.DropTargetExtension;
/**
* HTML5 drag end event.
diff --git a/server/src/main/java/com/vaadin/event/dnd/DragEndListener.java b/server/src/main/java/com/vaadin/ui/dnd/event/DragEndListener.java
index 55b55b2bcd..b8ab67279e 100644
--- a/server/src/main/java/com/vaadin/event/dnd/DragEndListener.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/event/DragEndListener.java
@@ -13,12 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd.event;
import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEventListener;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.dnd.DragSourceExtension;
/**
* Interface to be implemented when creating a dragend listener on a drag
diff --git a/server/src/main/java/com/vaadin/event/dnd/DragStartEvent.java b/server/src/main/java/com/vaadin/ui/dnd/event/DragStartEvent.java
index 2022f42a00..14d04bad96 100644
--- a/server/src/main/java/com/vaadin/event/dnd/DragStartEvent.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/event/DragStartEvent.java
@@ -13,11 +13,12 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd.event;
import com.vaadin.shared.ui.dnd.EffectAllowed;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
+import com.vaadin.ui.dnd.DragSourceExtension;
/**
* HTML5 drag start event.
diff --git a/server/src/main/java/com/vaadin/event/dnd/DragStartListener.java b/server/src/main/java/com/vaadin/ui/dnd/event/DragStartListener.java
index 530a0f113b..42c702f7db 100644
--- a/server/src/main/java/com/vaadin/event/dnd/DragStartListener.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/event/DragStartListener.java
@@ -13,12 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd.event;
import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEventListener;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.dnd.DragSourceExtension;
/**
* Interface to be implemented when creating a dragstart listener on a drag
diff --git a/server/src/main/java/com/vaadin/event/dnd/DropEvent.java b/server/src/main/java/com/vaadin/ui/dnd/event/DropEvent.java
index caa80a88ae..45dabd0a62 100644
--- a/server/src/main/java/com/vaadin/event/dnd/DropEvent.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/event/DropEvent.java
@@ -13,13 +13,15 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd.event;
import java.util.Optional;
import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
+import com.vaadin.ui.dnd.DragSourceExtension;
+import com.vaadin.ui.dnd.DropTargetExtension;
/**
* Server side drop event. Fired when an HTML5 drop happens.
diff --git a/server/src/main/java/com/vaadin/event/dnd/DropListener.java b/server/src/main/java/com/vaadin/ui/dnd/event/DropListener.java
index c10f51569c..5f31676468 100644
--- a/server/src/main/java/com/vaadin/event/dnd/DropListener.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/event/DropListener.java
@@ -13,12 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd.event;
import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEventListener;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.dnd.DropTargetExtension;
/**
* Interface to be implemented when creating a drop listener on a drop target
diff --git a/server/src/main/java/com/vaadin/event/dnd/FileDropEvent.java b/server/src/main/java/com/vaadin/ui/dnd/event/FileDropEvent.java
index 7ad5f410bf..331b83c784 100644
--- a/server/src/main/java/com/vaadin/event/dnd/FileDropEvent.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/event/FileDropEvent.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.event.dnd;
+package com.vaadin.ui.dnd.event;
import java.util.Collection;
import java.util.List;
@@ -21,6 +21,7 @@ import java.util.List;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.Html5File;
+import com.vaadin.ui.dnd.FileDropHandler;
/**
* File drop event that contains the collection of files dropped on a file drop