From 44a146f5a81704aafb375cfec0553f98eb92ae63 Mon Sep 17 00:00:00 2001 From: Mark Herwege Date: Thu, 13 Apr 2023 20:04:47 +0200 Subject: [PATCH] Add Input widget to main UI sitemap configuration and REST API (#3431) * add input widget to UI SitemapProviderImpl * inputHint in UIComponentSitemapProvider * add input element to REST Signed-off-by: Mark Herwege --- .../core/io/rest/sitemap/internal/SitemapResource.java | 5 +++++ .../openhab/core/io/rest/sitemap/internal/WidgetDTO.java | 1 + .../ui/internal/components/UIComponentSitemapProvider.java | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java index a0597d54f..2991d9b6a 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java @@ -75,6 +75,7 @@ import org.openhab.core.model.sitemap.sitemap.Chart; import org.openhab.core.model.sitemap.sitemap.ColorArray; import org.openhab.core.model.sitemap.sitemap.Frame; import org.openhab.core.model.sitemap.sitemap.Image; +import org.openhab.core.model.sitemap.sitemap.Input; import org.openhab.core.model.sitemap.sitemap.LinkableWidget; import org.openhab.core.model.sitemap.sitemap.Mapping; import org.openhab.core.model.sitemap.sitemap.Mapview; @@ -558,6 +559,10 @@ public class SitemapResource bean.mappings.add(mappingBean); } } + if (widget instanceof Input) { + Input inputWidget = (Input) widget; + bean.inputHint = inputWidget.getInputHint(); + } if (widget instanceof Slider) { Slider sliderWidget = (Slider) widget; bean.sendFrequency = sliderWidget.getFrequency(); diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetDTO.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetDTO.java index 61e79b7c3..db47ddd27 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetDTO.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetDTO.java @@ -47,6 +47,7 @@ public class WidgetDTO { public BigDecimal minValue; public BigDecimal maxValue; public BigDecimal step; + public String inputHint; public String url; public String encoding; public String service; diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java index 47d54996b..e274c23bb 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java @@ -45,6 +45,7 @@ import org.openhab.core.model.sitemap.sitemap.impl.DefaultImpl; import org.openhab.core.model.sitemap.sitemap.impl.FrameImpl; import org.openhab.core.model.sitemap.sitemap.impl.GroupImpl; import org.openhab.core.model.sitemap.sitemap.impl.ImageImpl; +import org.openhab.core.model.sitemap.sitemap.impl.InputImpl; import org.openhab.core.model.sitemap.sitemap.impl.MappingImpl; import org.openhab.core.model.sitemap.sitemap.impl.MapviewImpl; import org.openhab.core.model.sitemap.sitemap.impl.SelectionImpl; @@ -235,6 +236,11 @@ public class UIComponentSitemapProvider implements SitemapProvider, RegistryChan addWidgetMappings(selectionWidget.getMappings(), component); widget = selectionWidget; break; + case "Input": + InputImpl inputWidget = (InputImpl) SitemapFactory.eINSTANCE.createInput(); + widget = inputWidget; + setWidgetPropertyFromComponentConfig(widget, component, "inputHint", SitemapPackage.INPUT__INPUT_HINT); + break; case "Setpoint": SetpointImpl setpointWidget = (SetpointImpl) SitemapFactory.eINSTANCE.createSetpoint(); widget = setpointWidget;