From 60c3b883df39c567ce3f5cea8b17b972bca4cf93 Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Sat, 14 Mar 2015 15:16:36 -0700 Subject: [PATCH] Implemented ItemRegistry, ItemUIRegistry and ChartProvider support for the compatibility layer. This fixes #146. Signed-off-by: Kai Kreuzer (github: @kaikreuzer) --- .../META-INF/MANIFEST.MF | 12 +- .../OSGI-INF/chartproviderfactory.xml | 5 + .../OSGI-INF/itemuiregistry.xml | 9 + .../build.properties | 4 +- .../core/compat1x/internal/ItemMapper.java | 21 +- .../internal/ItemUIRegistryDelegate.java | 194 ++++++++++++++++++ .../io/net/http/SecureHttpContext.java | 60 ++++++ .../java/org/openhab/model/sitemap/Chart.java | 104 ++++++++++ .../org/openhab/model/sitemap/ColorArray.java | 159 ++++++++++++++ .../openhab/model/sitemap/Colorpicker.java | 50 +++++ .../java/org/openhab/model/sitemap/Frame.java | 18 ++ .../java/org/openhab/model/sitemap/Group.java | 18 ++ .../java/org/openhab/model/sitemap/Image.java | 95 +++++++++ .../openhab/model/sitemap/LinkableWidget.java | 41 ++++ .../java/org/openhab/model/sitemap/List.java | 50 +++++ .../org/openhab/model/sitemap/Mapping.java | 78 +++++++ .../model/sitemap/NonLinkableWidget.java | 18 ++ .../org/openhab/model/sitemap/Selection.java | 41 ++++ .../org/openhab/model/sitemap/Setpoint.java | 105 ++++++++++ .../org/openhab/model/sitemap/Sitemap.java | 122 +++++++++++ .../openhab/model/sitemap/SitemapModel.java | 19 ++ .../org/openhab/model/sitemap/Slider.java | 77 +++++++ .../org/openhab/model/sitemap/Switch.java | 41 ++++ .../java/org/openhab/model/sitemap/Text.java | 18 ++ .../java/org/openhab/model/sitemap/Video.java | 50 +++++ .../openhab/model/sitemap/VisibilityRule.java | 132 ++++++++++++ .../org/openhab/model/sitemap/Webview.java | 77 +++++++ .../org/openhab/model/sitemap/Widget.java | 158 ++++++++++++++ .../org/openhab/ui/chart/ChartProvider.java | 82 ++++++++ .../chart/internal/ChartProviderDelegate.java | 54 +++++ .../chart/internal/ChartProviderFactory.java | 82 ++++++++ .../org/openhab/ui/items/ItemUIProvider.java | 68 ++++++ .../org/openhab/ui/items/ItemUIRegistry.java | 158 ++++++++++++++ 33 files changed, 2216 insertions(+), 4 deletions(-) create mode 100644 bundles/core/org.openhab.core.compat1x/OSGI-INF/chartproviderfactory.xml create mode 100644 bundles/core/org.openhab.core.compat1x/OSGI-INF/itemuiregistry.xml create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/internal/ItemUIRegistryDelegate.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/http/SecureHttpContext.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Chart.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/ColorArray.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Colorpicker.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Frame.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Group.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Image.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/LinkableWidget.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/List.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Mapping.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/NonLinkableWidget.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Selection.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Setpoint.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Sitemap.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/SitemapModel.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Slider.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Switch.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Text.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Video.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/VisibilityRule.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Webview.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Widget.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/ChartProvider.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderDelegate.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderFactory.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIProvider.java create mode 100644 bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIRegistry.java diff --git a/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF b/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF index 6d01bf08436fd..2baaa40db92b1 100644 --- a/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF +++ b/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF @@ -19,8 +19,11 @@ Import-Package: com.google.common.base, org.apache.commons.io;version="2.0.1", org.apache.commons.lang, org.apache.commons.net.util, + org.eclipse.emf.common.util, + org.eclipse.emf.ecore, org.eclipse.emf.ecore.resource, org.eclipse.smarthome.core.autoupdate, + org.eclipse.smarthome.core.common.registry, org.eclipse.smarthome.core.events, org.eclipse.smarthome.core.items, org.eclipse.smarthome.core.library.items, @@ -32,6 +35,9 @@ Import-Package: com.google.common.base, org.eclipse.smarthome.core.types, org.eclipse.smarthome.io.multimedia.tts, org.eclipse.smarthome.model.item, + org.eclipse.smarthome.model.sitemap, + org.eclipse.smarthome.ui.chart, + org.eclipse.smarthome.ui.items, org.openhab.io.multimedia.actions, org.openhab.library.tel.types, org.osgi.framework, @@ -59,7 +65,9 @@ Export-Package: org.openhab.core.autoupdate, org.openhab.io.net.http, org.openhab.library.tel.items, org.openhab.library.tel.types, - org.openhab.model.item.binding + org.openhab.model.item.binding, + org.openhab.ui.chart, + org.openhab.ui.items Bundle-ClassPath: lib/jl1.0.1.jar, . -Service-Component: OSGI-INF/* +Service-Component: OSGI-INF/*.xml diff --git a/bundles/core/org.openhab.core.compat1x/OSGI-INF/chartproviderfactory.xml b/bundles/core/org.openhab.core.compat1x/OSGI-INF/chartproviderfactory.xml new file mode 100644 index 0000000000000..005406d4d87c9 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/OSGI-INF/chartproviderfactory.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bundles/core/org.openhab.core.compat1x/OSGI-INF/itemuiregistry.xml b/bundles/core/org.openhab.core.compat1x/OSGI-INF/itemuiregistry.xml new file mode 100644 index 0000000000000..0e23fdfb13724 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/OSGI-INF/itemuiregistry.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/bundles/core/org.openhab.core.compat1x/build.properties b/bundles/core/org.openhab.core.compat1x/build.properties index 52fd2a4448dc6..4a1f00dae8ebb 100644 --- a/bundles/core/org.openhab.core.compat1x/build.properties +++ b/bundles/core/org.openhab.core.compat1x/build.properties @@ -7,5 +7,7 @@ bin.includes = META-INF/,\ OSGI-INF/eventbridge.xml,\ OSGI-INF/eventpublisherdelegate.xml,\ OSGI-INF/bindingconfigreaderfactory.xml,\ - OSGI-INF/actionservicefactory.xml + OSGI-INF/actionservicefactory.xml,\ + OSGI-INF/itemuiregistry.xml,\ + OSGI-INF/chartproviderfactory.xml source.. = src/main/java/ diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/ItemMapper.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/ItemMapper.java index d9e93198c1aa0..7de31288823b2 100644 --- a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/ItemMapper.java +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/ItemMapper.java @@ -8,6 +8,7 @@ */ package org.openhab.core.compat1x.internal; +import org.eclipse.smarthome.core.items.GroupItem; import org.eclipse.smarthome.core.items.Item; import org.eclipse.smarthome.core.library.items.ColorItem; import org.eclipse.smarthome.core.library.items.ContactItem; @@ -34,7 +35,25 @@ public static org.openhab.core.items.Item mapToOpenHABItem(Item item) { if(item instanceof ColorItem) result = new org.openhab.core.library.items.ColorItem(item.getName()); if(item instanceof DateTimeItem) result = new org.openhab.core.library.items.DateTimeItem(item.getName()); if(item instanceof ESHCallItem) result = new org.openhab.library.tel.items.CallItem(item.getName()); - + + if(item instanceof GroupItem) { + GroupItem gItem = (GroupItem) item; + org.openhab.core.items.Item baseItem = ItemMapper.mapToOpenHABItem(gItem.getBaseItem()); + org.openhab.core.items.GroupItem ohgItem; + if(baseItem instanceof GenericItem) { + ohgItem = new org.openhab.core.items.GroupItem(item.getName(), (GenericItem) baseItem); + } else { + ohgItem = new org.openhab.core.items.GroupItem(item.getName()); + } + for(Item member : gItem.getMembers()) { + org.openhab.core.items.Item ohMember = ItemMapper.mapToOpenHABItem(member); + if(ohMember != null) { + ohgItem.addMember(ohMember); + } + } + result = ohgItem; + } + if(result instanceof org.openhab.core.items.GenericItem) { org.openhab.core.items.GenericItem genericItem = (GenericItem) result; if(item.getState()!=null) { diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/internal/ItemUIRegistryDelegate.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/internal/ItemUIRegistryDelegate.java new file mode 100644 index 0000000000000..8390d259700f4 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/internal/ItemUIRegistryDelegate.java @@ -0,0 +1,194 @@ +package org.openhab.core.items.internal; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.smarthome.core.common.registry.RegistryChangeListener; +import org.openhab.core.compat1x.internal.ItemMapper; +import org.openhab.core.items.Item; +import org.openhab.core.items.ItemNotFoundException; +import org.openhab.core.items.ItemNotUniqueException; +import org.openhab.core.items.ItemRegistryChangeListener; +import org.openhab.core.types.State; +import org.openhab.model.sitemap.LinkableWidget; +import org.openhab.model.sitemap.Sitemap; +import org.openhab.model.sitemap.Widget; +import org.openhab.ui.items.ItemUIRegistry; + +public class ItemUIRegistryDelegate implements ItemUIRegistry, RegistryChangeListener { + + private org.eclipse.smarthome.ui.items.ItemUIRegistry itemUIRegistry; + private Set listeners = new HashSet<>(); + + protected void setItemUIRegistry(org.eclipse.smarthome.ui.items.ItemUIRegistry itemUIRegistry) { + this.itemUIRegistry = itemUIRegistry; + itemUIRegistry.addRegistryChangeListener(this); + } + + protected void unsetItemUIRegistry(org.eclipse.smarthome.core.items.ItemRegistry itemUIRegistry) { + this.itemUIRegistry = null; + } + + @Override + public Item getItem(String name) throws ItemNotFoundException { + org.eclipse.smarthome.core.items.Item eshItem = itemUIRegistry.get(name); + return ItemMapper.mapToOpenHABItem(eshItem); + } + + @Override + public Item getItemByPattern(String name) throws ItemNotFoundException, ItemNotUniqueException { + org.eclipse.smarthome.core.items.Item eshItem; + try { + eshItem = itemUIRegistry.getItemByPattern(name); + } catch (org.eclipse.smarthome.core.items.ItemNotFoundException e) { + throw new ItemNotFoundException(name); + } catch (org.eclipse.smarthome.core.items.ItemNotUniqueException e) { + throw new ItemNotUniqueException(name, null); + } + return ItemMapper.mapToOpenHABItem(eshItem); + } + + @Override + public Collection getItems() { + Collection eshItems = itemUIRegistry.getItems(); + Collection ohItems = new HashSet(eshItems.size()); + + for(org.eclipse.smarthome.core.items.Item eshItem : eshItems) { + ohItems.add(ItemMapper.mapToOpenHABItem(eshItem)); + } + return ohItems; + } + + @Override + public Collection getItems(String pattern) { + Collection eshItems = itemUIRegistry.getItems(pattern); + Collection ohItems = new HashSet(eshItems.size()); + + for(org.eclipse.smarthome.core.items.Item eshItem : eshItems) { + ohItems.add(ItemMapper.mapToOpenHABItem(eshItem)); + } + return ohItems; + } + + @Override + public boolean isValidItemName(String itemName) { + return itemUIRegistry.isValidItemName(itemName); + } + + @Override + public void addItemRegistryChangeListener(ItemRegistryChangeListener listener) { + this.listeners.add(listener); + } + + @Override + public void removeItemRegistryChangeListener(ItemRegistryChangeListener listener) { + this.listeners.remove(listener); + } + + @Override + public void added(org.eclipse.smarthome.core.items.Item element) { + Item ohItem = ItemMapper.mapToOpenHABItem(element); + for(ItemRegistryChangeListener listener : listeners) { + listener.itemAdded(ohItem); + } + } + + @Override + public void removed(org.eclipse.smarthome.core.items.Item element) { + Item ohItem = ItemMapper.mapToOpenHABItem(element); + for(ItemRegistryChangeListener listener : listeners) { + listener.itemRemoved(ohItem); + } + } + + @Override + public void updated(org.eclipse.smarthome.core.items.Item oldElement, org.eclipse.smarthome.core.items.Item element) { + Item ohItem = ItemMapper.mapToOpenHABItem(element); + for(ItemRegistryChangeListener listener : listeners) { + listener.itemRemoved(ohItem); + listener.itemAdded(ohItem); + } + } + + @Override + public String getIcon(String itemName) { + return itemUIRegistry.getIcon(itemName); + } + + @Override + public String getLabel(String itemName) { + return itemUIRegistry.getLabel(itemName); + } + + @Override + public Widget getDefaultWidget(Class itemType, String itemName) { + return null; + } + + @Override + public Widget getWidget(String itemName) { + return null; + } + + @Override + public String getLabel(Widget w) { + return itemUIRegistry.getLabel(w.getItem()); + } + + @Override + public String getIcon(Widget w) { + return itemUIRegistry.getIcon(w.getItem()); + } + + @Override + public State getState(Widget w) { + return null; + } + + @Override + public Widget getWidget(Sitemap sitemap, String id) { + return null; + } + + @Override + public String getWidgetId(Widget w) { + return null; + } + + @Override + public EList getChildren(LinkableWidget w) { + return null; + } + + @Override + public boolean iconExists(String icon) { + return itemUIRegistry.iconExists(icon); + } + + @Override + public String getLabelColor(Widget w) { + return null; + } + + @Override + public String getValueColor(Widget w) { + return null; + } + + @Override + public boolean getVisiblity(Widget w) { + return true; + } + + @Override + public State getItemState(String itemName) { + try { + return getItem(itemName).getState(); + } catch (ItemNotFoundException e) { + return null; + } + } + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/http/SecureHttpContext.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/http/SecureHttpContext.java new file mode 100644 index 0000000000000..8132a2179a4c8 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/http/SecureHttpContext.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2010-2014, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.io.net.http; + +import java.io.IOException; +import java.net.URL; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.osgi.service.http.HttpContext; + + +/** + * Implementation of {@link HttpContext} which adds Basic-Authentication + * functionality to openHAB. + * + * @author Thomas.Eichstaedt-Engelen + * @since 0.9.0 + */ +public class SecureHttpContext implements HttpContext { + + private HttpContext defaultContext = null; + + public SecureHttpContext() { + } + + public SecureHttpContext(HttpContext defaultContext, final String realm) { + this.defaultContext = defaultContext; + } + + + /** + *

@{inheritDoc}

+ *

Delegates to defaultContext.getMimeType() + */ + public String getMimeType(String name) { + return this.defaultContext.getMimeType(name); + } + + /** + *

@{inheritDoc}

+ *

Delegates to defaultContext.getResource() + */ + public URL getResource(String name) { + return this.defaultContext.getResource(name); + } + + @Override + public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException { + return true; + } + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Chart.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Chart.java new file mode 100644 index 0000000000000..b0f21c3e29b77 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Chart.java @@ -0,0 +1,104 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Chart'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Chart#getService Service}
  • + *
  • {@link org.openhab.model.sitemap.Chart#getRefresh Refresh}
  • + *
  • {@link org.openhab.model.sitemap.Chart#getPeriod Period}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getChart() + * @model + * @generated + */ +public interface Chart extends NonLinkableWidget +{ + /** + * Returns the value of the 'Service' attribute. + * + *

+ * If the meaning of the 'Service' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Service' attribute. + * @see #setService(String) + * @see org.openhab.model.sitemap.SitemapPackage#getChart_Service() + * @model + * @generated + */ + String getService(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Chart#getService Service}' attribute. + * + * + * @param value the new value of the 'Service' attribute. + * @see #getService() + * @generated + */ + void setService(String value); + + /** + * Returns the value of the 'Refresh' attribute. + * + *

+ * If the meaning of the 'Refresh' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Refresh' attribute. + * @see #setRefresh(int) + * @see org.openhab.model.sitemap.SitemapPackage#getChart_Refresh() + * @model + * @generated + */ + int getRefresh(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Chart#getRefresh Refresh}' attribute. + * + * + * @param value the new value of the 'Refresh' attribute. + * @see #getRefresh() + * @generated + */ + void setRefresh(int value); + + /** + * Returns the value of the 'Period' attribute. + * + *

+ * If the meaning of the 'Period' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Period' attribute. + * @see #setPeriod(String) + * @see org.openhab.model.sitemap.SitemapPackage#getChart_Period() + * @model + * @generated + */ + String getPeriod(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Chart#getPeriod Period}' attribute. + * + * + * @param value the new value of the 'Period' attribute. + * @see #getPeriod() + * @generated + */ + void setPeriod(String value); + +} // Chart diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/ColorArray.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/ColorArray.java new file mode 100644 index 0000000000000..8d4b59727f375 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/ColorArray.java @@ -0,0 +1,159 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Color Array'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.ColorArray#getItem Item}
  • + *
  • {@link org.openhab.model.sitemap.ColorArray#getCondition Condition}
  • + *
  • {@link org.openhab.model.sitemap.ColorArray#getSign Sign}
  • + *
  • {@link org.openhab.model.sitemap.ColorArray#getState State}
  • + *
  • {@link org.openhab.model.sitemap.ColorArray#getArg Arg}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray() + * @model + * @generated + */ +public interface ColorArray extends EObject +{ + /** + * Returns the value of the 'Item' attribute. + * + *

+ * If the meaning of the 'Item' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Item' attribute. + * @see #setItem(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Item() + * @model + * @generated + */ + String getItem(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getItem Item}' attribute. + * + * + * @param value the new value of the 'Item' attribute. + * @see #getItem() + * @generated + */ + void setItem(String value); + + /** + * Returns the value of the 'Condition' attribute. + * + *

+ * If the meaning of the 'Condition' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Condition' attribute. + * @see #setCondition(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Condition() + * @model + * @generated + */ + String getCondition(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getCondition Condition}' attribute. + * + * + * @param value the new value of the 'Condition' attribute. + * @see #getCondition() + * @generated + */ + void setCondition(String value); + + /** + * Returns the value of the 'Sign' attribute. + * + *

+ * If the meaning of the 'Sign' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Sign' attribute. + * @see #setSign(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Sign() + * @model + * @generated + */ + String getSign(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getSign Sign}' attribute. + * + * + * @param value the new value of the 'Sign' attribute. + * @see #getSign() + * @generated + */ + void setSign(String value); + + /** + * Returns the value of the 'State' attribute. + * + *

+ * If the meaning of the 'State' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'State' attribute. + * @see #setState(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_State() + * @model + * @generated + */ + String getState(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getState State}' attribute. + * + * + * @param value the new value of the 'State' attribute. + * @see #getState() + * @generated + */ + void setState(String value); + + /** + * Returns the value of the 'Arg' attribute. + * + *

+ * If the meaning of the 'Arg' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Arg' attribute. + * @see #setArg(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Arg() + * @model + * @generated + */ + String getArg(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getArg Arg}' attribute. + * + * + * @param value the new value of the 'Arg' attribute. + * @see #getArg() + * @generated + */ + void setArg(String value); + +} // ColorArray diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Colorpicker.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Colorpicker.java new file mode 100644 index 0000000000000..a3ec46013c6d1 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Colorpicker.java @@ -0,0 +1,50 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Colorpicker'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Colorpicker#getFrequency Frequency}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getColorpicker() + * @model + * @generated + */ +public interface Colorpicker extends NonLinkableWidget +{ + /** + * Returns the value of the 'Frequency' attribute. + * + *

+ * If the meaning of the 'Frequency' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Frequency' attribute. + * @see #setFrequency(int) + * @see org.openhab.model.sitemap.SitemapPackage#getColorpicker_Frequency() + * @model + * @generated + */ + int getFrequency(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Colorpicker#getFrequency Frequency}' attribute. + * + * + * @param value the new value of the 'Frequency' attribute. + * @see #getFrequency() + * @generated + */ + void setFrequency(int value); + +} // Colorpicker diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Frame.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Frame.java new file mode 100644 index 0000000000000..0d7ab945a6242 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Frame.java @@ -0,0 +1,18 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Frame'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getFrame() + * @model + * @generated + */ +public interface Frame extends LinkableWidget +{ +} // Frame diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Group.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Group.java new file mode 100644 index 0000000000000..5de36047d1db8 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Group.java @@ -0,0 +1,18 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Group'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getGroup() + * @model + * @generated + */ +public interface Group extends LinkableWidget +{ +} // Group diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Image.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Image.java new file mode 100644 index 0000000000000..50c3f3e5ce634 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Image.java @@ -0,0 +1,95 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Image'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Image#getUrl Url}
  • + *
  • {@link org.openhab.model.sitemap.Image#getRefresh Refresh}
  • + *
  • {@link org.openhab.model.sitemap.Image#getIconColor Icon Color}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getImage() + * @model + * @generated + */ +public interface Image extends LinkableWidget +{ + /** + * Returns the value of the 'Url' attribute. + * + *

+ * If the meaning of the 'Url' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Url' attribute. + * @see #setUrl(String) + * @see org.openhab.model.sitemap.SitemapPackage#getImage_Url() + * @model + * @generated + */ + String getUrl(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Image#getUrl Url}' attribute. + * + * + * @param value the new value of the 'Url' attribute. + * @see #getUrl() + * @generated + */ + void setUrl(String value); + + /** + * Returns the value of the 'Refresh' attribute. + * + *

+ * If the meaning of the 'Refresh' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Refresh' attribute. + * @see #setRefresh(int) + * @see org.openhab.model.sitemap.SitemapPackage#getImage_Refresh() + * @model + * @generated + */ + int getRefresh(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Image#getRefresh Refresh}' attribute. + * + * + * @param value the new value of the 'Refresh' attribute. + * @see #getRefresh() + * @generated + */ + void setRefresh(int value); + + /** + * Returns the value of the 'Icon Color' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.ColorArray}. + * + *

+ * If the meaning of the 'Icon Color' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Icon Color' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getImage_IconColor() + * @model containment="true" + * @generated + */ + EList getIconColor(); + +} // Image diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/LinkableWidget.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/LinkableWidget.java new file mode 100644 index 0000000000000..43236894c2646 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/LinkableWidget.java @@ -0,0 +1,41 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Linkable Widget'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.LinkableWidget#getChildren Children}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getLinkableWidget() + * @model + * @generated + */ +public interface LinkableWidget extends Widget +{ + /** + * Returns the value of the 'Children' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.Widget}. + * + *

+ * If the meaning of the 'Children' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Children' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getLinkableWidget_Children() + * @model containment="true" + * @generated + */ + EList getChildren(); + +} // LinkableWidget diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/List.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/List.java new file mode 100644 index 0000000000000..6b9ab068650b6 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/List.java @@ -0,0 +1,50 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'List'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.List#getSeparator Separator}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getList() + * @model + * @generated + */ +public interface List extends NonLinkableWidget +{ + /** + * Returns the value of the 'Separator' attribute. + * + *

+ * If the meaning of the 'Separator' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Separator' attribute. + * @see #setSeparator(String) + * @see org.openhab.model.sitemap.SitemapPackage#getList_Separator() + * @model + * @generated + */ + String getSeparator(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.List#getSeparator Separator}' attribute. + * + * + * @param value the new value of the 'Separator' attribute. + * @see #getSeparator() + * @generated + */ + void setSeparator(String value); + +} // List diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Mapping.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Mapping.java new file mode 100644 index 0000000000000..3b66359020802 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Mapping.java @@ -0,0 +1,78 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Mapping'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Mapping#getCmd Cmd}
  • + *
  • {@link org.openhab.model.sitemap.Mapping#getLabel Label}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getMapping() + * @model + * @generated + */ +public interface Mapping extends EObject +{ + /** + * Returns the value of the 'Cmd' attribute. + * + *

+ * If the meaning of the 'Cmd' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Cmd' attribute. + * @see #setCmd(String) + * @see org.openhab.model.sitemap.SitemapPackage#getMapping_Cmd() + * @model + * @generated + */ + String getCmd(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getCmd Cmd}' attribute. + * + * + * @param value the new value of the 'Cmd' attribute. + * @see #getCmd() + * @generated + */ + void setCmd(String value); + + /** + * Returns the value of the 'Label' attribute. + * + *

+ * If the meaning of the 'Label' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label' attribute. + * @see #setLabel(String) + * @see org.openhab.model.sitemap.SitemapPackage#getMapping_Label() + * @model + * @generated + */ + String getLabel(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getLabel Label}' attribute. + * + * + * @param value the new value of the 'Label' attribute. + * @see #getLabel() + * @generated + */ + void setLabel(String value); + +} // Mapping diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/NonLinkableWidget.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/NonLinkableWidget.java new file mode 100644 index 0000000000000..a44084587a4e3 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/NonLinkableWidget.java @@ -0,0 +1,18 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Non Linkable Widget'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getNonLinkableWidget() + * @model + * @generated + */ +public interface NonLinkableWidget extends Widget +{ +} // NonLinkableWidget diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Selection.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Selection.java new file mode 100644 index 0000000000000..36784aafcc822 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Selection.java @@ -0,0 +1,41 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Selection'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Selection#getMappings Mappings}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSelection() + * @model + * @generated + */ +public interface Selection extends NonLinkableWidget +{ + /** + * Returns the value of the 'Mappings' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.Mapping}. + * + *

+ * If the meaning of the 'Mappings' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Mappings' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getSelection_Mappings() + * @model containment="true" + * @generated + */ + EList getMappings(); + +} // Selection diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Setpoint.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Setpoint.java new file mode 100644 index 0000000000000..bca7016396af5 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Setpoint.java @@ -0,0 +1,105 @@ +/** + */ +package org.openhab.model.sitemap; + +import java.math.BigDecimal; + +/** + * + * A representation of the model object 'Setpoint'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Setpoint#getMinValue Min Value}
  • + *
  • {@link org.openhab.model.sitemap.Setpoint#getMaxValue Max Value}
  • + *
  • {@link org.openhab.model.sitemap.Setpoint#getStep Step}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSetpoint() + * @model + * @generated + */ +public interface Setpoint extends NonLinkableWidget +{ + /** + * Returns the value of the 'Min Value' attribute. + * + *

+ * If the meaning of the 'Min Value' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Min Value' attribute. + * @see #setMinValue(BigDecimal) + * @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MinValue() + * @model + * @generated + */ + BigDecimal getMinValue(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMinValue Min Value}' attribute. + * + * + * @param value the new value of the 'Min Value' attribute. + * @see #getMinValue() + * @generated + */ + void setMinValue(BigDecimal value); + + /** + * Returns the value of the 'Max Value' attribute. + * + *

+ * If the meaning of the 'Max Value' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Max Value' attribute. + * @see #setMaxValue(BigDecimal) + * @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MaxValue() + * @model + * @generated + */ + BigDecimal getMaxValue(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMaxValue Max Value}' attribute. + * + * + * @param value the new value of the 'Max Value' attribute. + * @see #getMaxValue() + * @generated + */ + void setMaxValue(BigDecimal value); + + /** + * Returns the value of the 'Step' attribute. + * + *

+ * If the meaning of the 'Step' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Step' attribute. + * @see #setStep(BigDecimal) + * @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_Step() + * @model + * @generated + */ + BigDecimal getStep(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getStep Step}' attribute. + * + * + * @param value the new value of the 'Step' attribute. + * @see #getStep() + * @generated + */ + void setStep(BigDecimal value); + +} // Setpoint diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Sitemap.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Sitemap.java new file mode 100644 index 0000000000000..c01b333876df2 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Sitemap.java @@ -0,0 +1,122 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Sitemap'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Sitemap#getName Name}
  • + *
  • {@link org.openhab.model.sitemap.Sitemap#getLabel Label}
  • + *
  • {@link org.openhab.model.sitemap.Sitemap#getIcon Icon}
  • + *
  • {@link org.openhab.model.sitemap.Sitemap#getChildren Children}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap() + * @model + * @generated + */ +public interface Sitemap extends SitemapModel +{ + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Name() + * @model + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the 'Label' attribute. + * + *

+ * If the meaning of the 'Label' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label' attribute. + * @see #setLabel(String) + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Label() + * @model + * @generated + */ + String getLabel(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getLabel Label}' attribute. + * + * + * @param value the new value of the 'Label' attribute. + * @see #getLabel() + * @generated + */ + void setLabel(String value); + + /** + * Returns the value of the 'Icon' attribute. + * + *

+ * If the meaning of the 'Icon' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Icon' attribute. + * @see #setIcon(String) + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Icon() + * @model + * @generated + */ + String getIcon(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getIcon Icon}' attribute. + * + * + * @param value the new value of the 'Icon' attribute. + * @see #getIcon() + * @generated + */ + void setIcon(String value); + + /** + * Returns the value of the 'Children' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.Widget}. + * + *

+ * If the meaning of the 'Children' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Children' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Children() + * @model containment="true" + * @generated + */ + EList getChildren(); + +} // Sitemap diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/SitemapModel.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/SitemapModel.java new file mode 100644 index 0000000000000..19ff030deecf9 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/SitemapModel.java @@ -0,0 +1,19 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Model'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getSitemapModel() + * @model + * @generated + */ +public interface SitemapModel extends EObject +{ +} // SitemapModel diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Slider.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Slider.java new file mode 100644 index 0000000000000..135b055b7f3c4 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Slider.java @@ -0,0 +1,77 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Slider'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Slider#getFrequency Frequency}
  • + *
  • {@link org.openhab.model.sitemap.Slider#isSwitchEnabled Switch Enabled}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSlider() + * @model + * @generated + */ +public interface Slider extends NonLinkableWidget +{ + /** + * Returns the value of the 'Frequency' attribute. + * + *

+ * If the meaning of the 'Frequency' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Frequency' attribute. + * @see #setFrequency(int) + * @see org.openhab.model.sitemap.SitemapPackage#getSlider_Frequency() + * @model + * @generated + */ + int getFrequency(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Slider#getFrequency Frequency}' attribute. + * + * + * @param value the new value of the 'Frequency' attribute. + * @see #getFrequency() + * @generated + */ + void setFrequency(int value); + + /** + * Returns the value of the 'Switch Enabled' attribute. + * + *

+ * If the meaning of the 'Switch Enabled' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Switch Enabled' attribute. + * @see #setSwitchEnabled(boolean) + * @see org.openhab.model.sitemap.SitemapPackage#getSlider_SwitchEnabled() + * @model + * @generated + */ + boolean isSwitchEnabled(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Slider#isSwitchEnabled Switch Enabled}' attribute. + * + * + * @param value the new value of the 'Switch Enabled' attribute. + * @see #isSwitchEnabled() + * @generated + */ + void setSwitchEnabled(boolean value); + +} // Slider diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Switch.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Switch.java new file mode 100644 index 0000000000000..9e25290d7d256 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Switch.java @@ -0,0 +1,41 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Switch'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Switch#getMappings Mappings}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSwitch() + * @model + * @generated + */ +public interface Switch extends NonLinkableWidget +{ + /** + * Returns the value of the 'Mappings' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.Mapping}. + * + *

+ * If the meaning of the 'Mappings' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Mappings' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getSwitch_Mappings() + * @model containment="true" + * @generated + */ + EList getMappings(); + +} // Switch diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Text.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Text.java new file mode 100644 index 0000000000000..07c57d5676db1 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Text.java @@ -0,0 +1,18 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Text'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getText() + * @model + * @generated + */ +public interface Text extends LinkableWidget +{ +} // Text diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Video.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Video.java new file mode 100644 index 0000000000000..379a1bee0df93 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Video.java @@ -0,0 +1,50 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Video'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Video#getUrl Url}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getVideo() + * @model + * @generated + */ +public interface Video extends NonLinkableWidget +{ + /** + * Returns the value of the 'Url' attribute. + * + *

+ * If the meaning of the 'Url' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Url' attribute. + * @see #setUrl(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVideo_Url() + * @model + * @generated + */ + String getUrl(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Video#getUrl Url}' attribute. + * + * + * @param value the new value of the 'Url' attribute. + * @see #getUrl() + * @generated + */ + void setUrl(String value); + +} // Video diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/VisibilityRule.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/VisibilityRule.java new file mode 100644 index 0000000000000..3eac63a984020 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/VisibilityRule.java @@ -0,0 +1,132 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Visibility Rule'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.VisibilityRule#getItem Item}
  • + *
  • {@link org.openhab.model.sitemap.VisibilityRule#getCondition Condition}
  • + *
  • {@link org.openhab.model.sitemap.VisibilityRule#getSign Sign}
  • + *
  • {@link org.openhab.model.sitemap.VisibilityRule#getState State}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule() + * @model + * @generated + */ +public interface VisibilityRule extends EObject +{ + /** + * Returns the value of the 'Item' attribute. + * + *

+ * If the meaning of the 'Item' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Item' attribute. + * @see #setItem(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Item() + * @model + * @generated + */ + String getItem(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getItem Item}' attribute. + * + * + * @param value the new value of the 'Item' attribute. + * @see #getItem() + * @generated + */ + void setItem(String value); + + /** + * Returns the value of the 'Condition' attribute. + * + *

+ * If the meaning of the 'Condition' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Condition' attribute. + * @see #setCondition(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Condition() + * @model + * @generated + */ + String getCondition(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getCondition Condition}' attribute. + * + * + * @param value the new value of the 'Condition' attribute. + * @see #getCondition() + * @generated + */ + void setCondition(String value); + + /** + * Returns the value of the 'Sign' attribute. + * + *

+ * If the meaning of the 'Sign' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Sign' attribute. + * @see #setSign(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Sign() + * @model + * @generated + */ + String getSign(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getSign Sign}' attribute. + * + * + * @param value the new value of the 'Sign' attribute. + * @see #getSign() + * @generated + */ + void setSign(String value); + + /** + * Returns the value of the 'State' attribute. + * + *

+ * If the meaning of the 'State' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'State' attribute. + * @see #setState(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_State() + * @model + * @generated + */ + String getState(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getState State}' attribute. + * + * + * @param value the new value of the 'State' attribute. + * @see #getState() + * @generated + */ + void setState(String value); + +} // VisibilityRule diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Webview.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Webview.java new file mode 100644 index 0000000000000..4ec866416fa22 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Webview.java @@ -0,0 +1,77 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Webview'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Webview#getHeight Height}
  • + *
  • {@link org.openhab.model.sitemap.Webview#getUrl Url}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getWebview() + * @model + * @generated + */ +public interface Webview extends NonLinkableWidget +{ + /** + * Returns the value of the 'Height' attribute. + * + *

+ * If the meaning of the 'Height' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Height' attribute. + * @see #setHeight(int) + * @see org.openhab.model.sitemap.SitemapPackage#getWebview_Height() + * @model + * @generated + */ + int getHeight(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Webview#getHeight Height}' attribute. + * + * + * @param value the new value of the 'Height' attribute. + * @see #getHeight() + * @generated + */ + void setHeight(int value); + + /** + * Returns the value of the 'Url' attribute. + * + *

+ * If the meaning of the 'Url' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Url' attribute. + * @see #setUrl(String) + * @see org.openhab.model.sitemap.SitemapPackage#getWebview_Url() + * @model + * @generated + */ + String getUrl(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Webview#getUrl Url}' attribute. + * + * + * @param value the new value of the 'Url' attribute. + * @see #getUrl() + * @generated + */ + void setUrl(String value); + +} // Webview diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Widget.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Widget.java new file mode 100644 index 0000000000000..9cbd6342370b2 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Widget.java @@ -0,0 +1,158 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Widget'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Widget#getItem Item}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getLabel Label}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getIcon Icon}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getLabelColor Label Color}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getValueColor Value Color}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getVisibility Visibility}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getWidget() + * @model + * @generated + */ +public interface Widget extends EObject +{ + /** + * Returns the value of the 'Item' attribute. + * + *

+ * If the meaning of the 'Item' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Item' attribute. + * @see #setItem(String) + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Item() + * @model + * @generated + */ + String getItem(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getItem Item}' attribute. + * + * + * @param value the new value of the 'Item' attribute. + * @see #getItem() + * @generated + */ + void setItem(String value); + + /** + * Returns the value of the 'Label' attribute. + * + *

+ * If the meaning of the 'Label' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label' attribute. + * @see #setLabel(String) + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Label() + * @model + * @generated + */ + String getLabel(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getLabel Label}' attribute. + * + * + * @param value the new value of the 'Label' attribute. + * @see #getLabel() + * @generated + */ + void setLabel(String value); + + /** + * Returns the value of the 'Icon' attribute. + * + *

+ * If the meaning of the 'Icon' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Icon' attribute. + * @see #setIcon(String) + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Icon() + * @model + * @generated + */ + String getIcon(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getIcon Icon}' attribute. + * + * + * @param value the new value of the 'Icon' attribute. + * @see #getIcon() + * @generated + */ + void setIcon(String value); + + /** + * Returns the value of the 'Label Color' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.ColorArray}. + * + *

+ * If the meaning of the 'Label Color' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label Color' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_LabelColor() + * @model containment="true" + * @generated + */ + EList getLabelColor(); + + /** + * Returns the value of the 'Value Color' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.ColorArray}. + * + *

+ * If the meaning of the 'Value Color' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Value Color' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_ValueColor() + * @model containment="true" + * @generated + */ + EList getValueColor(); + + /** + * Returns the value of the 'Visibility' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.VisibilityRule}. + * + *

+ * If the meaning of the 'Visibility' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Visibility' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Visibility() + * @model containment="true" + * @generated + */ + EList getVisibility(); + +} // Widget diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/ChartProvider.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/ChartProvider.java new file mode 100644 index 0000000000000..17dfeb5f8ae2f --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/ChartProvider.java @@ -0,0 +1,82 @@ +package org.openhab.ui.chart; + +import java.awt.image.BufferedImage; +import java.util.Date; + +import org.openhab.core.items.ItemNotFoundException; + +/** + * Defines the interface for chart providers. A chart provider interfaces with + * the persistence store to get the data and receives parameters from the UI + * chart servlet and returns a chart image object (PNG). + * + * @author Chris Jackson + * @since 1.4.0 + * + * + */ +public interface ChartProvider { + /** + * Gets the name of this chart provider. + * + * @return String containing the provider name + */ + String getName(); + + /** + * Creates a chart object. This sets the initial parameters for the chart + * before the items are added + * + * @param service + * A string containing the name of the persistence service. May + * be null in which case the chart provider can decide itself + * which store to use. + * @param widget + * The widget ID. This allows the chart provider to look up the + * widget and get the items directly from the sitemap definition. + * May be null. + * @param theme + * A string containing a theme name for the chart. The provider + * should store its own themes. May be null to use a default + * theme. + * @param height + * The height of the chart. + * @param width + * The width of the chart. + * @param startTime + * The start time of the chart + * @param endTime + * The end time of the chart + * @param height + * The height of the chart + * @param width + * The width of the chart + * @param items + * The items to display on the chart + * @param groups + * The groups to display on the chart + * + * @return BufferedImage object if the chart is rendered correctly, + * otherwise null. + * + * @throws ItemNotFoundException if an item or group is not found + * @throws IllegalArgumentException if an invalid argument is passed + */ + BufferedImage createChart(String service, String theme, Date startTime, Date endTime, int height, + int width, String items, String groups) throws ItemNotFoundException; + + /** + * Gets the type of data that will be written by the chart. + * + * @return ImageType + */ + ImageType getChartType(); + + /** + * Provides a list of image types + * + */ + public enum ImageType { + png, jpg, gif; + } +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderDelegate.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderDelegate.java new file mode 100644 index 0000000000000..e6c0338db2c17 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderDelegate.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.ui.chart.internal; + +import java.awt.image.BufferedImage; +import java.util.Date; + +import org.apache.commons.lang.StringUtils; +import org.eclipse.smarthome.core.items.ItemNotFoundException; +import org.openhab.ui.chart.ChartProvider; + + +/** + * This class serves as a mapping from the "old" org.openhab namespace to the new org.eclipse.smarthome + * namespace for the action service. It wraps an instance with the old interface + * into a class with the new interface. + * + * @author Kai Kreuzer - Initial contribution and API + */ +public class ChartProviderDelegate implements org.eclipse.smarthome.ui.chart.ChartProvider { + + private ChartProvider provider; + + public ChartProviderDelegate(ChartProvider chartProvider) { + this.provider = chartProvider; + } + + @Override + public String getName() { + return provider.getName(); + } + + @Override + public BufferedImage createChart(String service, String theme, Date startTime, Date endTime, int height, int width, + String items, String groups) throws ItemNotFoundException { + try { + return provider.createChart(service, theme, startTime, endTime, height, width, items, groups); + } catch (org.openhab.core.items.ItemNotFoundException e) { + throw new ItemNotFoundException(StringUtils.substringBetween(e.getMessage(), "'")); + } + } + + @Override + public ImageType getChartType() { + return ImageType.valueOf(provider.getChartType().name()); + } + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderFactory.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderFactory.java new file mode 100644 index 0000000000000..393e9664c0c1d --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderFactory.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.ui.chart.internal; + +import java.util.Dictionary; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Map; +import java.util.Set; + +import org.openhab.ui.chart.ChartProvider; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +/** + * This class listens for services that implement the old chart provider service interface and registers + * an according service for each under the new interface. + * + * @author Kai Kreuzer - Initial contribution and API + */ +public class ChartProviderFactory { + + private Map> delegates = new HashMap<>(); + private BundleContext context; + + private Set chartProviders = new HashSet<>(); + + public void activate(BundleContext context) { + this.context = context; + for(ChartProvider provider : chartProviders) { + registerDelegateProvider(provider); + } + } + + public void deactivate() { + for(ServiceRegistration serviceReg : delegates.values()) { + serviceReg.unregister(); + } + delegates.clear(); + this.context = null; + } + + public void addChartProvider(ChartProvider provider) { + if(context!=null) { + registerDelegateProvider(provider); + } else { + chartProviders.add(provider); + } + } + + public void removeChartProvider(ChartProvider provider) { + if(context!=null) { + unregisterDelegateProvider(provider); + } + } + + private void registerDelegateProvider(ChartProvider chartProvider) { + if(!delegates.containsKey(chartProvider.getName())) { + ChartProviderDelegate service = new ChartProviderDelegate(chartProvider); + Dictionary props = new Hashtable(); + ServiceRegistration serviceReg = + context.registerService(org.eclipse.smarthome.ui.chart.ChartProvider.class, service, props); + delegates.put(chartProvider.getName(), serviceReg); + } + } + + private void unregisterDelegateProvider(ChartProvider chartProvider) { + if(delegates.containsKey(chartProvider.getName())) { + ServiceRegistration serviceReg = + delegates.get(chartProvider.getName()); + delegates.remove(chartProvider.getName()); + serviceReg.unregister(); + } + } +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIProvider.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIProvider.java new file mode 100644 index 0000000000000..6ea8ec247b8a7 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIProvider.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2010-2014, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.ui.items; + +import org.openhab.core.items.Item; +import org.openhab.model.sitemap.Widget; + + +/** + * This interface describes the methods that need to be implemented by a provider that + * wants to define the appearance of an item in the UI. + * + * @author Kai Kreuzer + * + */ +public interface ItemUIProvider { + + /** + * Returns the name of a bitmap to use as an icon. This name does not need to include + * state information or a file extension; if these are missing, they will be automatically added. + * + * TODO: Note that the consumer of this provider needs to be aware of these icons, so we + * have some implicit dependency between them. Maybe worth refactoring? + * + * @param itemName the name of the item to return the icon for + * @return the name of the icon to use or null if undefined. + */ + public String getIcon(String itemName); + + /** + * Returns the label text to be used for an item in the UI. + * + * @param item the name of the item to return the label text for + * @return the label text to be used in the UI or null if undefined. + */ + public String getLabel(String itemName); + + /** + * Provides a default widget for a given item (class). This is used whenever + * the UI needs to be created dynamically and there is no other source + * of information about the widgets. + * + * @param itemType the class of the item + * @param itemName the item name to get the default widget for + * + * @return a widget implementation that can be used for the given item + */ + public Widget getDefaultWidget(Class itemType, String itemName); + + /** + *

Provides a widget for a given item. This can be used to overwrite the widget + * listed in the sitemap. A use case for this is that the sitemap defines merely + * the parent-child-relation of widgets, but the concrete widget to be used for + * rendering might be selected dynamically at runtime.

+ *

If the sitemap widget should not be overridden, this method must return + * null.

+ * + * @param itemName the item name to get the widget for + * @return a widget to use for the given item or null if sitemap should not be overridden. + */ + public Widget getWidget(String itemName); +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIRegistry.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIRegistry.java new file mode 100644 index 0000000000000..f78376b53c90c --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIRegistry.java @@ -0,0 +1,158 @@ +/** + * Copyright (c) 2010-2014, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.ui.items; + +import org.eclipse.emf.common.util.EList; +import org.openhab.core.items.ItemRegistry; +import org.openhab.core.types.State; +import org.openhab.model.sitemap.LinkableWidget; +import org.openhab.model.sitemap.Sitemap; +import org.openhab.model.sitemap.Widget; + +/** + * This interface is used by a service which combines the core item registry + * with an aggregation of item ui providers; it can be therefore widely used for + * all UI related information requests regarding items. + * + * @author Kai Kreuzer + * @author Chris Jackson + * @since 0.8.0 + * + */ +public interface ItemUIRegistry extends ItemRegistry, ItemUIProvider { + + /** + * Retrieves the label for a widget. + * + * This first checks, if there is a label defined in the sitemap. If not, it + * checks all item UI providers for a label. If no label can be found, it is + * set to an empty string. + * + * If the label contains a "[%format]" section, i.e. + * “[%s]" for a string or "[%.3f]" for a decimal, this is replaced by the + * current value of the item and padded by a "" element. + * + * @param w + * the widget to retrieve the label for + * @return the label to use for the widget + */ + public String getLabel(Widget w); + + /** + * Retrieves the icon name for a widget. + * + * This first checks, if there is an icon defined in the sitemap. If not, if + * checks all item UI providers for an icon. If no icon can be found, the + * default icon name is the widget type name, e.g. "switch". + * + * If the icon name does not contain a "-" and has a state other than + * "undefined", its current state is appended to the icon name, e.g. + * "switch-on". If no such icon exists, the base icon ("switch") will be + * returned nonetheless. + * + * @param w + * the widget to retrieve the icon name for + * @return the icon name to use for the widget + */ + public String getIcon(Widget w); + + /** + * Retrieves the current state of the item of a widget or + * UnDefType.UNDEF. + * + * @param w + * the widget to retrieve the item state for + * @return the item state of the widget + */ + public State getState(Widget w); + + /** + * Retrieves the widget for a given id on a given sitemap. + * + * @param sitemap + * the sitemap to look for the widget + * @param id + * the id of the widget to look for + * @return the widget for the given id + */ + public Widget getWidget(Sitemap sitemap, String id); + + /** + * Provides an id for a widget. + * + * This constructs a string out of the position of the sitemap, so if this + * widget is the third child of a page linked from the fifth widget on the + * home screen, its id would be "0503". If the widget is dynamically created + * and not available in the sitemap, the name of its associated item is used + * instead. + * + * @param w + * the widget to get the id for + * @return an id for this widget + */ + public String getWidgetId(Widget w); + + /** + * this should be used instead of LinkableWidget.getChildren() as there + * might be no children defined on the widget, but they should be + * dynamically determined by looking at the members of the underlying item. + * + * @param w + * the widget to retrieve the children for + * @return the (dynamically or statically defined) children of the widget + */ + public EList getChildren(LinkableWidget w); + + /** + * Checks whether an icon with a given name exists + * + * @param icon + * the icon name to check + * @return true, if the icon exists + */ + public boolean iconExists(String icon); + + /** + * Gets the label color for the widget. Checks conditional statements to + * find the color based on the item value + * + * @param w + * Widget + * @return String with the color + */ + public String getLabelColor(Widget w); + + /** + * Gets the value color for the widget. Checks conditional statements to + * find the color based on the item value + * + * @param w + * Widget + * @return String with the color + */ + public String getValueColor(Widget w); + + /** + * Gets the widget visibility based on the item state + * + * @param w + * Widget + * @return true if the item is visible + */ + public boolean getVisiblity(Widget w); + + /** + * Gets the item state + * + * @param itemName + * item name + * @return State of the item + */ + public State getItemState(String itemName); +}