Class DropEvent<T extends AbstractComponent>

    • Field Summary

      • Fields inherited from class java.util.EventObject

        source
    • Constructor Summary

      Constructors 
      Constructor Description
      DropEvent​(T target, java.util.Map<java.lang.String,​java.lang.String> data, com.vaadin.shared.ui.dnd.DropEffect dropEffect, DragSourceExtension<? extends AbstractComponent> dragSourceExtension, com.vaadin.shared.MouseEventDetails mouseEventDetails)
      Creates a server side drop event.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T getComponent()
      Returns the drop target component where the drop event occurred.
      java.util.Map<java.lang.String,​java.lang.String> getDataTransferData()
      Get all of the transfer data from the DataTransfer object.
      java.util.Optional<java.lang.String> getDataTransferData​(java.lang.String type)
      Get data from the DataTransfer object.
      java.lang.String getDataTransferText()
      Get data of any of the types "text", "Text" or "text/plain".
      java.util.Optional<java.lang.Object> getDragData()
      Gets the server side drag data.
      java.util.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.
      java.util.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.
      com.vaadin.shared.ui.dnd.DropEffect getDropEffect()
      Get the desired dropEffect for the drop event.
      com.vaadin.shared.MouseEventDetails getMouseEventDetails()
      Gets the mouse event details for the drop event.
      • Methods inherited from class java.util.EventObject

        getSource, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DropEvent

        public DropEvent​(T target,
                         java.util.Map<java.lang.String,​java.lang.String> data,
                         com.vaadin.shared.ui.dnd.DropEffect dropEffect,
                         DragSourceExtension<? extends AbstractComponent> dragSourceExtension,
                         com.vaadin.shared.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 java.util.Optional<java.lang.String> getDataTransferData​(java.lang.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 java.lang.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 java.util.Map<java.lang.String,​java.lang.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 com.vaadin.shared.ui.dnd.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 java.util.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 java.util.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 java.util.Optional<java.lang.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 com.vaadin.shared.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.