Skip to content
Permalink
Browse files

Updates for GWT manager asset editor

  • Loading branch information...
richturner committed Jul 2, 2019
1 parent 8140062 commit af34f4f8332c9d368f4a861f4adfa1aef5fd6a5f
@@ -237,7 +237,10 @@ protected AttributeInfo(AttributeRef attributeRef, int retries, int responseTime
* Indicates whether the server replies to each packet not just polling requests (need this to successfully match
* request and response packets)
*/
public static final MetaItemDescriptor META_SERVER_ALWAYS_RESPONDS = metaItemFixedBoolean(PROTOCOL_NAMESPACE + ":serverAlwaysResponds", ACCESS_PRIVATE, false);
public static final MetaItemDescriptor META_SERVER_ALWAYS_RESPONDS = metaItemFixedBoolean(
PROTOCOL_NAME+ ":serverAlwaysResponds",
ACCESS_PRIVATE,
false);

/**
* Indicates how long to wait for a response from the server before re-attempting {@link #META_SEND_RETRIES} times
@@ -305,6 +308,15 @@ public String getVersion() {
return ATTRIBUTE_META_ITEM_DESCRIPTORS;
}

@Override
public AssetAttribute getProtocolConfigurationTemplate() {
return super.getProtocolConfigurationTemplate()
.addMeta(
new MetaItem(META_PROTOCOL_HOST, null),
new MetaItem(META_PROTOCOL_PORT, null)
);
}

@Override
protected void doLinkProtocolConfiguration(AssetAttribute protocolConfiguration) {

@@ -66,6 +66,15 @@ public static IsWidget createValueEditor(Value currentValue,
ManagerMessages managerMessages) {

switch(valueType) {
case ANY:
return createAnyEditor(
currentValue,
onValueModified,
timestamp,
readOnly,
widgetStyle,
managerMessages
);
case OBJECT:
ObjectValue currentValueObj = Values.getObject(currentValue).orElse(null);

@@ -191,6 +200,30 @@ public static IsWidget createBooleanEditor(BooleanValue currentValue,
return panel;
}

public static IsWidget createAnyEditor(Value currentValue,
Consumer<Value> onValueModified,
Optional<Long> timestamp,
boolean readOnly,
WidgetStyle widgetStyle,
ManagerMessages managerMessages) {

Consumer<Value> updateConsumer = readOnly ? null : onValueModified::accept;

FlowPanel panel = new FlowPanel();
panel.setStyleName("flex layout horizontal center or-ValueEditor or-ObjectValueEditor");
String label = managerMessages.jsonObject();
String title = managerMessages.edit() + " " + managerMessages.jsonObject();
IsWidget widget = createJsonEditorWidget(
new JsonEditor(title, widgetStyle, managerMessages), readOnly, label, currentValue, updateConsumer
);
FlowPanel widgetWrapper = new FlowPanel();
widgetWrapper.setStyleName("flex layout horizontal center");
widgetWrapper.add(widget);
panel.add(widgetWrapper);
timestamp.ifPresent(time -> addTimestampLabel(time, panel));
return panel;
}

public static IsWidget createObjectEditor(ObjectValue currentValue,
Consumer<ObjectValue> onValueModified,
Optional<Long> timestamp,
@@ -405,6 +405,14 @@ metaItemDisplayName[urnopenremoteprotocolcontrollerClientcommandDeviceName]=Cont
metaItemDisplayName[urnopenremoteprotocolcontrollerClientcommandName]=Controller command name
metaItemDisplayName[urnopenremoteprotocolcontrollerClientcommandsMap]=Controller commands map
metaItemDisplayName[urnopenremoteprotocolcontrollerClientbaseUri]=Controller base URI
metaItemDisplayName[urnopenremoteprotocoludpClienthost]=UDP server hostname/IP
metaItemDisplayName[urnopenremoteprotocoludpClientport]=UDP server port
metaItemDisplayName[urnopenremoteprotocoludpClientbindPort]=UDP Client bind port
metaItemDisplayName[urnopenremoteprotocoludpClientresponseTimeoutMillis]=Response timeout (ms)
metaItemDisplayName[urnopenremoteprotocoludpClientsendRetries]=No. of Retries
metaItemDisplayName[urnopenremoteprotocoludpClientserverAlwaysResponds]=UDP server always responds


attributeLinkConverterValues=Converter values
attributeLinkNewConverterValue=New converter value
enterConverterValue=Enter converter value
@@ -26,6 +26,7 @@
import org.openremote.model.util.TextUtil;
import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
import org.openremote.model.value.Values;

import java.util.Collection;
@@ -117,7 +118,7 @@ public void clearName() {
);
}

if (getValue().map(Value::getType).map(type -> descriptor.getValueType() != null && descriptor.getValueType() != type).orElse(true)) {
if (getValue().map(Value::getType).map(type -> descriptor.getValueType() != null && descriptor.getValueType() != ValueType.ANY && descriptor.getValueType() != type).orElse(true)) {
failures.add(new ValidationFailure(META_ITEM_VALUE_MISMATCH, descriptor.getValueType() != null ? descriptor.getValueType().name() : null));
return true;
}

0 comments on commit af34f4f

Please sign in to comment.
You can’t perform that action at this time.