100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Work on attribute meta editor
Christian Bauer6d6ef2603a34
diff --git a/container/src/main/java/org/openremote/container/persistence/Database.java b/container/src/main/java/org/openremote/container/persistence/Database.javaindex bb86ee44f..840a454ba 100644--- a/container/src/main/java/org/openremote/container/persistence/Database.java+++ b/container/src/main/java/org/openremote/container/persistence/Database.java@@ -29,6 +29,9 @@ import java.util.Map;public interface Database {+ /**+ * @return Persistence unit properties used to call <code>Persistence.createEntityManagerFactory(persistenceUnitName, persistenceUnitProperties)</code>+ */Map<String, Object> open(String connectionUrl, String username, String password, int connectionTimeoutSeconds, int minIdle, int maxPoolSize);void close();diff --git a/container/src/main/java/org/openremote/container/persistence/UniqueIdentifierGenerator.java b/container/src/main/java/org/openremote/container/persistence/UniqueIdentifierGenerator.javaindex def02a991..8e9355186 100644--- a/container/src/main/java/org/openremote/container/persistence/UniqueIdentifierGenerator.java+++ b/container/src/main/java/org/openremote/container/persistence/UniqueIdentifierGenerator.java@@ -26,6 +26,10 @@ import org.openremote.container.util.IdentifierUtil;import java.io.Serializable;+/**+ * Generate a globally unique identifier value if the persisted entity instance is of+ * type {@link IdentifiableEntity} and if its {@link IdentifiableEntity#getId()} method returns <code>null</code>.+ */public class UniqueIdentifierGenerator implements IdentifierGenerator {@Overridediff --git a/manager/client/src/main/java/org/openremote/manager/client/app/dialog/DialogImpl.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/app/dialog/DialogImpl.ui.xmlindex 57ac16224..277c473b0 100644--- a/manager/client/src/main/java/org/openremote/manager/client/app/dialog/DialogImpl.ui.xml+++ b/manager/client/src/main/java/org/openremote/manager/client/app/dialog/DialogImpl.ui.xml@@ -8,6 +8,9 @@<ui:style>.popup {z-index: 10;+ -webkit-box-shadow: 2px 2px 3px 2px rgba(0, 0, 0, 0.15);+ -moz-box-shadow: 2px 2px 3px 2px rgba(0, 0, 0, 0.15);+ box-shadow: 2px 2px 3px 2px rgba(0, 0, 0, 0.15)}.header {diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/agent/AgentAttributesEditor.java b/manager/client/src/main/java/org/openremote/manager/client/assets/agent/AgentAttributesEditor.javaindex 78f32d572..f52a928ae 100644--- a/manager/client/src/main/java/org/openremote/manager/client/assets/agent/AgentAttributesEditor.java+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/agent/AgentAttributesEditor.java@@ -130,8 +130,8 @@ public class AgentAttributesEditor extends AttributesEditor<AttributesEditor.Sty}@Override- protected FormLabel buildFormLabel(Attribute attribute) {- FormLabel formLabel = super.buildFormLabel(attribute);+ protected FormLabel createFormLabel(Attribute attribute) {+ FormLabel formLabel = super.createFormLabel(attribute);if (attribute.getName().equals("enabled")) {formLabel.setText(environment.getMessages().enabled());}diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/device/DeviceAttributesEditor.java b/manager/client/src/main/java/org/openremote/manager/client/assets/device/DeviceAttributesEditor.javaindex f8c2fcd63..4d4713fd5 100644--- a/manager/client/src/main/java/org/openremote/manager/client/assets/device/DeviceAttributesEditor.java+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/device/DeviceAttributesEditor.java@@ -109,8 +109,8 @@ public class DeviceAttributesEditor extends AttributesEditor<DeviceAttributesEdi}@Override- protected FormLabel buildFormLabel(Attribute attribute) {- FormLabel formLabel = super.buildFormLabel(attribute);+ protected FormLabel createFormLabel(Attribute attribute) {+ FormLabel formLabel = super.createFormLabel(attribute);if (DeviceResource.isDeviceResource(attribute)) {DeviceResource deviceResource = new DeviceResource(attribute);@@ -199,6 +199,7 @@ public class DeviceAttributesEditor extends AttributesEditor<DeviceAttributesEdireturn DeviceAttributes.isReadOnly(attribute) || super.isDefaultReadOnly(attribute);}+/*@Overrideprotected FormInputText createStringEditor(Style style, Attribute attribute, boolean readOnly) {return super.createStringEditor(style, attribute, readOnly || DeviceResource.isDeviceResource(attribute));@@ -218,6 +219,7 @@ public class DeviceAttributesEditor extends AttributesEditor<DeviceAttributesEdiprotected FormCheckBox createBooleanEditor(Style style, Attribute attribute, boolean readOnly) {return super.createBooleanEditor(style, attribute, readOnly || DeviceResource.isDeviceResource(attribute));}+*/protected void enableLiveUpdates(boolean enable) {if (enable) {diff --git a/manager/client/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java b/manager/client/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.javaindex cb0aa0696..41c369881 100644--- a/manager/client/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java+++ b/manager/client/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java@@ -157,6 +157,8 @@ public interface ManagerMessages extends Messages {String unsupportedAttributeType(String name);+ String unsupportedMetaItemType(String jsonType);+String loadingAssets();String assetName();@@ -241,7 +243,13 @@ public interface ManagerMessages extends Messages {String deleteAttribute();- String editAttributeMeta();+ String showAttributeMeta();++ String hideAttributeMeta();String addAttribute();++ String itemName();++ String deleteItem();}diff --git a/manager/client/src/main/java/org/openremote/manager/client/widget/AttributesEditor.java b/manager/client/src/main/java/org/openremote/manager/client/widget/AttributesEditor.javaindex 14d679e18..0da7e90ea 100644--- a/manager/client/src/main/java/org/openremote/manager/client/widget/AttributesEditor.java+++ b/manager/client/src/main/java/org/openremote/manager/client/widget/AttributesEditor.java@@ -19,31 +19,33 @@*/package org.openremote.manager.client.widget;+import com.google.gwt.user.client.ui.FlowPanel;import com.google.gwt.user.client.ui.InsertPanel;+import com.google.gwt.user.client.ui.IsWidget;import com.google.gwt.user.client.ui.Label;import elemental.json.Json;-import org.openremote.model.Runnable;+import elemental.json.JsonValue;import org.openremote.manager.client.Environment;import org.openremote.manager.client.i18n.ManagerMessages;import org.openremote.manager.client.util.TextUtil;-import org.openremote.model.Attribute;-import org.openremote.model.AttributeType;-import org.openremote.model.Attributes;-import org.openremote.model.MetadataItem;+import org.openremote.manager.shared.event.ui.ShowInfoEvent;+import org.openremote.model.*;+import org.openremote.model.Runnable;+import org.openremote.model.asset.AssetAttributeMeta;import java.util.Arrays;import java.util.LinkedHashMap;import java.util.List;import java.util.logging.Logger;-import static org.openremote.model.asset.AssetAttributeMeta.*;import static org.openremote.manager.shared.util.Util.sortMap;+import static org.openremote.model.asset.AssetAttributeMeta.getFirstMetadataItemValue;public class AttributesEditor<S extends AttributesEditor.Style> {private static final Logger LOG = Logger.getLogger(AttributesEditor.class.getName());- public interface Container<S> {+ public interface Container<S extends AttributesEditor.Style> {FormView getFormView();S getStyle();@@ -100,27 +102,6 @@ public class AttributesEditor<S extends AttributesEditor.Style> {sortMap(formGroups, (a, b) -> a.getFormLabel().getText().compareTo(b.getFormLabel().getText()));}- /* TODO Finish attribute add/remove, metadata editing-- public void buildActionsFormGroup() {- FormGroup formGroup = new FormGroup();- FormButton addButton = new FormButton();- FormInputText newAttributeNameInput =new FormInputText();- addButton.addClickHandler(event -> {- if (newAttributeNameInput.getValue() != null) {- String attributeName = newAttributeNameInput.getValue();- if (!attributes.hasAttribute(attributeName)) {- Attribute newAttribute = new Attribute(attributeName, AttributeType.STRING);- attributes.add(newAttribute);- FormGroup newAttributeFormGroup = createFormGroup(newAttribute);- formGroups.add(newAttributeFormGroup);- container.add(newAttributeFormGroup);- }- }- });- }- */-public void build() {formGroups.clear();buildAttributeFormGroups();@@ -152,53 +133,39 @@ public class AttributesEditor<S extends AttributesEditor.Style> {FormGroup formGroup = new FormGroup();- FormLabel formLabel = buildFormLabel(attribute);+ FormLabel formLabel = createFormLabel(attribute);formGroup.addFormLabel(formLabel);- FormField attributeField = new FormField();- formGroup.addFormField(attributeField);-- if (attribute.getType().equals(AttributeType.STRING)) {- formGroup.getFormField().add(createStringEditor(container.getStyle(), attribute, isDefaultReadOnly(attribute)));- } else if (attribute.getType().equals(AttributeType.INTEGER)) {- formGroup.getFormField().add(createIntegerEditor(container.getStyle(), attribute, isDefaultReadOnly(attribute)));- } else if (attribute.getType().equals(AttributeType.DECIMAL)) {- formGroup.getFormField().add(createDecimalEditor(container.getStyle(), attribute, isDefaultReadOnly(attribute)));- } else if (attribute.getType().equals(AttributeType.BOOLEAN)) {- formGroup.getFormField().add(createBooleanEditor(container.getStyle(), attribute, isDefaultReadOnly(attribute)));- } else {- formGroup.getFormField().add(- new Label(environment.getMessages().unsupportedAttributeType(attribute.getType().getValue()))- );- }+ FormField formField = new FormField();+ formGroup.addFormField(formField);+ formField.add(createEditor(attribute));- MetadataItem description = getFirstMetadataItem(attribute, DESCRIPTION);+ MetadataItem description = AssetAttributeMeta.getFirstMetadataItem(attribute, AssetAttributeMeta.DESCRIPTION);if (description != null) {formGroup.addInfolabel(new Label(description.getValue().asString()));}- // TODO Finish actions/metadata editingFormGroupActions formGroupActions = new FormGroupActions();FormButton deleteButton = new FormButton();deleteButton.setText(container.getMessages().deleteAttribute());deleteButton.setIcon("remove");+ deleteButton.addClickHandler(clickEvent -> {+ environment.getEventBus().dispatch(new ShowInfoEvent("TODO: Not implemented"));+ });formGroupActions.add(deleteButton);- FormButton editMetaButton = new FormButton();- editMetaButton.setText(container.getMessages().editAttributeMeta());- editMetaButton.setIcon("edit");- formGroupActions.add(editMetaButton);+ formGroup.addFormGroupActions(formGroupActions);- formGroup.add(formGroupActions);+ addAttributeMetaEditor(attribute, formGroup);return formGroup;}- protected FormLabel buildFormLabel(Attribute attribute) {+ protected FormLabel createFormLabel(Attribute attribute) {FormLabel formLabel = new FormLabel();String label = attribute.getName();- MetadataItem labelItem = getFirstMetadataItem(attribute, LABEL);+ MetadataItem labelItem = AssetAttributeMeta.getFirstMetadataItem(attribute, AssetAttributeMeta.LABEL);if (labelItem != null) {label = labelItem.getValue().asString();}@@ -208,99 +175,165 @@ public class AttributesEditor<S extends AttributesEditor.Style> {return formLabel;}+ protected void addAttributeMetaEditor(Attribute attribute, FormGroup formGroup) {+ MetaEditor metaEditor = new MetaEditor(attribute);+ formGroup.addExtension(metaEditor);+ }+/* ####################################################################### */- protected FormInputText createStringEditor(S style, Attribute attribute, boolean readOnly) {+ protected IsWidget createEditor(Attribute attribute) {+ IsWidget editor;+ S style = container.getStyle();+ Consumer<JsonValue> updateConsumer = isDefaultReadOnly(attribute) ? null : attribute::setValue;+ JsonValue currentValue = attribute.getValue();+ JsonValue defaultValue = getFirstMetadataItemValue(attribute, AssetAttributeMeta.DEFAULT);++ if (attribute.getType().equals(AttributeType.STRING)) {+ editor = createStringEditor(style, currentValue, defaultValue, updateConsumer);+ } else if (attribute.getType().equals(AttributeType.INTEGER)) {+ editor = createIntegerEditor(style, currentValue, defaultValue, updateConsumer);+ } else if (attribute.getType().equals(AttributeType.DECIMAL)) {+ editor = createDecimalEditor(style, currentValue, defaultValue, updateConsumer);+ } else if (attribute.getType().equals(AttributeType.BOOLEAN)) {+ editor = createBooleanEditor(style, currentValue, defaultValue, updateConsumer);+ } else {+ FormField unsupportedField = new FormField();+ unsupportedField.add(new FormOutputText(+ environment.getMessages().unsupportedAttributeType(attribute.getType().getValue())+ ));+ editor = unsupportedField;+ }+ return editor;+ }++ protected IsWidget createEditor(MetadataItem item) {+ IsWidget editor;++ S style = container.getStyle();+ JsonValue currentValue = item.getValue();+ // For some metadata items we know if we can edit them or not... custom items are always editable+ Boolean isEditable = AssetAttributeMeta.isEditable(item.getName());+ Consumer<JsonValue> updateConsumer = isEditable != null && isEditable ? item::setValue : null;++ // TODO: We should support more JSON types, and have special editors for well-known meta items+ switch (currentValue.getType()) {+ case STRING:+ editor = createStringEditor(style, currentValue, null, updateConsumer);+ break;+ case NUMBER:+ editor = createIntegerEditor(style, currentValue, null, updateConsumer);+ break;+ case BOOLEAN:+ editor = createBooleanEditor(style, currentValue, null, updateConsumer);+ break;+ default:+ FormField unsupportedField = new FormField();+ unsupportedField.add(new FormOutputText(+ environment.getMessages().unsupportedMetaItemType(currentValue.getType().name())+ ));+ editor = unsupportedField;+ }+ return editor;+ }++ protected FormInputText createStringEditor(S style,+ JsonValue currentValue,+ JsonValue defaultValue,+ Consumer<JsonValue> updateConsumer) {FormInputText input = createFormInputText(style.attributeStringEditor());- MetadataItem defaultValue;- if (attribute.getValue() != null) {- input.setValue(attribute.getValue().asString());- } else if ((defaultValue = getFirstMetadataItem(attribute, DEFAULT)) != null) {- input.setValue(defaultValue.getValue().asString());+ if (currentValue != null) {+ input.setValue(currentValue.asString());+ } else if ((defaultValue) != null) {+ input.setValue(defaultValue.asString());}- if (readOnly) {- input.setReadOnly(true);- } else {+ if (updateConsumer != null) {input.addValueChangeHandler(- event -> attribute.setValue(+ event -> updateConsumer.accept(Json.create(event.getValue())));+ } else {+ input.setReadOnly(true);}return input;}- protected FormInputNumber createIntegerEditor(S style, Attribute attribute, boolean readOnly) {+ protected FormInputNumber createIntegerEditor(S style,+ JsonValue currentValue,+ JsonValue defaultValue,+ Consumer<JsonValue> updateConsumer) {FormInputNumber input = createFormInputNumber(style.attributeIntegerEditor());- MetadataItem defaultValue;- if (attribute.getValue() != null) {- input.setValue(attribute.getValue().asString());- } else if ((defaultValue = getFirstMetadataItem(attribute, DEFAULT)) != null) {- input.setValue(defaultValue.getValue().asString());+ if (currentValue != null) {+ input.setValue(currentValue.asString());+ } else if (defaultValue != null) {+ input.setValue(defaultValue.asString());}- if (readOnly) {- input.setReadOnly(true);- } else {+ if (updateConsumer != null) {input.addValueChangeHandler(event -> {try {Integer value = Integer.valueOf(event.getValue());- attribute.setValue(Json.create(value));+ updateConsumer.accept(Json.create(value));} catch (NumberFormatException ex) {// TODO Do nothing? can we hook this up into validation?}});+ } else {+ input.setReadOnly(true);}return input;}- protected FormInputText createDecimalEditor(S style, Attribute attribute, boolean readOnly) {+ protected FormInputText createDecimalEditor(S style,+ JsonValue currentValue,+ JsonValue defaultValue,+ Consumer<JsonValue> updateConsumer) {FormInputText input = createFormInputText(style.attributeDecimalEditor());- MetadataItem defaultValue;- if (attribute.getValue() != null) {- input.setValue(attribute.getValue().asString());- } else if ((defaultValue = getFirstMetadataItem(attribute, DEFAULT)) != null) {- input.setValue(defaultValue.getValue().asString());+ if (currentValue != null) {+ input.setValue(currentValue.asString());+ } else if (defaultValue != null) {+ input.setValue(defaultValue.asString());}- if (readOnly) {- input.setReadOnly(true);- } else {+ if (updateConsumer != null) {input.addValueChangeHandler(event -> {try {Double value = Double.valueOf(event.getValue());- attribute.setValue(Json.create(value));+ updateConsumer.accept(Json.create(value));} catch (NumberFormatException ex) {// TODO Do nothing? can we hook this up into validation?}});+ } else {+ input.setReadOnly(true);}return input;}- protected FormCheckBox createBooleanEditor(S style, Attribute attribute, boolean readOnly) {+ protected FormCheckBox createBooleanEditor(S style,+ JsonValue currentValue,+ JsonValue defaultValue,+ Consumer<JsonValue> updateConsumer) {FormCheckBox input = createFormInputCheckBox(style.attributeBooleanEditor());Boolean value = null;- MetadataItem defaultValue;- if (attribute.getValueAsBoolean() != null) {- value = attribute.getValueAsBoolean();- } else if ((defaultValue = getFirstMetadataItem(attribute, DEFAULT)) != null) {- defaultValue.getValue().asBoolean();+ if (currentValue != null) {+ value = currentValue.asBoolean();+ } else if (defaultValue != null) {+ defaultValue.asBoolean();}input.setValue(value);- if (readOnly) {- input.setEnabled(false);+ if (updateConsumer != null) {+ input.addValueChangeHandler(event -> updateConsumer.accept(Json.create(input.getValue())));} else {- input.addValueChangeHandler(event -> {- attribute.setValue(Json.create(input.getValue()));- });+ input.setEnabled(false);}return input;}@@ -330,4 +363,44 @@ public class AttributesEditor<S extends AttributesEditor.Style> {protected boolean isDefaultReadOnly(Attribute attribute) {return false;}++ /* ####################################################################### */++ public class MetaEditor extends FlowPanel {++ final protected Attribute attribute;++ public MetaEditor(Attribute attribute) {+ this.attribute = attribute;++ if (attribute.hasMetadata()) {+ for (MetadataItem item : attribute.getMetadata().all()) {+ FormGroup formGroup = new FormGroup();++ FormLabel label = new FormLabel();+ label.addStyleName("largest");+ label.setText(item.getName());+ formGroup.addFormLabel(label);++ FormField formField = new FormField();+ formField.add(createEditor(item));+ formGroup.addFormField(formField);++ FormGroupActions formGroupActions = new FormGroupActions();++ FormButton deleteButton = new FormButton();+ deleteButton.setText(container.getMessages().deleteItem());+ deleteButton.setIcon("remove");+ deleteButton.addClickHandler(clickEvent -> {+ environment.getEventBus().dispatch(new ShowInfoEvent("TODO: Not implemented"));+ });+ formGroupActions.add(deleteButton);++ formGroup.addFormGroupActions(formGroupActions);++ add(formGroup);+ }+ }+ }+ }}diff --git a/manager/client/src/main/java/org/openremote/manager/client/widget/FormGroup.java b/manager/client/src/main/java/org/openremote/manager/client/widget/FormGroup.javaindex 546c0cc7d..251667a7b 100644--- a/manager/client/src/main/java/org/openremote/manager/client/widget/FormGroup.java+++ b/manager/client/src/main/java/org/openremote/manager/client/widget/FormGroup.java@@ -23,22 +23,52 @@ import com.google.gwt.dom.client.Style;import com.google.gwt.uibinder.client.UiChild;import com.google.gwt.user.client.ui.*;+import java.util.logging.Logger;+/**- * A form has form groups, each group is a combination of label,- * control field, etc. typically rendered in a single line/block.+ * A form group has a main and optional extension panel that can be expanded/collapsed on demand.+ * <p>+ * The main panel renders a {@link FormLabel}, optional secondary info label, a {@link FormField}, and {@link FormGroupActions} in a block.+ * <p>+ * The extension panel renders any widget in a collapsible block after the main panel.*/public class FormGroup extends FlowPanel implements HasWidgets {+ private static final Logger LOG = Logger.getLogger(FormGroup.class.getName());++ protected FlowPanel mainPanel = new FlowPanel();+protected FlowPanel labelPanel = new FlowPanel();protected FormLabel formLabel;+ protected Label infoLabel;+protected FormField formField;+protected FormGroupActions formGroupActions;- protected Label infoLabel;++ protected FormButton toggleExtensionButton = new FormButton();++ protected FlowPanel extensionPanel = new FlowPanel();++ protected boolean expanded;public FormGroup() {- getElement().addClassName("layout horizontal center or-FormGroup");+ setStyleName("layout vertical or-FormGroup");++ mainPanel.setStyleName("layout horizontal center");+ add(mainPanel);+labelPanel.setStyleName("layout vertical");- add(labelPanel);+ mainPanel.add(labelPanel);++ toggleExtensionButton.setVisible(false);+ toggleExtensionButton.setIcon("caret-down");+ toggleExtensionButton.addClickHandler(clickEvent -> {+ setExpanded(!isExpanded());+ });+ mainPanel.add(toggleExtensionButton);++ extensionPanel.setStyleName("or-FormGroupExtension");}@UiChild(tagname = "label", limit = 1)@@ -54,7 +84,11 @@ public class FormGroup extends FlowPanel implements HasWidgets {if (this.formField != null)throw new IllegalStateException("Form field already set");this.formField = formField;- add(formField);+ mainPanel.insert(formField,+ mainPanel.getWidgetIndex(formGroupActions) > 0+ ? mainPanel.getWidgetIndex(formGroupActions)+ : mainPanel.getWidgetIndex(toggleExtensionButton)+ );if (this.formLabel != null) {formField.setFormFieldId(this.formLabel.getFormFieldId());@@ -64,7 +98,7 @@ public class FormGroup extends FlowPanel implements HasWidgets {@UiChild(tagname = "actions", limit = 1)public void addFormGroupActions(FormGroupActions formGroupActions) {this.formGroupActions = formGroupActions;- add(formGroupActions);+ mainPanel.insert(formGroupActions, mainPanel.getWidgetIndex(toggleExtensionButton));}@UiChild(tagname = "info", limit = 1)@@ -76,6 +110,12 @@ public class FormGroup extends FlowPanel implements HasWidgets {labelPanel.add(infoLabel);}+ @UiChild(tagname = "expansion")+ public void addExtension(Widget widget) {+ toggleExtensionButton.setVisible(true);+ extensionPanel.add(widget);+ }+public FormLabel getFormLabel() {return formLabel;}@@ -93,26 +133,47 @@ public class FormGroup extends FlowPanel implements HasWidgets {}public void setError(boolean error) {- getElement().removeClassName("error");+ removeStyleName("error");if (error) {- getElement().addClassName("error");+ addStyleName("error");}}public void setAlignStart(boolean alignStart) {if (alignStart) {- removeStyleName("center");- addStyleName("start");+ mainPanel.removeStyleName("center");+ mainPanel.addStyleName("start");} else {- removeStyleName("start");- addStyleName("center");+ mainPanel.removeStyleName("start");+ mainPanel.addStyleName("center");}}public void setOpaque(boolean opaque) {- getElement().removeClassName("opaque");+ removeStyleName("opaque");if (opaque) {- getElement().addClassName("opaque");+ addStyleName("opaque");}}++ public void setExpanded(boolean expanded) {+ this.expanded = expanded;+ if (expanded) {+ add(extensionPanel);+ addStyleName("expanded");+ toggleExtensionButton.setIcon("caret-up");+ toggleExtensionButton.addStyleName("or-FormButtonPrimary");+ toggleExtensionButton.removeStyleName("or-FormButton");+ } else {+ remove(extensionPanel);+ removeStyleName("expanded");+ toggleExtensionButton.setIcon("caret-down");+ toggleExtensionButton.removeStyleName("or-FormButtonPrimary");+ toggleExtensionButton.addStyleName("or-FormButton");+ }+ }++ public boolean isExpanded() {+ return expanded;+ }}diff --git a/manager/client/src/main/java/org/openremote/manager/client/widget/FormOutputText.java b/manager/client/src/main/java/org/openremote/manager/client/widget/FormOutputText.javanew file mode 100644index 000000000..8f542b7c4--- /dev/null+++ b/manager/client/src/main/java/org/openremote/manager/client/widget/FormOutputText.java@@ -0,0 +1,34 @@+/*+ * Copyright 2017, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.manager.client.widget;++import com.google.gwt.user.client.ui.Label;++public class FormOutputText extends Label {++ public FormOutputText() {+ this(null);+ }++ public FormOutputText(String text) {+ super(text);+ setStyleName("or-FormControl or-FormOutputText");+ }+}\ No newline at end of filediff --git a/manager/client/src/main/resources/org/openremote/manager/client/i18n/ManagerMessages.properties b/manager/client/src/main/resources/org/openremote/manager/client/i18n/ManagerMessages.propertiesindex 173cff4f8..f526b9a5d 100644--- a/manager/client/src/main/resources/org/openremote/manager/client/i18n/ManagerMessages.properties+++ b/manager/client/src/main/resources/org/openremote/manager/client/i18n/ManagerMessages.properties@@ -69,6 +69,7 @@ description=DescriptionnoConnectorAssigned= No connector assignedconnectorNotInstalled= CONNECTOR NOT INSTALLEDunsupportedAttributeType= Unsupported attribute type: {0}+unsupportedMetaItemType= Unsupported meta item type : {0}loadingAssets=Loading assets...assetName= Asset nameupdateAsset=Update asset@@ -119,5 +120,8 @@ enableAgentDescription= Enabled agents will discover devices and manage their inconfirmationInventoryRefresh=Are you sure you want to delete all child assets of agent {0} and trigger device discovery?noAgentsFound=No agents founddeleteAttribute=Delete attribute-editAttributeMeta=Edit Metadata+showAttributeMeta=Show metadata+hideAttributeMeta=Hide metadataaddAttribute=Add attribute+itemName=Item name+deleteItem=Delete itemdiff --git a/manager/client/src/main/webapp/css/style.html b/manager/client/src/main/webapp/css/style.htmlindex d1a61f6c3..9165873ab 100644--- a/manager/client/src/main/webapp/css/style.html+++ b/manager/client/src/main/webapp/css/style.html@@ -134,8 +134,8 @@opacity: inherit;}- .or-PushButtonIcon {- margin: 0 0.4em;+ .or-PushButtonIcon + .html-face {+ margin-left: 0.6em;}.or-PushButton.or-PushButton-up-disabled {@@ -160,7 +160,7 @@}.or-HyperlinkIcon {- width: 1em;+ width: 0.6em;}.or-Hyperlink a,@@ -246,6 +246,18 @@opacity: 0.44;}+ .or-FormGroup.expanded .or-FormGroup {+ margin-bottom: 0;+ }++ .or-FormGroup.expanded .or-FormGroup .or-FormLabel {+ font-size: 0.8em;+ }++ .or-FormGroupExtension {+ margin: .8em;+ }+.or-FormLabel {min-width: 10em;font-weight: 600;@@ -260,6 +272,10 @@min-width: 15em;}+ .or-FormLabel.largest {+ min-width: 30em;+ }+.or-FormLabel .required {margin: 0 0.4em;}diff --git a/manager/client/src/main/webapp/css/theme.html b/manager/client/src/main/webapp/css/theme.htmlindex acafa1a7f..fba6e3956 100644--- a/manager/client/src/main/webapp/css/theme.html+++ b/manager/client/src/main/webapp/css/theme.html@@ -9,6 +9,7 @@--theme-darkgrey: #374c4f; /* rgb(55, 76, 79) */--theme-mediumgrey: #919194; /* rgb(145, 145, 148); */--theme-lightgrey: #cccccc; /* rgb(204, 204, 204); */+ --theme-lightergrey: #e5e5e5; /* rgb(229, 229, 229); */--theme-brightgrey: #f5f5f5; /* rgb(245, 245, 245); */--theme-red: #e64a19; /* rgb(230, 74, 25); */--theme-yellow: #fbc02d; /* rgb(251, 192, 45); */@@ -133,6 +134,16 @@background-image: -moz-linear-gradient(45deg, var(--theme-brightgrey) 0%, transparent 100%);}+ .or-FormGroup.expanded {+ background-image: -webkit-linear-gradient(45deg, var(--theme-lightergrey) 0%, transparent 100%);+ background-image: -moz-linear-gradient(45deg, var(--theme-lightergrey) 0%, transparent 100%);+ }++ .or-FormGroup.expanded .or-FormGroup {+ background-image: none;+ background: var(--theme-white);+ }+.or-FormGroup.error .or-FormControl {border-color: var(--theme-red);}diff --git a/model/src/main/java/org/openremote/model/asset/AssetAttributeMeta.java b/model/src/main/java/org/openremote/model/asset/AssetAttributeMeta.javaindex 430bee1af..10a41e04b 100644--- a/model/src/main/java/org/openremote/model/asset/AssetAttributeMeta.java+++ b/model/src/main/java/org/openremote/model/asset/AssetAttributeMeta.java@@ -119,12 +119,12 @@ public enum AssetAttributeMeta {return list.toArray(new AssetAttributeMeta[list.size()]);}- public static boolean isEditable(String name) {- try {- return AssetAttributeMeta.valueOf(name).isEditable();- } catch (IllegalArgumentException ex) {- return false;+ public static Boolean isEditable(String name) {+ for (AssetAttributeMeta assetAttributeMeta : editable()) {+ if (assetAttributeMeta.getName().equals(name))+ return assetAttributeMeta.isEditable();}+ return null;}public static MetadataItem createMetadataItem(AssetAttributeMeta name, JsonValue value) {@@ -136,4 +136,11 @@ public enum AssetAttributeMeta {? attribute.getMetadata().first(meta.getName()): null;}++ public static JsonValue getFirstMetadataItemValue(Attribute attribute, AssetAttributeMeta meta) {+ MetadataItem item = attribute.hasMetaItem(meta.getName())+ ? attribute.getMetadata().first(meta.getName())+ : null;+ return item != null ? item.getValue() : null;+ }}