diff options
author | Adam Wagner <wbadam@users.noreply.github.com> | 2017-03-24 11:28:58 +0200 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-03-24 11:28:58 +0200 |
commit | e905e2bb8057d19128bc5bd052d73ee8f29687a8 (patch) | |
tree | 54b0d8a210bc6c4b9fcdb6a8f676e63495b3f55d /client | |
parent | ff3c31b8cb3ba65230edede8edcdef9aa613d178 (diff) | |
download | vaadin-framework-e905e2bb8057d19128bc5bd052d73ee8f29687a8.tar.gz vaadin-framework-e905e2bb8057d19128bc5bd052d73ee8f29687a8.zip |
Clean DropEvent and DragEndEvent properties (#8925)
* Add dropEffect parameter to DragEndEvent (#8895)
* Remove drop effect from drop event (#8895)
* Make sure that drop effect is not null
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java | 14 | ||||
-rw-r--r-- | client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java | 3 |
2 files changed, 14 insertions, 3 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 da14466666..3094042826 100644 --- a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java @@ -25,6 +25,7 @@ import com.vaadin.event.dnd.DragSourceExtension; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.dnd.DragSourceRpc; import com.vaadin.shared.ui.dnd.DragSourceState; +import com.vaadin.shared.ui.dnd.DropEffect; import elemental.events.Event; import elemental.events.EventListener; @@ -113,12 +114,19 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector { * event occurs. * * @param event + * browser event to be handled */ protected void onDragEnd(Event event) { // Initiate server start dragend event when there is a DragEndListener // attached on the server side if (hasEventListener(DragSourceState.EVENT_DRAGEND)) { - getRpcProxy(DragSourceRpc.class).dragEnd(); + String dropEffect = getDropEffect( + ((NativeEvent) event).getDataTransfer()); + + assert dropEffect != null : "Drop effect should never be null"; + + getRpcProxy(DragSourceRpc.class) + .dragEnd(DropEffect.valueOf(dropEffect.toUpperCase())); } } @@ -137,6 +145,10 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector { dataTransfer.effectAllowed = effectAllowed; }-*/; + private native String getDropEffect(DataTransfer dataTransfer)/*-{ + return dataTransfer.dropEffect; + }-*/; + @Override public DragSourceState getState() { return (DragSourceState) super.getState(); 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 a1ac662987..5f8ca243c7 100644 --- a/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java @@ -182,8 +182,7 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector { String dataTransferText = nativeEvent.getDataTransfer().getData( DragSourceState.DATA_TYPE_TEXT); - getRpcProxy(DropTargetRpc.class) - .drop(dataTransferText, getState().dropEffect); + getRpcProxy(DropTargetRpc.class).drop(dataTransferText); } removeTargetIndicator(getDropTargetElement()); |