Class UIComponent

java.lang.Object
org.openhab.core.ui.components.UIComponent
Direct Known Subclasses:
RootUIComponent

public class UIComponent extends Object
A UIComponent represents a piece of UI element for a client frontend to render; it is kept very simple and delegates the actual rendering and behavior to the frontend. It has a reference to a component's name as defined by the frontend, a map of configuration parameters, and several named "slots", or placeholders, which may contain other sub-components, thus defining a tree. No checks are performed on the actual validity of configuration parameters and their values, the validity of a particular slot for a certain component or the validity of certain types of sub-components within a particular slot: that is the frontend's responsibility.
Author:
Yannick Schaus - Initial contribution
  • Constructor Details

    • UIComponent

      public UIComponent()
      Empty constructor for deserialization.
    • UIComponent

      public UIComponent(String componentType)
      Constructs a component by its type name - component names are not arbitrary, they are defined by the target frontend.
      Parameters:
      componentType - type of the component as known to the frontend
  • Method Details

    • getType

      public String getType()
      Retrieves the type of the component.
      Returns:
      the component type
    • getComponent

      public String getComponent()
      Retrieves the type of the component.
      Returns:
      the component type
    • setComponent

      public void setComponent(String component)
      Sets the type of the component.
      Parameters:
      component - the component type
    • getConfig

      public Map<String,Object> getConfig()
      Gets all the configuration parameters of the component
      Returns:
      the map of configuration parameters
    • setConfig

      public void setConfig(Map<String,Object> config)
      Sets all the configuration parameters of the component
      Parameters:
      config - the map of configuration parameters
    • addConfig

      public void addConfig(String key, Object value)
      Adds a new configuration parameter to the component
      Parameters:
      key - the parameter key
      value - the parameter value
    • getSlots

      public Map<String,List<UIComponent>> getSlots()
      Returns all the slots of the component including their sub-components
      Returns:
      the slots and their sub-components
    • setSlots

      public void setSlots(Map<String,List<UIComponent>> slots)
      Sets all the slots of the component
      Parameters:
      slots - the slots and their sub-components
    • addSlot

      public List<UIComponent> addSlot(String slotName)
      Adds a new empty slot to the component
      Parameters:
      slotName - the name of the slot
      Returns:
      the empty list of components in the newly created slot
    • getSlot

      public List<UIComponent> getSlot(String slotName)
      Gets the list of sub-components in a slot
      Parameters:
      slotName - the name of the slot
      Returns:
      the list of sub-components in the slot
    • addComponent

      public void addComponent(String slotName, UIComponent subComponent)
      Add a new sub-component to the specified slot. Creates the slot if necessary.
      Parameters:
      slotName - the slot to add the component to
      subComponent - the sub-component to add