com.vaadin.flow.dom.impl.
Class ShadowRootStateProvider
- java.lang.Object
-
- com.vaadin.flow.dom.impl.AbstractNodeStateProvider
-
- com.vaadin.flow.dom.impl.ShadowRootStateProvider
-
All Implemented Interfaces:
public class ShadowRootStateProvider extends AbstractNodeStateProvider
Implementation which handles shadow root nodes.
Only the methods implemented in the
AbstractNodeStateProvider
are supported (related to the composition).The data is stored directly in the state node but this should be considered an implementation detail which can change.
Since:
1.0
Author:
Vaadin Ltd
See Also:
-
-
Constructor Summary
Constructors Constructor and Description ShadowRootStateProvider()
-
Method Summary
All Methods 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.
StateNode
attachShadow(StateNode node)
Attaches the shadow root for the
node
.StateNode
createShadowRootNode(StateNode node)
Create a new shadow root node for the given element
node
.static ShadowRootStateProvider
get()
Gets the one and only instance.
String
getAttribute(StateNode node, String attribute)
Gets the value of the given attribute.
Stream<String>
getAttributeNames(StateNode node)
Gets the defined attribute names.
ClassList
getClassList(StateNode node)
Gets a list representation of all CSS class names set for an element.
protected Node<?>
getNode(StateNode node)
Gets the flyweight instance for the
node
supported by the provider.Serializable
getProperty(StateNode node, String name)
Gets the value of the given property.
Stream<String>
getPropertyNames(StateNode node)
Gets the defined property names.
protected Class<? extends NodeFeature>[]
getProviderFeatures()
Returns the features supported by the provider.
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.
boolean
isTextNode(StateNode node)
Checks if the state node represents a text node.
boolean
isVisible(StateNode node)
Gets the
node
visibility.void
removeAttribute(StateNode node, String attribute)
Removes the given attribute if it has been set.
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.
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.void
visit(StateNode node, NodeVisitor visitor)
Visit the
node
applyingvisitor
to it and its descendants based on the return value from the visitor.-
Methods inherited from class com.vaadin.flow.dom.impl.AbstractNodeStateProvider
appendVirtualChild, attachExistingElement, getChild, getChildCount, getParent, insertChild, removeAllChildren, removeChild, removeChild, supports, visitDescendants
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.dom.ElementStateProvider
getComponent, setComponent
-
-
-
-
Method Detail
-
get
public static ShadowRootStateProvider get()
Gets the one and only instance.
Returns:
the instance to use for shadow root nodes
-
createShadowRootNode
public StateNode createShadowRootNode(StateNode node)
Create a new shadow root node for the given element
node
.Parameters:
node
- the node to create the shadow root forReturns:
the shadow root node
-
getTag
public String getTag(StateNode node)
Description copied from interface:
ElementStateProvider
Gets the tag name for the given node.
Parameters:
node
- the node containing the dataReturns:
the tag name
-
setAttribute
public void setAttribute(StateNode node, String attribute, String value)
Description copied from interface:
ElementStateProvider
Sets the given attribute to the given value.
Parameters:
node
- the node containing the dataattribute
- the attribute name, not nullvalue
- the attribute value
-
setAttribute
public void setAttribute(StateNode node, String attribute, AbstractStreamResource resource)
Description copied from interface:
ElementStateProvider
Sets the given attribute to the given
StreamResource
value.Parameters:
node
- the node containing the dataattribute
- the attribute name, not nullresource
- the attribute value, not null
-
getAttribute
public String getAttribute(StateNode node, String attribute)
Description copied from interface:
ElementStateProvider
Gets the value of the given attribute.
Parameters:
node
- the node containing the dataattribute
- the attribute name, not nullReturns:
the attribute value or null if the attribute has not been set
-
hasAttribute
public boolean hasAttribute(StateNode node, String attribute)
Description copied from interface:
ElementStateProvider
Checks if the given attribute has been set.
Parameters:
node
- the node containing the dataattribute
- the attribute name, not nullReturns:
true if the attribute has been set, false otherwise
-
removeAttribute
public void removeAttribute(StateNode node, String attribute)
Description copied from interface:
ElementStateProvider
Removes the given attribute if it has been set.
Parameters:
node
- the node containing the dataattribute
- the attribute name, not null
-
getAttributeNames
public Stream<String> getAttributeNames(StateNode node)
Description copied from interface:
ElementStateProvider
Gets the defined attribute names.
Parameters:
node
- the node containing the dataReturns:
the defined attribute names
-
addEventListener
public DomListenerRegistration addEventListener(StateNode node, String eventType, DomEventListener listener)
Description copied from interface:
ElementStateProvider
Adds a DOM event listener.
Parameters:
node
- the node containing the dataeventType
- the event typelistener
- the listenerReturns:
a handle for configuring or removing the listener
-
getProperty
public Serializable getProperty(StateNode node, String name)
Description copied from interface:
ElementStateProvider
Gets the value of the given property.
Parameters:
node
- the node containing the dataname
- the property name, not nullReturns:
the property value, or
null
if the property has not been set
-
setProperty
public void setProperty(StateNode node, String name, Serializable value, boolean emitChange)
Description copied from interface:
ElementStateProvider
Sets the given property to the given value.
Parameters:
node
- the node containing the dataname
- the property name, notnull
value
- the property valueemitChange
- true to create a change event for the client side
-
removeProperty
public void removeProperty(StateNode node, String name)
Description copied from interface:
ElementStateProvider
Removes the given property if it has been set.
Parameters:
node
- the node containing the dataname
- the property name, notnull
-
hasProperty
public boolean hasProperty(StateNode node, String name)
Description copied from interface:
ElementStateProvider
Checks if the given property has been set.
Parameters:
node
- the node containing the dataname
- the property name, notnull
Returns:
true
if the property has been set,false
otherwise
-
getPropertyNames
public Stream<String> getPropertyNames(StateNode node)
Description copied from interface:
ElementStateProvider
Gets the defined property names.
Parameters:
node
- the node containing the dataReturns:
the defined property names
-
isTextNode
public boolean isTextNode(StateNode node)
Description copied from interface:
ElementStateProvider
Checks if the state node represents a text node.
Parameters:
node
- the node to checkReturns:
true
if the state node represents a text node; otherwisefalse
-
getTextContent
public String getTextContent(StateNode node)
Description copied from interface:
ElementStateProvider
Gets the text content. This is only valid if
ElementStateProvider.isTextNode(StateNode)
returnstrue
.Parameters:
node
- the node containing the dataReturns:
the text content
-
setTextContent
public void setTextContent(StateNode node, String textContent)
Description copied from interface:
ElementStateProvider
Sets the text content. This is only valid if
ElementStateProvider.isTextNode(StateNode)
returnstrue
.Parameters:
node
- the node containing the datatextContent
- the text content, not null
-
getClassList
public ClassList getClassList(StateNode node)
Description copied from interface:
ElementStateProvider
Gets a list representation of all CSS class names set for an element.
Parameters:
node
- the node containing the dataReturns:
the class list, never
null
-
getStyle
public Style getStyle(StateNode node)
Description copied from interface:
ElementStateProvider
Returns a style instance for managing element inline styles.
Parameters:
node
- the node containing the dataReturns:
the element styles
-
getSynchronizedProperties
public Set<String> getSynchronizedProperties(StateNode node)
Description copied from interface:
ElementStateProvider
Gets the names of the properties to synchronize from the client side to the server.
The events which trigger synchronization are defined using
ElementStateProvider.getSynchronizedPropertyEvents(StateNode)
.Parameters:
node
- the node containing the dataReturns:
the names of the properties to synchronize
-
addSynchronizedProperty
public void addSynchronizedProperty(StateNode node, String property, DisabledUpdateMode mode)
Description copied from interface:
ElementStateProvider
Makes the property synchronized from the client side to the server.
The events which trigger synchronization are defined using
ElementStateProvider.getSynchronizedPropertyEvents(StateNode)
.Parameters:
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, notnull
See Also:
ElementStateProvider.getSynchronizedPropertyEvents(StateNode)
,ElementStateProvider.getSynchronizedProperties(StateNode)
-
getSynchronizedPropertyEvents
public Set<String> getSynchronizedPropertyEvents(StateNode node)
Description copied from interface:
ElementStateProvider
Gets the event types which should trigger synchronization of properties from the client side to the server.
Parameters:
node
- the node containing the dataReturns:
the event types which should trigger synchronization
-
addPropertyChangeListener
public Registration addPropertyChangeListener(StateNode node, String name, PropertyChangeListener listener)
Description copied from interface:
ElementStateProvider
Adds a property change listener.
Parameters:
node
- the node containing the propertyname
- the property name to add the listener forlistener
- listener to get notifications about property value changesReturns:
an event registration handle for removing the listener
-
getShadowRoot
public StateNode getShadowRoot(StateNode node)
Description copied from interface:
ElementStateProvider
Gets shadow root for the
node
if it has been attached.Parameters:
node
- the node having a shadow root, notnull
Returns:
the shadow root of the
node
, may be null
-
attachShadow
public StateNode attachShadow(StateNode node)
Description copied from interface:
ElementStateProvider
Attaches the shadow root for the
node
.Parameters:
node
- the node to attach the shadow rootReturns:
the shadow root of the
node
-
visit
public void visit(StateNode node, NodeVisitor visitor)
Description copied from interface:
ElementStateProvider
Visit the
node
applyingvisitor
to it and its descendants based on the return value from the visitor.Parameters:
node
- the node to visitvisitor
- the visitor to apply to the node
-
getProviderFeatures
protected Class<? extends NodeFeature>[] getProviderFeatures()
Description copied from class:
AbstractNodeStateProvider
Returns the features supported by the provider.
Specified by:
getProviderFeatures
in classAbstractNodeStateProvider
Returns:
features supported by the provider
-
getNode
protected Node<?> getNode(StateNode node)
Description copied from class:
AbstractNodeStateProvider
Gets the flyweight instance for the
node
supported by the provider.Specified by:
getNode
in classAbstractNodeStateProvider
Parameters:
node
- the node to wrap into flyweightReturns:
the flyweight instance for the
node
See Also:
-
setVisible
public void setVisible(StateNode node, boolean visible)
Description copied from interface:
ElementStateProvider
Sets the
node
visibility.Parameters:
node
- the node containing the datavisible
- the node visibility value
-
isVisible
public boolean isVisible(StateNode node)
Description copied from interface:
ElementStateProvider
Gets the
node
visibility.Parameters:
node
- the node containing the dataReturns:
the node visibility
-
-