public interface ElementStateProvider extends Serializable
Modifier and Type | Method and Description |
---|---|
DomListenerRegistration |
addEventListener(StateNode node,
String eventType,
DomEventListener listener)
Adds a DOM event listener.
|
Registration |
addPropertyChangeListener(StateNode node,
String name,
PropertyChangeListener listener)
Adds a property change listener.
|
void |
addSynchronizedProperty(StateNode node,
String property,
DisabledUpdateMode mode)
Makes the property synchronized from the client side to the server.
|
void |
appendVirtualChild(StateNode node,
Element child,
String type,
String payload)
Append the given element as a virtual child.
|
void |
attachExistingElement(StateNode node,
String tagName,
Element previousSibling,
ChildElementConsumer callback)
Attaches a child element with the given
tagName which is the next
sibling for the previousSibling . |
StateNode |
attachShadow(StateNode node)
Attaches the shadow root for the
node . |
String |
getAttribute(StateNode node,
String attribute)
Gets the value of the given attribute.
|
Stream<String> |
getAttributeNames(StateNode node)
Gets the defined attribute names.
|
Element |
getChild(StateNode node,
int index)
Returns the child element at the given position.
|
int |
getChildCount(StateNode node)
Gets the number of child elements.
|
ClassList |
getClassList(StateNode node)
Gets a list representation of all CSS class names set for an element.
|
default Optional<Component> |
getComponent(StateNode node)
Gets the component this element is mapped to.
|
Node |
getParent(StateNode node)
Gets the parent element.
|
Serializable |
getProperty(StateNode node,
String name)
Gets the value of the given property.
|
Stream<String> |
getPropertyNames(StateNode node)
Gets the defined property names.
|
StateNode |
getShadowRoot(StateNode node)
Gets shadow root for the
node if it has been attached. |
Style |
getStyle(StateNode node)
Returns a style instance for managing element inline styles.
|
Set<String> |
getSynchronizedProperties(StateNode node)
Gets the names of the properties to synchronize from the client side to
the server.
|
Set<String> |
getSynchronizedPropertyEvents(StateNode node)
Gets the event types which should trigger synchronization of properties
from the client side to the server.
|
String |
getTag(StateNode node)
Gets the tag name for the given node.
|
String |
getTextContent(StateNode node)
Gets the text content.
|
boolean |
hasAttribute(StateNode node,
String attribute)
Checks if the given attribute has been set.
|
boolean |
hasProperty(StateNode node,
String name)
Checks if the given property has been set.
|
void |
insertChild(StateNode node,
int index,
Element child)
Inserts the given child at the given position.
|
boolean |
isTextNode(StateNode node)
Checks if the state node represents a text node.
|
boolean |
isVisible(StateNode node)
Gets the
node visibility. |
void |
removeAllChildren(StateNode node)
Removes all child elements.
|
void |
removeAttribute(StateNode node,
String attribute)
Removes the given attribute if it has been set.
|
void |
removeChild(StateNode node,
Element child)
Removes the given child.
|
void |
removeChild(StateNode node,
int index)
Removes the child at the given position.
|
void |
removeProperty(StateNode node,
String name)
Removes the given property if it has been set.
|
void |
setAttribute(StateNode node,
String attribute,
AbstractStreamResource resource)
Sets the given attribute to the given
StreamResource value. |
void |
setAttribute(StateNode node,
String attribute,
String value)
Sets the given attribute to the given value.
|
default void |
setComponent(StateNode node,
Component component)
Defines a mapping between the element and the given component.
|
void |
setProperty(StateNode node,
String name,
Serializable value,
boolean emitChange)
Sets the given property to the given value.
|
void |
setTextContent(StateNode node,
String textContent)
Sets the text content.
|
void |
setVisible(StateNode node,
boolean visible)
Sets the
node visibility. |
boolean |
supports(StateNode node)
Checks if the element state provider supports the given state node.
|
void |
visit(StateNode node,
NodeVisitor visitor)
Visit the
node applying visitor to it and its descendants
based on the return value from the visitor. |
boolean supports(StateNode node)
node
- the state node to checkString getTag(StateNode node)
node
- the node containing the datavoid setAttribute(StateNode node, String attribute, String value)
node
- the node containing the dataattribute
- the attribute name, not nullvalue
- the attribute valuevoid setAttribute(StateNode node, String attribute, AbstractStreamResource resource)
StreamResource
value.node
- the node containing the dataattribute
- the attribute name, not nullresource
- the attribute value, not nullString getAttribute(StateNode node, String attribute)
node
- the node containing the dataattribute
- the attribute name, not nullboolean hasAttribute(StateNode node, String attribute)
node
- the node containing the dataattribute
- the attribute name, not nullvoid removeAttribute(StateNode node, String attribute)
node
- the node containing the dataattribute
- the attribute name, not nullStream<String> getAttributeNames(StateNode node)
node
- the node containing the dataNode getParent(StateNode node)
node
- the node containing the dataint getChildCount(StateNode node)
node
- the node containing the dataElement getChild(StateNode node, int index)
node
- the node containing the dataindex
- the index of the child element to returnvoid insertChild(StateNode node, int index, Element child)
node
- the node containing the dataindex
- the position at which to insert the new childchild
- the child element to insertvoid removeChild(StateNode node, int index)
node
- the node containing the dataindex
- the position of the child element to removevoid removeChild(StateNode node, Element child)
node
- the node containing the datachild
- the child element to removevoid removeAllChildren(StateNode node)
node
- the node containing the dataDomListenerRegistration addEventListener(StateNode node, String eventType, DomEventListener listener)
node
- the node containing the dataeventType
- the event typelistener
- the listenerSerializable getProperty(StateNode node, String name)
node
- the node containing the dataname
- the property name, not nullnull
if the property has not
been setvoid setProperty(StateNode node, String name, Serializable value, boolean emitChange)
node
- the node containing the dataname
- the property name, not null
value
- the property valueemitChange
- true to create a change event for the client sidevoid removeProperty(StateNode node, String name)
node
- the node containing the dataname
- the property name, not null
boolean hasProperty(StateNode node, String name)
node
- the node containing the dataname
- the property name, not null
true
if the property has been set,
false
otherwiseStream<String> getPropertyNames(StateNode node)
node
- the node containing the databoolean isTextNode(StateNode node)
node
- the node to checktrue
if the state node represents a text node;
otherwise false
String getTextContent(StateNode node)
isTextNode(StateNode)
returns true
.node
- the node containing the datavoid setTextContent(StateNode node, String textContent)
isTextNode(StateNode)
returns true
.node
- the node containing the datatextContent
- the text content, not nullClassList getClassList(StateNode node)
node
- the node containing the datanull
Style getStyle(StateNode node)
node
- the node containing the dataSet<String> getSynchronizedProperties(StateNode node)
The events which trigger synchronization are defined using
getSynchronizedPropertyEvents(StateNode)
.
node
- the node containing the dataSet<String> getSynchronizedPropertyEvents(StateNode node)
node
- the node containing the datadefault void setComponent(StateNode node, Component component)
node
- the node containing the datacomponent
- the component to map the element todefault Optional<Component> getComponent(StateNode node)
node
- the node containing the dataRegistration addPropertyChangeListener(StateNode node, String name, PropertyChangeListener listener)
node
- the node containing the propertyname
- the property name to add the listener forlistener
- listener to get notifications about property value changesStateNode getShadowRoot(StateNode node)
node
if it has been attached.node
- the node having a shadow root, not null
node
, may be nullStateNode attachShadow(StateNode node)
node
.node
- the node to attach the shadow rootnode
void attachExistingElement(StateNode node, String tagName, Element previousSibling, ChildElementConsumer callback)
tagName
which is the next
sibling for the previousSibling
.
The previousSibling
parameter value can be null
which
means that the very first child with the given tagName
will be
used to attach (if any).
node
- the parent nodetagName
- the tag name of the element to attach, not null
previousSibling
- previous sibling, may be null
callback
- the callback which will be invoked with a server side element
instance or an error will be reported, not null
void appendVirtualChild(StateNode node, Element child, String type, String payload)
node
- the node containing the datachild
- the child element to addtype
- the type of additional payload datapayload
- the additional payload datavoid visit(StateNode node, NodeVisitor visitor)
node
applying visitor
to it and its descendants
based on the return value from the visitor.node
- the node to visitvisitor
- the visitor to apply to the nodevoid setVisible(StateNode node, boolean visible)
node
visibility.node
- the node containing the datavisible
- the node visibility valueboolean isVisible(StateNode node)
node
visibility.node
- the node containing the datavoid addSynchronizedProperty(StateNode node, String property, DisabledUpdateMode mode)
The events which trigger synchronization are defined using
getSynchronizedPropertyEvents(StateNode)
.
node
- the node containing the dataproperty
- the property to synchronizemode
- controls RPC from the client side to the server side when the
element is disabled, not null
getSynchronizedPropertyEvents(StateNode)
,
getSynchronizedProperties(StateNode)
Copyright © 2023. All rights reserved.