public class DragAndDropService extends Object implements VariableOwner, ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Constructor and Description |
---|
DragAndDropService(VaadinSession session) |
Modifier and Type | Method and 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, or
null 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 connector
|
UI |
getUI()
Returns the UI this connector is attached to
|
boolean |
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.
|
public DragAndDropService(VaadinSession session)
public void changeVariables(Object source, Map<String,Object> variables)
VariableOwner
changeVariables
in interface VariableOwner
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.public boolean isEnabled()
VariableOwner
Tests if the variable owner is enabled or not. The terminal should not send any variable changes to disabled variable owners.
isEnabled
in interface VariableOwner
true
if the variable owner is enabled,
false
if notpublic boolean isImmediate()
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 return false
in VariableOwner.isImmediate()
.
isImmediate
in interface VariableOwner
true
if the component is in immediate mode,
false
if not.public void printJSONResponse(Writer outWriter) throws IOException
IOException
public String getConnectorId()
Connector
getConnectorId
in interface Connector
public boolean isConnectorEnabled()
ClientConnector
isConnectorEnabled
in interface ClientConnector
public List<ClientMethodInvocation> retrievePendingRpcCalls()
ClientConnector
retrievePendingRpcCalls
in interface ClientConnector
public ServerRpcManager<?> getRpcManager(String interfaceName)
ClientConnector
getRpcManager
in interface ClientConnector
interfaceName
- name of the interface for which the call was madepublic Class<? extends SharedState> getStateType()
ClientConnector
getStateType
in interface ClientConnector
@Deprecated public void requestRepaint()
requestRepaint
in interface ClientConnector
public void markAsDirty()
ClientConnector
ClientConnector.beforeClientResponse(boolean)
followed by ClientConnector.encodeState()
for all connectors that are marked as dirty and send any updated state
info to the client.markAsDirty
in interface ClientConnector
public ClientConnector getParent()
Connector
null
if the
connector is not attached to any parent.getParent
in interface ClientConnector
getParent
in interface Connector
null
if there is no parent.@Deprecated public void requestRepaintAll()
requestRepaintAll
in interface ClientConnector
public void markAsDirtyRecursive()
ClientConnector
This should only be used in special cases, e.g when the state of a descendant depends on the state of an ancestor.
markAsDirtyRecursive
in interface ClientConnector
ClientConnector.markAsDirty()
public void attach()
ClientConnector
The caller of this method is #setParent(ClientConnector)
if the
parent is itself already attached to the session. If not, the parent will
call the ClientConnector.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
.
attach
in interface ClientConnector
public void detach()
ClientConnector
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 call ClientConnector.detach()
for each of its children.
detach
in interface ClientConnector
public Collection<Extension> getExtensions()
ClientConnector
getExtensions
in interface ClientConnector
public void removeExtension(Extension extension)
ClientConnector
removeExtension
in interface ClientConnector
extension
- the extension to remove.public UI getUI()
ClientConnector
getUI
in interface ClientConnector
public void beforeClientResponse(boolean initial)
ClientConnector
beforeClientResponse
in interface ClientConnector
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.public JsonObject encodeState()
ClientConnector
LegacyCommunicationManager.encodeState(ClientConnector, SharedState)
.encodeState
in interface ClientConnector
public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException
ClientConnector
ConnectorResource
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.
handleConnectorRequest
in interface ClientConnector
request
- the request that should be handledresponse
- the response object to which the response should be writtenpath
- the requested relative pathtrue
if the request has been handled,
false
if no response has been written.IOException
- if there is a problem generating a response.public ErrorHandler getErrorHandler()
ClientConnector
getErrorHandler
in interface ClientConnector
public void setErrorHandler(ErrorHandler errorHandler)
ClientConnector
setErrorHandler
in interface ClientConnector
errorHandler
- The error handler for this connectorpublic void addAttachListener(ClientConnector.AttachListener listener)
addAttachListener
in interface ClientConnector
public void removeAttachListener(ClientConnector.AttachListener listener)
removeAttachListener
in interface ClientConnector
public void addDetachListener(ClientConnector.DetachListener listener)
addDetachListener
in interface ClientConnector
public void removeDetachListener(ClientConnector.DetachListener listener)
removeDetachListener
in interface ClientConnector
public boolean isAttached()
ClientConnector
isAttached
in interface ClientConnector
Copyright © 2019 Vaadin Ltd. All rights reserved.