Use setpoint as default sitemap element for item with tag "Setpoint" (#3364)
* Use setpoint as default sitemap element for item with tag "Setpoint" Fix openhab/openhab-webui#1697 Signed-off-by: Laurent Garnier <lg.hc@free.fr>pull/3369/head
parent
fcb8dee9a6
commit
fd6e161d21
|
@ -283,6 +283,9 @@ public class ItemUIRegistryImpl implements ItemUIRegistry {
|
|||
}
|
||||
if (!isReadOnly && hasStateOptions(itemName)) {
|
||||
return SitemapFactory.eINSTANCE.createSelection();
|
||||
}
|
||||
if (!isReadOnly && NumberItem.class.isAssignableFrom(itemType) && hasItemTag(itemName, "Setpoint")) {
|
||||
return SitemapFactory.eINSTANCE.createSetpoint();
|
||||
} else {
|
||||
return SitemapFactory.eINSTANCE.createText();
|
||||
}
|
||||
|
@ -856,6 +859,15 @@ public class ItemUIRegistryImpl implements ItemUIRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean hasItemTag(String itemName, String tag) {
|
||||
try {
|
||||
Item item = getItem(itemName);
|
||||
return item.hasTag(tag);
|
||||
} catch (ItemNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem(String name) throws ItemNotFoundException {
|
||||
return itemRegistry.getItem(name);
|
||||
|
|
Loading…
Reference in New Issue