com.vaadin.ui.dnd.
Class FileDropTarget<T extends AbstractComponent>
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.server.AbstractExtension
-
- com.vaadin.ui.dnd.DropTargetExtension<T>
-
- com.vaadin.ui.dnd.FileDropTarget<T>
-
Type Parameters:
T
- Type of the component to be extended.All Implemented Interfaces:
MethodEventSource
,ClientConnector
,Extension
,Connector
,Serializable
public class FileDropTarget<T extends AbstractComponent> extends DropTargetExtension<T>
Extension to add drop target functionality to a widget for accepting and uploading files.
Dropped files are handled in the
FileDropHandler
given in the constructor. The file details are first sent to the handler, which can then decide which files to upload to server by setting aStreamVariable
withHtml5File.setStreamVariable(StreamVariable)
.Since:
8.1
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
-
Constructor Summary
Constructors Constructor Description FileDropTarget(T target, FileDropHandler<T> fileDropHandler)
Extends
target
component and makes it a file drop target.
-
Method Summary
All Methods Modifier and Type Method Description T
getParent()
Returns the component this extension is attached to.
protected FileDropTargetState
getState()
Returns the shared state for this connector.
protected FileDropTargetState
getState(boolean markAsDirty)
Returns the shared state for this connector.
protected void
onDrop(Map<String,FileParameters> fileParams)
Invoked when a file or files have been dropped on client side.
-
Methods inherited from class com.vaadin.ui.dnd.DropTargetExtension
addDropListener, attach, getDropCriteriaScript, getDropEffect, onDrop, registerDropTargetRpc, setDropCriteria, setDropCriteriaScript, setDropCriterion, setDropCriterion, setDropCriterion, setDropEffect
-
Methods inherited from class com.vaadin.server.AbstractExtension
extend, getSupportedParentType, remove, setParent
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, beforeClientResponse, createState, detach, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
-
-
-
Constructor Detail
-
FileDropTarget
public FileDropTarget(T target, FileDropHandler<T> fileDropHandler)
Extends
target
component and makes it a file drop target. A file drop handler needs to be added to handle the file drop event.Parameters:
target
- Component to be extended.fileDropHandler
- File drop handler that handles the file drop event.See Also:
-
-
Method Detail
-
onDrop
protected void onDrop(Map<String,FileParameters> fileParams)
Invoked when a file or files have been dropped on client side. Fires the
FileDropEvent
.Parameters:
fileParams
- map from file ids to actual file details
-
getState
protected FileDropTargetState getState()
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector. The shared state object is shared between the server connector and the client connector. Changes are only communicated from the server to the client and not in the other direction.
As a side effect, marks the connector dirty so any changes done to the state will be sent to the client. Use
getState(false)
to avoid marking the connector as dirty.Overrides:
getState
in classDropTargetExtension<T extends AbstractComponent>
Returns:
The shared state for this connector. Never null.
-
getState
protected FileDropTargetState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classDropTargetExtension<T extends AbstractComponent>
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
getParent
public T getParent()
Returns the component this extension is attached to.
Specified by:
getParent
in interfaceClientConnector
Specified by:
getParent
in interfaceConnector
Overrides:
getParent
in classDropTargetExtension<T extends AbstractComponent>
Returns:
Extended component.
-
-