Interface ElementStateProvider

    • Method Detail

      • supports

        boolean supports​(StateNode node)
        Checks if the element state provider supports the given state node.
        Parameters:
        node - the state node to check
        Returns:
        true if the element state provider is compatible with the given state node, false otherwise
      • getTag

        String getTag​(StateNode node)
        Gets the tag name for the given node.
        Parameters:
        node - the node containing the data
        Returns:
        the tag name
      • setAttribute

        void setAttribute​(StateNode node,
                          String attribute,
                          String value)
        Sets the given attribute to the given value.
        Parameters:
        node - the node containing the data
        attribute - the attribute name, not null
        value - the attribute value
      • setAttribute

        void setAttribute​(StateNode node,
                          String attribute,
                          AbstractStreamResource resource)
        Sets the given attribute to the given StreamResource value.
        Parameters:
        node - the node containing the data
        attribute - the attribute name, not null
        resource - the attribute value, not null
      • getAttribute

        String getAttribute​(StateNode node,
                            String attribute)
        Gets the value of the given attribute.
        Parameters:
        node - the node containing the data
        attribute - the attribute name, not null
        Returns:
        the attribute value or null if the attribute has not been set
      • hasAttribute

        boolean hasAttribute​(StateNode node,
                             String attribute)
        Checks if the given attribute has been set.
        Parameters:
        node - the node containing the data
        attribute - the attribute name, not null
        Returns:
        true if the attribute has been set, false otherwise
      • removeAttribute

        void removeAttribute​(StateNode node,
                             String attribute)
        Removes the given attribute if it has been set.
        Parameters:
        node - the node containing the data
        attribute - the attribute name, not null
      • getAttributeNames

        Stream<String> getAttributeNames​(StateNode node)
        Gets the defined attribute names.
        Parameters:
        node - the node containing the data
        Returns:
        the defined attribute names
      • getParent

        Node getParent​(StateNode node)
        Gets the parent element.
        Parameters:
        node - the node containing the data
        Returns:
        the parent element or null if the element has no parent
      • getChildCount

        int getChildCount​(StateNode node)
        Gets the number of child elements.
        Parameters:
        node - the node containing the data
        Returns:
        the number of child elements
      • getChild

        Element getChild​(StateNode node,
                         int index)
        Returns the child element at the given position.
        Parameters:
        node - the node containing the data
        index - the index of the child element to return
        Returns:
        the child element
      • insertChild

        void insertChild​(StateNode node,
                         int index,
                         Element child)
        Inserts the given child at the given position.
        Parameters:
        node - the node containing the data
        index - the position at which to insert the new child
        child - the child element to insert
      • removeChild

        void removeChild​(StateNode node,
                         int index)
        Removes the child at the given position.
        Parameters:
        node - the node containing the data
        index - the position of the child element to remove
      • removeChild

        void removeChild​(StateNode node,
                         Element child)
        Removes the given child.
        Parameters:
        node - the node containing the data
        child - the child element to remove
      • removeAllChildren

        void removeAllChildren​(StateNode node)
        Removes all child elements.
        Parameters:
        node - the node containing the data
      • addEventListener

        DomListenerRegistration addEventListener​(StateNode node,
                                                 String eventType,
                                                 DomEventListener listener)
        Adds a DOM event listener.
        Parameters:
        node - the node containing the data
        eventType - the event type
        listener - the listener
        Returns:
        a handle for configuring or removing the listener
      • getProperty

        Serializable getProperty​(StateNode node,
                                 String name)
        Gets the value of the given property.
        Parameters:
        node - the node containing the data
        name - the property name, not null
        Returns:
        the property value, or null if the property has not been set
      • setProperty

        void setProperty​(StateNode node,
                         String name,
                         Serializable value,
                         boolean emitChange)
        Sets the given property to the given value.
        Parameters:
        node - the node containing the data
        name - the property name, not null
        value - the property value
        emitChange - true to create a change event for the client side
      • removeProperty

        void removeProperty​(StateNode node,
                            String name)
        Removes the given property if it has been set.
        Parameters:
        node - the node containing the data
        name - the property name, not null
      • hasProperty

        boolean hasProperty​(StateNode node,
                            String name)
        Checks if the given property has been set.
        Parameters:
        node - the node containing the data
        name - the property name, not null
        Returns:
        true if the property has been set, false otherwise
      • getPropertyNames

        Stream<String> getPropertyNames​(StateNode node)
        Gets the defined property names.
        Parameters:
        node - the node containing the data
        Returns:
        the defined property names
      • isTextNode

        boolean isTextNode​(StateNode node)
        Checks if the state node represents a text node.
        Parameters:
        node - the node to check
        Returns:
        true if the state node represents a text node; otherwise false
      • getTextContent

        String getTextContent​(StateNode node)
        Gets the text content. This is only valid if isTextNode(StateNode) returns true.
        Parameters:
        node - the node containing the data
        Returns:
        the text content
      • setTextContent

        void setTextContent​(StateNode node,
                            String textContent)
        Sets the text content. This is only valid if isTextNode(StateNode) returns true.
        Parameters:
        node - the node containing the data
        textContent - the text content, not null
      • getClassList

        ClassList getClassList​(StateNode node)
        Gets a list representation of all CSS class names set for an element.
        Parameters:
        node - the node containing the data
        Returns:
        the class list, never null
      • getStyle

        Style getStyle​(StateNode node)
        Returns a style instance for managing element inline styles.
        Parameters:
        node - the node containing the data
        Returns:
        the element styles
      • setComponent

        default void setComponent​(StateNode node,
                                  Component component)
        Defines a mapping between the element and the given component.
        Parameters:
        node - the node containing the data
        component - the component to map the element to
      • getComponent

        default Optional<Component> getComponent​(StateNode node)
        Gets the component this element is mapped to.
        Parameters:
        node - the node containing the data
        Returns:
        an optional component, or an empty optional if no component has been mapped to this node
      • addPropertyChangeListener

        Registration addPropertyChangeListener​(StateNode node,
                                               String name,
                                               PropertyChangeListener listener)
        Adds a property change listener.
        Parameters:
        node - the node containing the property
        name - the property name to add the listener for
        listener - listener to get notifications about property value changes
        Returns:
        an event registration handle for removing the listener
      • getShadowRoot

        StateNode getShadowRoot​(StateNode node)
        Gets shadow root for the node if it has been attached.
        Parameters:
        node - the node having a shadow root, not null
        Returns:
        the shadow root of the node, may be null
      • attachShadow

        StateNode attachShadow​(StateNode node)
        Attaches the shadow root for the node.
        Parameters:
        node - the node to attach the shadow root
        Returns:
        the shadow root of the node
      • attachExistingElement

        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.

        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).

        Parameters:
        node - the parent node
        tagName - 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
      • appendVirtualChild

        void appendVirtualChild​(StateNode node,
                                Element child,
                                String type,
                                String payload)
        Append the given element as a virtual child.
        Parameters:
        node - the node containing the data
        child - the child element to add
        type - the type of additional payload data
        payload - the additional payload data
      • visit

        void visit​(StateNode node,
                   NodeVisitor visitor)
        Visit the node applying visitor to it and its descendants based on the return value from the visitor.
        Parameters:
        node - the node to visit
        visitor - the visitor to apply to the node
      • setVisible

        void setVisible​(StateNode node,
                        boolean visible)
        Sets the node visibility.
        Parameters:
        node - the node containing the data
        visible - the node visibility value
      • isVisible

        boolean isVisible​(StateNode node)
        Gets the node visibility.
        Parameters:
        node - the node containing the data
        Returns:
        the node visibility