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:
TreeGridDropTargetConnector
public class GridDropTargetConnector extends DropTargetExtensionConnector
Makes Grid an HTML5 drop target. This is the client side counterpart ofGridDropTarget.- Since:
- 8.1
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
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 Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddDragOverStyle(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 voidextend(ServerConnector target)Called when the extension is attached to its parent.protected DropLocationgetDropLocation(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.ElementgetDropTargetElement()Finds the drop target element within the widget.protected elemental.json.JsonObjectgetRowData(com.google.gwt.dom.client.TableRowElement row)Get the row data as json object for the given row.GridDropTargetStategetState()Returns the shared state object for this connector.protected com.google.gwt.dom.client.ElementgetTargetElement(com.google.gwt.dom.client.Element source)Gets the target element for a dragover or drop event.protected booleanisDropAllowedByCriteriaScript(com.google.gwt.dom.client.NativeEvent event)Checks if a criteria script exists and, if yes, executes it.protected booleanisDroppingOnRowsPossible()Inspects whether the current drop would happen on the whole grid instead of specific row as the drop target.protected voidonDragEnter(elemental.events.Event event)Event handler for thedragenterevent.protected voidremoveDragOverStyle(com.google.gwt.dom.client.NativeEvent event)Remove the drag over indicator class name from the target element.protected voidsendDropEventToServer(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:AbstractExtensionConnectorCalled 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:
extendin classDropTargetExtensionConnector- Parameters:
target- The connector this extension extends
-
isDropAllowedByCriteriaScript
protected boolean isDropAllowedByCriteriaScript(com.google.gwt.dom.client.NativeEvent event)
Description copied from class:DropTargetExtensionConnectorChecks 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:
isDropAllowedByCriteriaScriptin classDropTargetExtensionConnector- Parameters:
event- browser event (dragEnter, dragOver, drop) that should be evaluated by the criteria script- Returns:
trueif no script was given or if the script returned true,falseotherwise.
-
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:
truewhen the drop target is the whole grid, orfalsewhen 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:DropTargetExtensionConnectorInitiates a server RPC for the drop event.- Overrides:
sendDropEventToServerin classDropTargetExtensionConnector- Parameters:
types- List of data types fromDataTransfer.typesobject.data- Map containing all types and corresponding data from theDataTransferobject.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 element- Returns:
- 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 event- Returns:
- the drop location to use
-
onDragEnter
protected void onDragEnter(elemental.events.Event event)
Description copied from class:DropTargetExtensionConnectorEvent handler for thedragenterevent.Override this method in case custom handling for the dragstart event is required. If the drop is allowed, the event should prevent default.
- Overrides:
onDragEnterin classDropTargetExtensionConnector- Parameters:
event- browser event to be handled
-
addDragOverStyle
protected void addDragOverStyle(com.google.gwt.dom.client.NativeEvent event)
Description copied from class:DropTargetExtensionConnectorAdd class that indicates that the component is a target while data is being dragged over it.This is triggered on
dragenteranddragoverevents 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:
addDragOverStylein 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:DropTargetExtensionConnectorRemove the drag over indicator class name from the target element.This is triggered on
drop,dragleaveanddragoverevents 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:
removeDragOverStylein 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 event- Returns:
- 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:DropTargetExtensionConnectorFinds the drop target element within the widget. By default, returns the topmost element.- Overrides:
getDropTargetElementin classDropTargetExtensionConnector- Returns:
- the drop target element in the parent widget.
-
getState
public GridDropTargetState getState()
Description copied from class:AbstractConnectorReturns the shared state object for this connector. Override this method to define the shared state type for your connector.- Specified by:
getStatein interfaceServerConnector- Overrides:
getStatein classDropTargetExtensionConnector- Returns:
- the current shared state (never null)
-
-