com.vaadin.ui.dnd.event.

Class DropEvent<T extends AbstractComponent>

    • Constructor Detail

      • DropEvent

        public DropEvent​(T target,
                         Map<String,​String> data,
                         DropEffect dropEffect,
                         DragSourceExtension<? extends AbstractComponent> dragSourceExtension,
                         MouseEventDetails mouseEventDetails)

        Creates a server side drop event.

        Parameters:

        target - Component that received the drop.

        data - Map containing all types and corresponding data from the DataTransfer object.

        dropEffect - the desired drop effect

        dragSourceExtension - Drag source extension of the component that initiated the drop event.

        mouseEventDetails - Mouse event details object containing information about the drop event

    • Method Detail

      • getDataTransferData

        public Optional<String> getDataTransferData​(String type)

        Get data from the DataTransfer object.

        Parameters:

        type - Data format, e.g. text/plain or text/uri-list.

        Returns:

        Optional data for the given format if exists in the DataTransfer, otherwise Optional.empty().

      • getDataTransferText

        public String getDataTransferText()

        Get data of any of the types "text", "Text" or "text/plain".

        IE 11 transfers data dropped from the desktop as "Text" while most other browsers transfer textual data as "text/plain".

        Returns:

        First existing data of types in order "text", "Text" or "text/plain", or null if none of them exist.

      • getDataTransferData

        public Map<String,​String> getDataTransferData()

        Get all of the transfer data from the DataTransfer object. The data can be iterated to find the most relevant data as it preserves the order in which the data was set to the drag source element.

        Returns:

        Map of type/data pairs, containing all the data from the DataTransfer object.

      • getDropEffect

        public DropEffect getDropEffect()

        Get the desired dropEffect for the drop event.

        NOTE: Currently you cannot trust this to work on all browsers! https://github.com/vaadin/framework/issues/9247 For Chrome and IE11 it is never set and always returns DropEffect.NONE even though the drop succeeded!

        Returns:

        the drop effect

      • getDragSourceComponent

        public Optional<AbstractComponent> getDragSourceComponent()

        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.

        Returns:

        Drag source component or an empty optional.

      • getDragSourceExtension

        public Optional<DragSourceExtension<? extends AbstractComponent>> getDragSourceExtension()

        Returns the extension of the drag source component if the drag originated from a component in the same UI as the drop target component, or an empty optional.

        Returns:

        Drag source extension or an empty optional

      • getDragData

        public Optional<Object> getDragData()

        Gets the server side drag data. This data can be set during the drag start event on the server side and can be used to transfer data between drag source and drop target when they are in the same UI.

        Returns:

        Optional server side drag data if set and the drag source and the drop target are in the same UI, otherwise empty Optional.

        See Also:

        DragSourceExtension.setDragData(Object)

      • getMouseEventDetails

        public MouseEventDetails getMouseEventDetails()

        Gets the mouse event details for the drop event.

        Returns:

        Mouse event details object containing information about the drop event.

      • getComponent

        public T getComponent()

        Returns the drop target component where the drop event occurred.

        Overrides:

        getComponent in class Component.Event

        Returns:

        Component on which a drag source was dropped.