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 /server | |
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 'server')
4 files changed, 17 insertions, 30 deletions
diff --git a/server/src/main/java/com/vaadin/event/dnd/DragEndEvent.java b/server/src/main/java/com/vaadin/event/dnd/DragEndEvent.java index f1176e1880..57f111e848 100644 --- a/server/src/main/java/com/vaadin/event/dnd/DragEndEvent.java +++ b/server/src/main/java/com/vaadin/event/dnd/DragEndEvent.java @@ -15,7 +15,7 @@ */ package com.vaadin.event.dnd; -import com.vaadin.shared.ui.dnd.EffectAllowed; +import com.vaadin.shared.ui.dnd.DropEffect; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Component; @@ -30,7 +30,7 @@ import com.vaadin.ui.Component; */ public class DragEndEvent<T extends AbstractComponent> extends Component.Event { private final String dataTransferText; - private final EffectAllowed effectAllowed; + private final DropEffect dropEffect; /** * Creates a server side dragend event. @@ -40,16 +40,16 @@ public class DragEndEvent<T extends AbstractComponent> extends Component.Event { * @param dataTransferText * Data of type {@code "text"} from the {@code DataTransfer} * object. - * @param effectAllowed - * Allowed effects from {@code DataTransfer.effectAllowed} object. + * @param dropEffect + * Drop effect from {@code DataTransfer.dropEffect} object. */ public DragEndEvent(T source, String dataTransferText, - EffectAllowed effectAllowed) { + DropEffect dropEffect) { super(source); this.dataTransferText = dataTransferText; - this.effectAllowed = effectAllowed; + this.dropEffect = dropEffect; } /** @@ -64,12 +64,13 @@ public class DragEndEvent<T extends AbstractComponent> extends Component.Event { } /** - * Returns the {@code effectAllowed} parameter of this event. + * Get drop effect of the dragend event. * - * @return This event's {@code effectAllowed} parameter. + * @return The {@code DataTransfer.dropEffect} parameter of the client side + * dragend event. */ - public EffectAllowed getEffectAllowed() { - return effectAllowed; + public DropEffect getDropEffect() { + return dropEffect; } /** diff --git a/server/src/main/java/com/vaadin/event/dnd/DragSourceExtension.java b/server/src/main/java/com/vaadin/event/dnd/DragSourceExtension.java index 6a6a8a8c64..bce643ffdb 100644 --- a/server/src/main/java/com/vaadin/event/dnd/DragSourceExtension.java +++ b/server/src/main/java/com/vaadin/event/dnd/DragSourceExtension.java @@ -21,6 +21,7 @@ import com.vaadin.server.AbstractExtension; import com.vaadin.shared.Registration; import com.vaadin.shared.ui.dnd.DragSourceRpc; 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; @@ -62,10 +63,9 @@ public class DragSourceExtension<T extends AbstractComponent> extends } @Override - public void dragEnd() { + public void dragEnd(DropEffect dropEffect) { DragEndEvent<T> event = new DragEndEvent<>(target, - getState(false).dataTransferText, - getState(false).effectAllowed); + getState(false).dataTransferText, dropEffect); fireEvent(event); } }); diff --git a/server/src/main/java/com/vaadin/event/dnd/DropEvent.java b/server/src/main/java/com/vaadin/event/dnd/DropEvent.java index c2b4943d0f..932f5577a5 100644 --- a/server/src/main/java/com/vaadin/event/dnd/DropEvent.java +++ b/server/src/main/java/com/vaadin/event/dnd/DropEvent.java @@ -32,7 +32,6 @@ import com.vaadin.ui.Component; */ public class DropEvent<T extends AbstractComponent> extends Component.Event { private final String dataTransferText; - private final DropEffect dropEffect; private final DragSourceExtension<? extends AbstractComponent> dragSourceExtension; private final AbstractComponent dragSource; @@ -44,20 +43,16 @@ public class DropEvent<T extends AbstractComponent> extends Component.Event { * @param dataTransferText * Data of type {@code "text"} from the {@code DataTransfer} * object. - * @param dropEffect - * Drop effect from {@code DataTransfer.dropEffect} object. * @param dragSourceExtension * Drag source extension of the component that initiated the drop * event. */ - public DropEvent(T target, String dataTransferText, DropEffect dropEffect, + public DropEvent(T target, String dataTransferText, DragSourceExtension<? extends AbstractComponent> dragSourceExtension) { super(target); this.dataTransferText = dataTransferText; - this.dropEffect = dropEffect; - this.dragSourceExtension = dragSourceExtension; this.dragSource = Optional.ofNullable(dragSourceExtension) .map(DragSourceExtension::getParent).orElse(null); @@ -75,15 +70,6 @@ public class DropEvent<T extends AbstractComponent> extends Component.Event { } /** - * Get drop effect set for the current drop target. - * - * @return {@code dropEffect} parameter set for the current drop target. - */ - public DropEffect getDropEffect() { - return dropEffect; - } - - /** * Returns the drag source component if the drag originated from a * component in the same UI as the drop target component, or an empty * optional. diff --git a/server/src/main/java/com/vaadin/event/dnd/DropTargetExtension.java b/server/src/main/java/com/vaadin/event/dnd/DropTargetExtension.java index 2df43027a1..c4a5f981ff 100644 --- a/server/src/main/java/com/vaadin/event/dnd/DropTargetExtension.java +++ b/server/src/main/java/com/vaadin/event/dnd/DropTargetExtension.java @@ -43,9 +43,9 @@ public class DropTargetExtension<T extends AbstractComponent> extends * Component to be extended. */ public DropTargetExtension(T target) { - registerRpc((DropTargetRpc) (dataTransferText, dropEffect) -> { + registerRpc((DropTargetRpc) dataTransferText -> { DropEvent<T> event = new DropEvent<>(target, dataTransferText, - dropEffect, getUI().getActiveDragSource()); + getUI().getActiveDragSource()); fireEvent(event); }); |