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
lolodomo 2023-02-12 19:30:29 +01:00 committed by GitHub
parent fcb8dee9a6
commit fd6e161d21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -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);