mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
[sitemap] Add new element Colortemperaturepicker (#4420)
Related to #3891 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
7f5fbbb22f
commit
7d98903acb
@ -83,6 +83,7 @@ import org.openhab.core.model.sitemap.sitemap.ButtonDefinition;
|
||||
import org.openhab.core.model.sitemap.sitemap.Buttongrid;
|
||||
import org.openhab.core.model.sitemap.sitemap.Chart;
|
||||
import org.openhab.core.model.sitemap.sitemap.ColorArray;
|
||||
import org.openhab.core.model.sitemap.sitemap.Colortemperaturepicker;
|
||||
import org.openhab.core.model.sitemap.sitemap.Condition;
|
||||
import org.openhab.core.model.sitemap.sitemap.Frame;
|
||||
import org.openhab.core.model.sitemap.sitemap.IconRule;
|
||||
@ -145,6 +146,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
* @author Laurent Garnier - New widget icon parameter based on conditional rules
|
||||
* @author Laurent Garnier - Added releaseCmd field for mappings used for switch element
|
||||
* @author Laurent Garnier - Added support for Buttongrid as container for Button elements
|
||||
* @author Laurent Garnier - Added support for new sitemap element Colortemperaturepicker
|
||||
*/
|
||||
@Component(service = { RESTResource.class, EventSubscriber.class })
|
||||
@JaxrsResource
|
||||
@ -700,6 +702,10 @@ public class SitemapResource
|
||||
bean.maxValue = setpointWidget.getMaxValue();
|
||||
bean.step = setpointWidget.getStep();
|
||||
}
|
||||
if (widget instanceof Colortemperaturepicker colortemperaturepickerWidget) {
|
||||
bean.minValue = colortemperaturepickerWidget.getMinValue();
|
||||
bean.maxValue = colortemperaturepickerWidget.getMaxValue();
|
||||
}
|
||||
if (widget instanceof Buttongrid buttonGridWidget) {
|
||||
for (ButtonDefinition button : buttonGridWidget.getButtons()) {
|
||||
MappingDTO mappingBean = new MappingDTO();
|
||||
|
@ -15,7 +15,7 @@ Widget:
|
||||
(LinkableWidget | NonLinkableWidget);
|
||||
|
||||
NonLinkableWidget:
|
||||
Switch | Selection | Slider | Setpoint | Video | Chart | Webview | Colorpicker | Mapview | Input | Button | Default;
|
||||
Switch | Selection | Slider | Setpoint | Video | Chart | Webview | Colorpicker | Colortemperaturepicker | Mapview | Input | Button | Default;
|
||||
|
||||
LinkableWidget:
|
||||
(Text | Group | Image | Frame | Buttongrid)
|
||||
@ -165,6 +165,17 @@ Colorpicker:
|
||||
('iconcolor=[' (IconColor+=ColorArray (',' IconColor+=ColorArray)*) ']')? &
|
||||
('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)*) ']')?);
|
||||
|
||||
Colortemperaturepicker:
|
||||
'Colortemperaturepicker' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? &
|
||||
(('icon=' icon=Icon) |
|
||||
('icon=[' (IconRules+=IconRule (',' IconRules+=IconRule)*) ']') |
|
||||
('staticIcon=' staticIcon=Icon))? &
|
||||
('minValue=' minValue=Number)? & ('maxValue=' maxValue=Number)? &
|
||||
('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) |
|
||||
|
@ -17,6 +17,7 @@ package org.openhab.core.model.sitemap.validation
|
||||
|
||||
import org.openhab.core.model.sitemap.sitemap.Button
|
||||
import org.openhab.core.model.sitemap.sitemap.Buttongrid
|
||||
import org.openhab.core.model.sitemap.sitemap.Colortemperaturepicker
|
||||
import org.openhab.core.model.sitemap.sitemap.Frame
|
||||
import org.openhab.core.model.sitemap.sitemap.LinkableWidget
|
||||
import org.openhab.core.model.sitemap.sitemap.Setpoint
|
||||
@ -143,6 +144,14 @@ class SitemapValidator extends AbstractSitemapValidator {
|
||||
}
|
||||
}
|
||||
|
||||
@Check
|
||||
def void checkColortemperaturepicker(Colortemperaturepicker ctp) {
|
||||
if (ctp.minValue !== null && ctp.maxValue !== null && ctp.minValue > ctp.maxValue) {
|
||||
error("Colortemperaturepicker on item '" + ctp.item + "' has larger minValue than maxValue",
|
||||
SitemapPackage.Literals.COLORTEMPERATUREPICKER.getEStructuralFeature(SitemapPackage.COLORTEMPERATUREPICKER__MIN_VALUE));
|
||||
}
|
||||
}
|
||||
|
||||
@Check
|
||||
def void checkInputHintParameter(Input i) {
|
||||
if (i.inputHint !== null && !ALLOWED_HINTS.contains(i.inputHint)) {
|
||||
|
@ -48,6 +48,7 @@ import org.openhab.core.model.sitemap.sitemap.impl.ButtongridImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.ChartImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.ColorArrayImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.ColorpickerImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.ColortemperaturepickerImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.ConditionImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.DefaultImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.FrameImpl;
|
||||
@ -88,6 +89,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author Laurent Garnier - Added icon field for mappings
|
||||
* @author Mark Herwege - Make UI provided sitemaps compatible with enhanced syntax in conditions
|
||||
* @author Mark Herwege - Add support for Button element
|
||||
* @author Laurent Garnier - Added support for new sitemap element Colortemperaturepicker
|
||||
*/
|
||||
@NonNullByDefault
|
||||
@Component(service = SitemapProvider.class)
|
||||
@ -267,6 +269,15 @@ public class UIComponentSitemapProvider implements SitemapProvider, RegistryChan
|
||||
ColorpickerImpl colorpickerWidget = (ColorpickerImpl) SitemapFactory.eINSTANCE.createColorpicker();
|
||||
widget = colorpickerWidget;
|
||||
break;
|
||||
case "Colortemperaturepicker":
|
||||
ColortemperaturepickerImpl colortemperaturepickerWidget = (ColortemperaturepickerImpl) SitemapFactory.eINSTANCE
|
||||
.createColortemperaturepicker();
|
||||
widget = colortemperaturepickerWidget;
|
||||
setWidgetPropertyFromComponentConfig(widget, component, "minValue",
|
||||
SitemapPackage.COLORTEMPERATUREPICKER__MIN_VALUE);
|
||||
setWidgetPropertyFromComponentConfig(widget, component, "maxValue",
|
||||
SitemapPackage.COLORTEMPERATUREPICKER__MAX_VALUE);
|
||||
break;
|
||||
case "Buttongrid":
|
||||
ButtongridImpl buttongridWidget = (ButtongridImpl) SitemapFactory.eINSTANCE.createButtongrid();
|
||||
addWidgetButtons(buttongridWidget.getButtons(), component);
|
||||
|
@ -112,6 +112,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author Laurent Garnier - Support added for multiple AND conditions in labelcolor/valuecolor/visibility
|
||||
* @author Laurent Garnier - new icon parameter based on conditional rules
|
||||
* @author Danny Baumann - widget label source support
|
||||
* @author Laurent Garnier - Consider Colortemperaturepicker element as possible default widget
|
||||
*/
|
||||
@NonNullByDefault
|
||||
@Component(immediate = true, configurationPid = "org.openhab.sitemap", //
|
||||
@ -302,6 +303,9 @@ public class ItemUIRegistryImpl implements ItemUIRegistry {
|
||||
}
|
||||
if (!isReadOnly && NumberItem.class.isAssignableFrom(itemType) && hasItemTag(itemName, "Setpoint")) {
|
||||
return SitemapFactory.eINSTANCE.createSetpoint();
|
||||
} else if (!isReadOnly && NumberItem.class.isAssignableFrom(itemType)
|
||||
&& hasItemTag(itemName, "ColorTemperature")) {
|
||||
return SitemapFactory.eINSTANCE.createColortemperaturepicker();
|
||||
} else {
|
||||
return SitemapFactory.eINSTANCE.createText();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user