com.vaadin.ui.dnd.event.
Class DropEvent<T extends AbstractComponent>
- java.lang.Object
-
- java.util.EventObject
-
- com.vaadin.event.ConnectorEvent
-
- com.vaadin.ui.Component.Event
-
- com.vaadin.ui.dnd.event.DropEvent<T>
-
Type Parameters:
T
- Type of the drop target component.All Implemented Interfaces:
Direct Known Subclasses:
public class DropEvent<T extends AbstractComponent> extends Component.Event
Server side drop event. Fired when an HTML5 drop happens.
Since:
8.1
Author:
Vaadin Ltd
See Also:
DropTargetExtension.addDropListener(DropListener)
, Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description DropEvent(T target, Map<String,String> data, DropEffect dropEffect, DragSourceExtension<? extends AbstractComponent> dragSourceExtension, MouseEventDetails mouseEventDetails)
Creates a server side drop event.
-
Method Summary
All Methods Modifier and Type Method Description T
getComponent()
Returns the drop target component where the drop event occurred.
Map<String,String>
getDataTransferData()
Get all of the transfer data from the
DataTransfer
object.Optional<String>
getDataTransferData(String type)
Get data from the
DataTransfer
object.String
getDataTransferText()
Get data of any of the types
"text"
,"Text"
or"text/plain"
.Optional<Object>
getDragData()
Gets the server side drag data.
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.
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.
DropEffect
getDropEffect()
Get the desired dropEffect for the drop event.
MouseEventDetails
getMouseEventDetails()
Gets the mouse event details for the drop event.
-
Methods inherited from class com.vaadin.event.ConnectorEvent
getConnector
-
Methods inherited from class java.util.EventObject
getSource, toString
-
-
-
-
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 theDataTransfer
object.dropEffect
- the desired drop effectdragSourceExtension
- 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
ortext/uri-list
.Returns:
Optional data for the given format if exists in the
DataTransfer
, otherwiseOptional.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"
, ornull
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:
-
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 classComponent.Event
Returns:
Component on which a drag source was dropped.
-
-