Package org.openhab.core.ui.components
Class UIComponent
java.lang.Object
org.openhab.core.ui.components.UIComponent
- Direct Known Subclasses:
RootUIComponent
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 Summary
ConstructorDescriptionEmpty constructor for deserialization.UIComponent
(String componentType) Constructs a component by its type name - component names are not arbitrary, they are defined by the target frontend. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addComponent
(String slotName, UIComponent subComponent) Add a new sub-component to the specified slot.void
Adds a new configuration parameter to the componentAdds a new empty slot to the componentRetrieves the type of the component.Gets all the configuration parameters of the componentGets the list of sub-components in a slotgetSlots()
Returns all the slots of the component including their sub-componentsgetType()
Retrieves the type of the component.void
setComponent
(String component) Sets the type of the component.void
Sets all the configuration parameters of the componentvoid
setSlots
(Map<String, List<UIComponent>> slots) Sets all the slots of the component
-
Constructor Details
-
UIComponent
public UIComponent()Empty constructor for deserialization. -
UIComponent
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
Retrieves the type of the component.- Returns:
- the component type
-
getComponent
Retrieves the type of the component.- Returns:
- the component type
-
setComponent
Sets the type of the component.- Parameters:
component
- the component type
-
getConfig
Gets all the configuration parameters of the component- Returns:
- the map of configuration parameters
-
setConfig
Sets all the configuration parameters of the component- Parameters:
config
- the map of configuration parameters
-
addConfig
Adds a new configuration parameter to the component- Parameters:
key
- the parameter keyvalue
- the parameter value
-
getSlots
Returns all the slots of the component including their sub-components- Returns:
- the slots and their sub-components
-
setSlots
Sets all the slots of the component- Parameters:
slots
- the slots and their sub-components
-
addSlot
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
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
Add a new sub-component to the specified slot. Creates the slot if necessary.- Parameters:
slotName
- the slot to add the component tosubComponent
- the sub-component to add
-