com.vaadin.client.connectors.grid.
Class GridDropTargetConnector
- java.lang.Object
-
- com.vaadin.client.ui.AbstractConnector
-
- com.vaadin.client.extensions.AbstractExtensionConnector
-
- com.vaadin.client.extensions.DropTargetExtensionConnector
-
- com.vaadin.client.connectors.grid.GridDropTargetConnector
-
All Implemented Interfaces:
com.google.gwt.event.shared.EventHandler
,StateChangeEvent.StateChangeHandler
,ServerConnector
,Connector
,Serializable
Direct Known Subclasses:
public class GridDropTargetConnector extends DropTargetExtensionConnector
Makes Grid an HTML5 drop target. This is the client side counterpart of
GridDropTarget
.Since:
8.1
Author:
Vaadin Ltd
See Also:
-
-
Field Summary
-
Fields inherited from class com.vaadin.client.extensions.DropTargetExtensionConnector
STYLE_SUFFIX_DRAG_BOTTOM, STYLE_SUFFIX_DRAG_CENTER, STYLE_SUFFIX_DRAG_TOP, STYLE_SUFFIX_DROPTARGET
-
-
Constructor Summary
Constructors Constructor Description GridDropTargetConnector()
-
Method Summary
All Methods Modifier and Type Method Description protected void
addDragOverStyle(com.google.gwt.dom.client.NativeEvent event)
Add class that indicates that the component is a target while data is being dragged over it.
protected void
extend(ServerConnector target)
Called when the extension is attached to its parent.
protected DropLocation
getDropLocation(com.google.gwt.dom.client.Element target, com.google.gwt.dom.client.NativeEvent event)
Returns the location of the event within the row.
protected com.google.gwt.dom.client.Element
getDropTargetElement()
Finds the drop target element within the widget.
protected elemental.json.JsonObject
getRowData(com.google.gwt.dom.client.TableRowElement row)
Get the row data as json object for the given row.
GridDropTargetState
getState()
Returns the shared state object for this connector.
protected com.google.gwt.dom.client.Element
getTargetElement(com.google.gwt.dom.client.Element source)
Gets the target element for a dragover or drop event.
protected boolean
isDropAllowedByCriteriaScript(com.google.gwt.dom.client.NativeEvent event)
Checks if a criteria script exists and, if yes, executes it.
protected boolean
isDroppingOnRowsPossible()
Inspects whether the current drop would happen on the whole grid instead of specific row as the drop target.
protected void
onDragEnter(elemental.events.Event event)
Event handler for the
dragenter
event.protected void
removeDragOverStyle(com.google.gwt.dom.client.NativeEvent event)
Remove the drag over indicator class name from the target element.
protected void
sendDropEventToServer(List<String> types, Map<String,String> data, String dropEffect, com.google.gwt.dom.client.NativeEvent dropEvent)
Initiates a server RPC for the drop event.
-
Methods inherited from class com.vaadin.client.extensions.DropTargetExtensionConnector
addDropTargetStyle, onDragLeave, onDragOver, onDrop, onUnregister, removeDropTargetStyle
-
Methods inherited from class com.vaadin.client.extensions.AbstractExtensionConnector
setParent
-
Methods inherited from class com.vaadin.client.ui.AbstractConnector
addStateChangeHandler, addStateChangeHandler, createState, doInit, ensureHandlerManager, fireEvent, forceStateChange, getChildren, getConnection, getConnectorId, getParent, getResourceUrl, getRpcImplementations, getRpcProxy, getStateType, getTag, hasEventListener, init, isEnabled, onStateChanged, registerRpc, removeStateChangeHandler, removeStateChangeHandler, setChildren, setTag, unregisterRpc, updateEnabledState
-
-
-
-
Method Detail
-
extend
protected void extend(ServerConnector target)
Description copied from class:
AbstractExtensionConnector
Called when the extension is attached to its parent. This method is only called once as an extension cannot be moved from one parent to another.
Overrides:
extend
in classDropTargetExtensionConnector
Parameters:
target
- The connector this extension extends
-
isDropAllowedByCriteriaScript
protected boolean isDropAllowedByCriteriaScript(com.google.gwt.dom.client.NativeEvent event)
Description copied from class:
DropTargetExtensionConnector
Checks if a criteria script exists and, if yes, executes it. This method is protected, so subclasses as e.g. GridDropTargetConnector can override it to add additional script parameters.
Overrides:
isDropAllowedByCriteriaScript
in classDropTargetExtensionConnector
Parameters:
event
- browser event (dragEnter, dragOver, drop) that should be evaluated by the criteria scriptReturns:
true
if no script was given or if the script returned true,false
otherwise.
-
isDroppingOnRowsPossible
protected boolean isDroppingOnRowsPossible()
Inspects whether the current drop would happen on the whole grid instead of specific row as the drop target. This is based on used drop mode, whether dropping on sorted grid rows is allowed (determined on server side and automatically updated to drop mode) and whether the grid is empty.
Returns:
true
when the drop target is the whole grid, orfalse
when it is one of the rows
-
sendDropEventToServer
protected void sendDropEventToServer(List<String> types, Map<String,String> data, String dropEffect, com.google.gwt.dom.client.NativeEvent dropEvent)
Description copied from class:
DropTargetExtensionConnector
Initiates a server RPC for the drop event.
Overrides:
sendDropEventToServer
in classDropTargetExtensionConnector
Parameters:
types
- List of data types fromDataTransfer.types
object.data
- Map containing all types and corresponding data from theDataTransfer
object.dropEffect
- The desired drop effect.
-
getRowData
protected elemental.json.JsonObject getRowData(com.google.gwt.dom.client.TableRowElement row)
Get the row data as json object for the given row.
Parameters:
row
- table row elementReturns:
row data as json object for the given row
-
getDropLocation
protected DropLocation getDropLocation(com.google.gwt.dom.client.Element target, com.google.gwt.dom.client.NativeEvent event)
Returns the location of the event within the row.
Parameters:
target
- drop target elementevent
- drop eventReturns:
the drop location to use
-
onDragEnter
protected void onDragEnter(elemental.events.Event event)
Description copied from class:
DropTargetExtensionConnector
Event handler for the
dragenter
event.Override this method in case custom handling for the dragstart event is required. If the drop is allowed, the event should prevent default.
Overrides:
onDragEnter
in classDropTargetExtensionConnector
Parameters:
event
- browser event to be handled
-
addDragOverStyle
protected void addDragOverStyle(com.google.gwt.dom.client.NativeEvent event)
Description copied from class:
DropTargetExtensionConnector
Add class that indicates that the component is a target while data is being dragged over it.
This is triggered on
dragenter
anddragover
events pending if the drop is possible. The drop is possible if the drop effect for the target and source do match and the drop criteria script evaluates to true or is not set.Overrides:
addDragOverStyle
in classDropTargetExtensionConnector
Parameters:
event
- the dragenter or dragover event that triggered the indication.
-
removeDragOverStyle
protected void removeDragOverStyle(com.google.gwt.dom.client.NativeEvent event)
Description copied from class:
DropTargetExtensionConnector
Remove the drag over indicator class name from the target element.
This is triggered on
drop
,dragleave
anddragover
events pending on whether the drop has happened or if it is not possible. The drop is not possible if the drop effect for the source and target don't match or if there is a drop criteria script that evaluates to false.Overrides:
removeDragOverStyle
in classDropTargetExtensionConnector
Parameters:
event
- the event that triggered the removal of the indicator
-
getTargetElement
protected com.google.gwt.dom.client.Element getTargetElement(com.google.gwt.dom.client.Element source)
Gets the target element for a dragover or drop event.
Parameters:
source
- the event target of the eventReturns:
the element that should be handled as the target of the event
-
getDropTargetElement
protected com.google.gwt.dom.client.Element getDropTargetElement()
Description copied from class:
DropTargetExtensionConnector
Finds the drop target element within the widget. By default, returns the topmost element.
Overrides:
getDropTargetElement
in classDropTargetExtensionConnector
Returns:
the drop target element in the parent widget.
-
getState
public GridDropTargetState getState()
Description copied from class:
AbstractConnector
Returns the shared state object for this connector. Override this method to define the shared state type for your connector.
Specified by:
getState
in interfaceServerConnector
Overrides:
getState
in classDropTargetExtensionConnector
Returns:
the current shared state (never null)
-
-