Class DragAndDropService
- java.lang.Object
-
- com.vaadin.server.DragAndDropService
-
- All Implemented Interfaces:
ClientConnector
,VariableOwner
,Connector
,Serializable
public class DragAndDropService extends Object implements VariableOwner, ClientConnector
- See Also:
- Serialized Form
-
-
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 DragAndDropService(VaadinSession session)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAttachListener(ClientConnector.AttachListener listener)
void
addDetachListener(ClientConnector.DetachListener listener)
void
attach()
Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).void
beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the client.void
changeVariables(Object source, Map<String,Object> variables)
Called when one or more variables handled by the implementing class are changed.void
detach()
Notifies the connector that it is detached from its VaadinSession.JsonObject
encodeState()
Called by the framework to encode the state to a JSONObject.String
getConnectorId()
Returns the id for this connector.ErrorHandler
getErrorHandler()
Gets the error handler for the connector.Collection<Extension>
getExtensions()
Get a read-only collection of all extensions attached to this connector.ClientConnector
getParent()
Gets the parent connector of this connector, ornull
if the connector is not attached to any parent.ServerRpcManager<?>
getRpcManager(String interfaceName)
Returns the RPC manager instance to use when receiving calls for an RPC interface.Class<? extends SharedState>
getStateType()
Returns the type of the shared state for this connectorUI
getUI()
Returns the UI this connector is attached toboolean
handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path)
Handle a request directed to this connector.boolean
isAttached()
Checks if the connector is attached to a VaadinSession.boolean
isConnectorEnabled()
Checks if the communicator is enabled.boolean
isEnabled()
Tests if the variable owner is enabled or not.boolean
isImmediate()
Tests if the variable owner is in immediate mode or not.void
markAsDirty()
Marks that this connector's state might have changed.void
markAsDirtyRecursive()
Causes this connector and all connectors below it to be marked as dirty.void
printJSONResponse(Writer outWriter)
void
removeAttachListener(ClientConnector.AttachListener listener)
void
removeDetachListener(ClientConnector.DetachListener listener)
void
removeExtension(Extension extension)
Remove an extension from this connector.void
requestRepaint()
Deprecated.void
requestRepaintAll()
Deprecated.List<ClientMethodInvocation>
retrievePendingRpcCalls()
Returns the list of pending server to client RPC calls and clears the list.void
setErrorHandler(ErrorHandler errorHandler)
Sets the error handler for the connector.
-
-
-
Constructor Detail
-
DragAndDropService
public DragAndDropService(VaadinSession session)
-
-
Method Detail
-
changeVariables
public void changeVariables(Object source, Map<String,Object> variables)
Description copied from interface:VariableOwner
Called when one or more variables handled by the implementing class are changed.- Specified by:
changeVariables
in interfaceVariableOwner
- Parameters:
source
- the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.
-
isEnabled
public boolean isEnabled()
Description copied from interface:VariableOwner
Tests if the variable owner is enabled or not. The terminal should not send any variable changes to disabled variable owners.
- Specified by:
isEnabled
in interfaceVariableOwner
- Returns:
true
if the variable owner is enabled,false
if not
-
isImmediate
public boolean isImmediate()
Description copied from interface:VariableOwner
Tests if the variable owner is in immediate mode or not. Being in immediate mode means that all variable changes are required to be sent back from the terminal immediately when they occur.
Note:
VariableOwner
does not include a set- method for the immediateness property. This is because not all VariableOwners wish to offer the functionality. Such VariableOwners are never in the immediate mode, thus they always returnfalse
inVariableOwner.isImmediate()
.- Specified by:
isImmediate
in interfaceVariableOwner
- Returns:
true
if the component is in immediate mode,false
if not.
-
printJSONResponse
public void printJSONResponse(Writer outWriter) throws IOException
- Throws:
IOException
-
getConnectorId
public String getConnectorId()
Description copied from interface:Connector
Returns the id for this connector. This is set by the framework and does not change during the lifetime of a connector.- Specified by:
getConnectorId
in interfaceConnector
- Returns:
- The id for the connector.
-
isConnectorEnabled
public boolean isConnectorEnabled()
Description copied from interface:ClientConnector
Checks if the communicator is enabled. An enabled communicator is allowed to receive messages from its counter-part.- Specified by:
isConnectorEnabled
in interfaceClientConnector
- Returns:
- true if the connector can receive messages, false otherwise
-
retrievePendingRpcCalls
public List<ClientMethodInvocation> retrievePendingRpcCalls()
Description copied from interface:ClientConnector
Returns the list of pending server to client RPC calls and clears the list.- Specified by:
retrievePendingRpcCalls
in interfaceClientConnector
- Returns:
- an unmodifiable ordered list of pending server to client method calls (not null)
-
getRpcManager
public ServerRpcManager<?> getRpcManager(String interfaceName)
Description copied from interface:ClientConnector
Returns the RPC manager instance to use when receiving calls for an RPC interface.- Specified by:
getRpcManager
in interfaceClientConnector
- Parameters:
interfaceName
- name of the interface for which the call was made- Returns:
- ServerRpcManager or null if none found for the interface
-
getStateType
public Class<? extends SharedState> getStateType()
Description copied from interface:ClientConnector
Returns the type of the shared state for this connector- Specified by:
getStateType
in interfaceClientConnector
- Returns:
- The type of the state. Must never return null.
-
requestRepaint
@Deprecated public void requestRepaint()
Deprecated.- Specified by:
requestRepaint
in interfaceClientConnector
-
markAsDirty
public void markAsDirty()
Description copied from interface:ClientConnector
Marks that this connector's state might have changed. When the framework is about to send new data to the client-side, it will runClientConnector.beforeClientResponse(boolean)
followed byClientConnector.encodeState()
for all connectors that are marked as dirty and send any updated state info to the client.- Specified by:
markAsDirty
in interfaceClientConnector
-
getParent
public ClientConnector getParent()
Description copied from interface:Connector
Gets the parent connector of this connector, ornull
if the connector is not attached to any parent.- Specified by:
getParent
in interfaceClientConnector
- Specified by:
getParent
in interfaceConnector
- Returns:
- the parent connector, or
null
if there is no parent.
-
requestRepaintAll
@Deprecated public void requestRepaintAll()
Deprecated.- Specified by:
requestRepaintAll
in interfaceClientConnector
-
markAsDirtyRecursive
public void markAsDirtyRecursive()
Description copied from interface:ClientConnector
Causes this connector and all connectors below it to be marked as dirty.This should only be used in special cases, e.g when the state of a descendant depends on the state of an ancestor.
- Specified by:
markAsDirtyRecursive
in interfaceClientConnector
- See Also:
ClientConnector.markAsDirty()
-
attach
public void attach()
Description copied from interface:ClientConnector
Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).The caller of this method is
#setParent(ClientConnector)
if the parent is itself already attached to the session. If not, the parent will call theClientConnector.attach()
for all its children when it is attached to the session. This method is always called before the connector's data is sent to the client-side for the first time.The attachment logic is implemented in
AbstractClientConnector
.- Specified by:
attach
in interfaceClientConnector
-
detach
public void detach()
Description copied from interface:ClientConnector
Notifies the connector that it is detached from its VaadinSession.The caller of this method is
#setParent(ClientConnector)
if the parent is in the session. When the parent is detached from the session it is its responsibility to callClientConnector.detach()
for each of its children.- Specified by:
detach
in interfaceClientConnector
-
getExtensions
public Collection<Extension> getExtensions()
Description copied from interface:ClientConnector
Get a read-only collection of all extensions attached to this connector.- Specified by:
getExtensions
in interfaceClientConnector
- Returns:
- a collection of extensions
-
removeExtension
public void removeExtension(Extension extension)
Description copied from interface:ClientConnector
Remove an extension from this connector.- Specified by:
removeExtension
in interfaceClientConnector
- Parameters:
extension
- the extension to remove.
-
getUI
public UI getUI()
Description copied from interface:ClientConnector
Returns the UI this connector is attached to- Specified by:
getUI
in interfaceClientConnector
- Returns:
- The UI this connector is attached to or null if it is not attached to any UI
-
beforeClientResponse
public void beforeClientResponse(boolean initial)
Description copied from interface:ClientConnector
Called before the shared state and RPC invocations are sent to the client. Gives the connector an opportunity to set computed/dynamic state values or to invoke last minute RPC methods depending on other component features.- Specified by:
beforeClientResponse
in interfaceClientConnector
- Parameters:
initial
-true
if the client-side connector will be created and initialized after this method has been invoked.false
if there is already an initialized client-side connector.
-
encodeState
public JsonObject encodeState()
Description copied from interface:ClientConnector
Called by the framework to encode the state to a JSONObject. This is typically done by calling the static methodLegacyCommunicationManager.encodeState(ClientConnector, SharedState)
.- Specified by:
encodeState
in interfaceClientConnector
- Returns:
- a JSON object with the encoded connector state
-
handleConnectorRequest
public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException
Description copied from interface:ClientConnector
Handle a request directed to this connector. This can be used by connectors to dynamically generate a response and it is also used internally when servingConnectorResource
s.Requests to
/APP/connector/[ui id]/[connector id]/
are routed to this method with the remaining part of the requested path available in the path parameter.NOTE that the session is not locked when this method is called. It is the responsibility of the connector to ensure that the session is locked while handling state or other session related data. For best performance the session should be unlocked before writing a large response to the client.
- Specified by:
handleConnectorRequest
in interfaceClientConnector
- Parameters:
request
- the request that should be handledresponse
- the response object to which the response should be writtenpath
- the requested relative path- Returns:
true
if the request has been handled,false
if no response has been written.- Throws:
IOException
- if there is a problem generating a response.
-
getErrorHandler
public ErrorHandler getErrorHandler()
Description copied from interface:ClientConnector
Gets the error handler for the connector. The error handler is dispatched whenever there is an error processing the data coming from the client to this connector.- Specified by:
getErrorHandler
in interfaceClientConnector
- Returns:
- The error handler or null if not set
-
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
Description copied from interface:ClientConnector
Sets the error handler for the connector. The error handler is dispatched whenever there is an error processing the data coming from the client for this connector.- Specified by:
setErrorHandler
in interfaceClientConnector
- Parameters:
errorHandler
- The error handler for this connector
-
addAttachListener
public void addAttachListener(ClientConnector.AttachListener listener)
- Specified by:
addAttachListener
in interfaceClientConnector
-
removeAttachListener
public void removeAttachListener(ClientConnector.AttachListener listener)
- Specified by:
removeAttachListener
in interfaceClientConnector
-
addDetachListener
public void addDetachListener(ClientConnector.DetachListener listener)
- Specified by:
addDetachListener
in interfaceClientConnector
-
removeDetachListener
public void removeDetachListener(ClientConnector.DetachListener listener)
- Specified by:
removeDetachListener
in interfaceClientConnector
-
isAttached
public boolean isAttached()
Description copied from interface:ClientConnector
Checks if the connector is attached to a VaadinSession.- Specified by:
isAttached
in interfaceClientConnector
- Returns:
- true if the connector is attached to a session, false otherwise
-
-