public class StateTree extends Object
| Constructor and Description |
|---|
StateTree(Registry registry)
Creates a new instance connected to the given registry.
|
| Modifier and Type | Method and Description |
|---|---|
StateNode |
getNode(int id)
Finds the node with the given id.
|
Registry |
getRegistry()
Gets the
Registry that this state tree belongs to. |
StateNode |
getRootNode()
Gets the root node of this tree.
|
boolean |
isActive(StateNode node)
Checks whether the
node is active. |
boolean |
isUpdateInProgress()
Returns whether this tree is currently being updated by
TreeChangeProcessor.processChanges(StateTree, JsonArray). |
boolean |
isVisible(StateNode node)
Returns the visibility state of the
node. |
void |
prepareForResync()
Unregisters all nodes except root from this tree, and clears the root's
features.
|
void |
registerNode(StateNode node)
Registers a node with this tree.
|
void |
sendEventToServer(StateNode node,
String eventType,
elemental.json.JsonObject eventData)
Sends an event to the server.
|
void |
sendExistingElementAttachToServer(StateNode parent,
int requestedId,
int assignedId,
String tagName,
int index)
Sends a data for attach existing element server side callback.
|
void |
sendExistingElementWithIdAttachToServer(StateNode parent,
int requestedId,
int assignedId,
String id)
Sends a data for attach existing element with id server side callback.
|
void |
sendNodePropertySyncToServer(MapProperty property)
Sends a map property sync to the server.
|
void |
sendTemplateEventToServer(StateNode node,
String methodName,
JsArray<?> argsArray,
int promiseId)
Sends a request to call server side method with
methodName using
argsArray as argument values. |
void |
setUpdateInProgress(boolean updateInProgress)
Mark this tree as being updated.
|
void |
unregisterNode(StateNode node)
Unregisters a node from this tree.
|
public StateTree(Registry registry)
registry - the global registrypublic void setUpdateInProgress(boolean updateInProgress)
updateInProgress - true if the tree is being updated,
false if notisUpdateInProgress()public boolean isUpdateInProgress()
TreeChangeProcessor.processChanges(StateTree, JsonArray).true if being updated, false if notpublic final void registerNode(StateNode node)
node - the node to registerpublic void unregisterNode(StateNode node)
node - the node to unregisterpublic void prepareForResync()
public StateNode getNode(int id)
id - the idnull if no such node
is registered.public StateNode getRootNode()
public void sendEventToServer(StateNode node, String eventType, elemental.json.JsonObject eventData)
node - the node that listened to the eventeventType - the type of eventeventData - extra data associated with the eventpublic void sendNodePropertySyncToServer(MapProperty property)
property - the property that should have its value synced to the server,
not nullpublic void sendTemplateEventToServer(StateNode node, String methodName, JsArray<?> argsArray, int promiseId)
methodName using
argsArray as argument values.
In cases when the state tree has been changed and we receive a delayed or deferred template event the event is just ignored.
node - the node referring to the server side instance containing the
methodmethodName - the method nameargsArray - the arguments array for the methodpromiseId - the promise id to use for getting the result back, or -1 if no
result is expectedpublic void sendExistingElementAttachToServer(StateNode parent, int requestedId, int assignedId, String tagName, int index)
parent - parent of the node to attachrequestedId - originally requested id of a server side nodeassignedId - identifier which should be used on the server side for the
element (instead of requestedId)tagName - the requested tagNameindex - the index of the element on the server sidepublic void sendExistingElementWithIdAttachToServer(StateNode parent, int requestedId, int assignedId, String id)
parent - parent of the node to attachrequestedId - originally requested id of a server side nodeassignedId - identifier which should be used on the server side for the
element (instead of requestedId)id - id of requested elementpublic Registry getRegistry()
Registry that this state tree belongs to.nullpublic boolean isVisible(StateNode node)
node.node - the node whose visibility is testedtrue is the node is visible, false otherwisepublic boolean isActive(StateNode node)
node is active.
The node is active if it's visible and all its ancestors are visible.
node - the node whose activity is testedtrue is the node is active, false otherwiseCopyright © 2000–2022 Vaadin Ltd. All rights reserved.