Package org.openhab.core.ui.items
Interface ItemUIRegistry
- All Superinterfaces:
ItemRegistry
,ItemUIProvider
,Registry<Item,
String>
This interface is used by a service which combines the core item registry
with an aggregation of item ui providers; it can be therefore widely used for
all UI related information requests regarding items.
- Author:
- Kai Kreuzer - Initial contribution, Chris Jackson - Initial contribution, Laurent Garnier - new method getIconColor, Mark Herwege - new method getFormatPattern, Laurent Garnier - new method getConditionalIcon, Danny Baumann - widget label source support
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable State
convertState
(Widget widget, Item item, State state) Convert the given state into@Nullable State
convertStateToLabelUnit
(QuantityType<?> state, String label) Convert the given state to the unit found in label.@Nullable String
Retrieves the category for a widget.org.eclipse.emf.common.util.EList
<Widget> this should be used instead of LinkableWidget.getChildren() as there might be no children defined on the widget, but they should be dynamically determined by looking at the members of the underlying item.org.eclipse.emf.common.util.EList
<Widget> getChildren
(Sitemap sitemap) this should be used instead of Sitemap.getChildren() as the default widgets have to be resolved to a concrete widget type.@Nullable String
Gets the icon for the widget.@Nullable String
Gets the format pattern for the widget value, retrieved from widget label, item label or item state description@Nullable String
Gets the icon color for the widget.@Nullable State
getItemState
(String itemName) Gets the item state@Nullable String
Retrieves the label for a widget.@Nullable String
Gets the label color for the widget.Retrieves the label source for a widget.@Nullable org.eclipse.emf.ecore.EObject
this should be used instead of Widget.eContainer() as as the concrete widgets created from default widgets have no parent.@Nullable State
Retrieves the current state of the item of a widget orUnDefType.UNDEF
.@Nullable String
getUnitForWidget
(Widget widget) Provide a widget specific String representation of aUnit
.@Nullable String
Gets the value color for the widget.boolean
Gets the widget visibility based on the item state@Nullable Widget
Retrieves the widget for a given id on a given sitemap.Provides an id for a widget.Methods inherited from interface org.openhab.core.items.ItemRegistry
addRegistryHook, getItem, getItemByPattern, getItems, getItems, getItemsByTag, getItemsByTag, getItemsByTagAndType, getItemsOfType, remove, removeRegistryHook
Methods inherited from interface org.openhab.core.ui.items.ItemUIProvider
getCategory, getDefaultWidget, getLabel, getWidget
Methods inherited from interface org.openhab.core.common.registry.Registry
add, addRegistryChangeListener, get, getAll, remove, removeRegistryChangeListener, stream, update
-
Method Details
-
getLabel
Retrieves the label for a widget. This first checks, if there is a label defined in the sitemap. If not, it checks all item UI providers for a label. If no label can be found, it is set to an empty string. If the label contains a "[%format]" section, i.e. "[%s]" for a string or "[%.3f]" for a decimal, this is replaced by the current value of the item and padded by a "" element.- Parameters:
w
- the widget to retrieve the label for- Returns:
- the label to use for the widget
-
getLabelSource
Retrieves the label source for a widget.- Parameters:
w
- the widget to retrieve the label source for- Returns:
- the source the widget label is taken from
-
getCategory
Retrieves the category for a widget. This first checks, if there is a category defined in the sitemap. If not, it checks all item UI providers for a category. If no category can be found, the default category is the widget type name, e.g. "switch".- Parameters:
w
- the widget to retrieve the category for- Returns:
- the category to use for the widget
-
getState
Retrieves the current state of the item of a widget orUnDefType.UNDEF
.- Parameters:
w
- the widget to retrieve the item state for- Returns:
- the item state of the widget
-
getWidget
Retrieves the widget for a given id on a given sitemap.- Parameters:
sitemap
- the sitemap to look for the widgetid
- the id of the widget to look for- Returns:
- the widget for the given id
-
getWidgetId
Provides an id for a widget. This constructs a string out of the position of the sitemap, so if this widget is the third child of a page linked from the fifth widget on the home screen, its id would be "0503". If the widget is dynamically created and not available in the sitemap, the name of its associated item is used instead.- Parameters:
w
- the widget to get the id for- Returns:
- an id for this widget
-
getChildren
this should be used instead of Sitemap.getChildren() as the default widgets have to be resolved to a concrete widget type.- Parameters:
sitemap
- the sitemap to retrieve the children for- Returns:
- the children of the sitemap
-
getChildren
this should be used instead of LinkableWidget.getChildren() as there might be no children defined on the widget, but they should be dynamically determined by looking at the members of the underlying item.- Parameters:
w
- the widget to retrieve the children for- Returns:
- the (dynamically or statically defined) children of the widget
-
getParent
this should be used instead of Widget.eContainer() as as the concrete widgets created from default widgets have no parent.- Parameters:
w
- the widget to retrieve the parent for- Returns:
- the parent of the widget
-
getFormatPattern
Gets the format pattern for the widget value, retrieved from widget label, item label or item state description- Parameters:
w
- Widget- Returns:
- String with the format pattern
-
getLabelColor
Gets the label color for the widget. Checks conditional statements to find the color based on the item value- Parameters:
w
- Widget- Returns:
- String with the color
-
getValueColor
Gets the value color for the widget. Checks conditional statements to find the color based on the item value- Parameters:
w
- Widget- Returns:
- String with the color
-
getIconColor
Gets the icon color for the widget. Checks conditional statements to find the color based on the item value- Parameters:
w
- Widget- Returns:
- String with the color
-
getConditionalIcon
Gets the icon for the widget. Checks conditional statements to find the icon based on the item value- Parameters:
w
- Widget- Returns:
- the icon reference or null in case no conditional statement is defined or no conditional statement is fulfilled.
-
getVisiblity
Gets the widget visibility based on the item state- Parameters:
w
- Widget- Returns:
- true if the item is visible
-
getItemState
Gets the item state- Parameters:
itemName
- item name- Returns:
- State of the item
-
getUnitForWidget
Provide a widget specific String representation of aUnit
.- Parameters:
widget
-- Returns:
- a widget specific String representation of a
Unit
.
-
convertStateToLabelUnit
Convert the given state to the unit found in label. The label must be in the format "" with unit being a valid unit symbol. - Parameters:
state
- the state to be converted.label
- the label containing the target unit.- Returns:
- the converted state.
-
convertState
Convert the given state into- Parameters:
widget
- Widgetitem
- itemstate
- state- Returns:
- the state converted to a type accepted by the item or the given state if the conversion was not possible
-