Interface ItemUIRegistry

All Superinterfaces:
ItemRegistry, ItemUIProvider, Registry<Item,String>

@NonNullByDefault public interface ItemUIRegistry extends ItemRegistry, ItemUIProvider
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
  • Method Details

    • getLabel

      @Nullable String getLabel(Widget w)
      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

      @Nullable String getCategory(Widget w)
      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

      @Nullable State getState(Widget w)
      Retrieves the current state of the item of a widget or UnDefType.UNDEF.
      Parameters:
      w - the widget to retrieve the item state for
      Returns:
      the item state of the widget
    • getWidget

      @Nullable Widget getWidget(Sitemap sitemap, String id)
      Retrieves the widget for a given id on a given sitemap.
      Parameters:
      sitemap - the sitemap to look for the widget
      id - the id of the widget to look for
      Returns:
      the widget for the given id
    • getWidgetId

      String getWidgetId(Widget w)
      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

      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.
      Parameters:
      sitemap - the sitemap to retrieve the children for
      Returns:
      the children of the sitemap
    • getChildren

      org.eclipse.emf.common.util.EList<Widget> getChildren(LinkableWidget w)
      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

      @Nullable org.eclipse.emf.ecore.EObject getParent(Widget w)
      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

      @Nullable String getFormatPattern(Widget w)
      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

      @Nullable String getLabelColor(Widget w)
      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

      @Nullable String getValueColor(Widget w)
      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

      @Nullable String getIconColor(Widget w)
      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

      @Nullable String getConditionalIcon(Widget w)
      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

      boolean getVisiblity(Widget w)
      Gets the widget visibility based on the item state
      Parameters:
      w - Widget
      Returns:
      true if the item is visible
    • getItemState

      @Nullable State getItemState(String itemName)
      Gets the item state
      Parameters:
      itemName - item name
      Returns:
      State of the item
    • getUnitForWidget

      @Nullable String getUnitForWidget(Widget widget)
      Provide a widget specific String representation of a Unit.
      Parameters:
      widget -
      Returns:
      a widget specific String representation of a Unit.
    • convertStateToLabelUnit

      @Nullable State convertStateToLabelUnit(QuantityType<?> state, String label)
      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

      @Nullable State convertState(Widget widget, Item item, State state)
      Convert the given state into
      Parameters:
      widget - Widget
      item - item
      state - state
      Returns:
      the state converted to a type accepted by the item or the given state if the conversion was not possible