mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
[sitemap] Add new "staticIcon" parameter (#3735)
When set, the UI should not provide the item state when requestiong the OH icon and should not request again the icon when the item state is updated. Related to openhab/openhab-android#3404 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
3af2e30098
commit
c12067a63b
@ -523,6 +523,7 @@ public class SitemapResource
|
||||
}
|
||||
bean.widgetId = widgetId;
|
||||
bean.icon = itemUIRegistry.getCategory(widget);
|
||||
bean.staticIcon = widget.getStaticIcon() != null;
|
||||
bean.labelcolor = convertItemValueColor(itemUIRegistry.getLabelColor(widget), itemState);
|
||||
bean.valuecolor = convertItemValueColor(itemUIRegistry.getValueColor(widget), itemState);
|
||||
bean.iconcolor = convertItemValueColor(itemUIRegistry.getIconColor(widget), itemState);
|
||||
|
@ -35,6 +35,7 @@ public class WidgetDTO {
|
||||
|
||||
public String label;
|
||||
public String icon;
|
||||
public Boolean staticIcon;
|
||||
public String labelcolor;
|
||||
public String valuecolor;
|
||||
public String iconcolor;
|
||||
|
@ -24,28 +24,32 @@ LinkableWidget:
|
||||
'}')?;
|
||||
|
||||
Frame:
|
||||
{Frame} 'Frame' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
{Frame} 'Frame' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
('iconcolor=[' (IconColor+=ColorArray (',' IconColor+=ColorArray)* ']'))? &
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Text:
|
||||
{Text} 'Text' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
{Text} 'Text' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
('iconcolor=[' (IconColor+=ColorArray (',' IconColor+=ColorArray)* ']'))? &
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Group:
|
||||
'Group' (('item=' item=GroupItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Group' (('item=' item=GroupItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
('iconcolor=[' (IconColor+=ColorArray (',' IconColor+=ColorArray)* ']'))? &
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Image:
|
||||
'Image' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Image' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('url=' url=STRING)? & ('refresh=' refresh=INT)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
@ -53,7 +57,8 @@ Image:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Video:
|
||||
'Video' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Video' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('url=' url=STRING) & ('encoding=' encoding=STRING)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
@ -61,7 +66,8 @@ Video:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Chart:
|
||||
'Chart' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Chart' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('service=' service=STRING)? & ('refresh=' refresh=INT)? & ('period=' period=ID) &
|
||||
('legend=' legend=BOOLEAN_OBJECT)? & ('forceasitem=' forceAsItem=BOOLEAN_OBJECT)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
@ -71,7 +77,8 @@ Chart:
|
||||
('yAxisDecimalPattern=' yAxisDecimalPattern=(STRING))?);
|
||||
|
||||
Webview:
|
||||
'Webview' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Webview' (('item=' item=ItemRef)? & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('height=' height=INT)? & ('url=' url=STRING) &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
@ -79,7 +86,8 @@ Webview:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Switch:
|
||||
'Switch' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Switch' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('mappings=[' mappings+=Mapping (',' mappings+=Mapping)* ']')? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
@ -87,7 +95,8 @@ Switch:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Mapview:
|
||||
'Mapview' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Mapview' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('height=' height=INT)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
@ -95,7 +104,8 @@ Mapview:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Slider:
|
||||
'Slider' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Slider' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('sendFrequency=' frequency=INT)? & (switchEnabled?='switchSupport')? &
|
||||
('minValue=' minValue=Number)? & ('maxValue=' maxValue=Number)? & ('step=' step=Number)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
@ -104,7 +114,8 @@ Slider:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Selection:
|
||||
'Selection' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Selection' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('mappings=[' mappings+=Mapping (',' mappings+=Mapping)* ']')? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
@ -112,7 +123,8 @@ Selection:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Setpoint:
|
||||
'Setpoint' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Setpoint' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('minValue=' minValue=Number)? & ('maxValue=' maxValue=Number)? & ('step=' step=Number)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
@ -120,15 +132,17 @@ Setpoint:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Colorpicker:
|
||||
'Colorpicker' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? & ('sendFrequency='
|
||||
frequency=INT)? &
|
||||
'Colorpicker' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('sendFrequency=' frequency=INT)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
('iconcolor=[' (IconColor+=ColorArray (',' IconColor+=ColorArray)* ']'))? &
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Input:
|
||||
'Input' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Input' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('inputHint=' inputHint=STRING)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
@ -136,7 +150,8 @@ Input:
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)* ']'))?);
|
||||
|
||||
Default:
|
||||
'Default' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & ('icon=' icon=Icon)? &
|
||||
'Default' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) | ('staticIcon=' staticIcon=Icon))? &
|
||||
('height=' height=INT)? &
|
||||
('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)* ']'))? &
|
||||
('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)* ']'))? &
|
||||
|
@ -267,6 +267,7 @@ public class UIComponentSitemapProvider implements SitemapProvider, RegistryChan
|
||||
if (widget != null) {
|
||||
setWidgetPropertyFromComponentConfig(widget, component, "label", SitemapPackage.WIDGET__LABEL);
|
||||
setWidgetPropertyFromComponentConfig(widget, component, "icon", SitemapPackage.WIDGET__ICON);
|
||||
setWidgetPropertyFromComponentConfig(widget, component, "staticIcon", SitemapPackage.WIDGET__STATIC_ICON);
|
||||
setWidgetPropertyFromComponentConfig(widget, component, "item", SitemapPackage.WIDGET__ITEM);
|
||||
|
||||
if (widget instanceof LinkableWidget linkableWidget) {
|
||||
|
@ -641,6 +641,8 @@ public class ItemUIRegistryImpl implements ItemUIRegistry {
|
||||
// if an icon is defined for the widget, use it
|
||||
if (w.getIcon() != null) {
|
||||
category = w.getIcon();
|
||||
} else if (w.getStaticIcon() != null) {
|
||||
category = w.getStaticIcon();
|
||||
} else {
|
||||
// otherwise check if any item ui provider provides an icon for this item
|
||||
String itemName = w.getItem();
|
||||
@ -792,6 +794,7 @@ public class ItemUIRegistryImpl implements ItemUIRegistry {
|
||||
private void copyProperties(Widget source, Widget target) {
|
||||
target.setItem(source.getItem());
|
||||
target.setIcon(source.getIcon());
|
||||
target.setStaticIcon(source.getStaticIcon());
|
||||
target.setLabel(source.getLabel());
|
||||
target.getVisibility().addAll(EcoreUtil.copyAll(source.getVisibility()));
|
||||
target.getLabelColor().addAll(EcoreUtil.copyAll(source.getLabelColor()));
|
||||
|
Loading…
Reference in New Issue
Block a user