Search in sources :

Example 1 with AssetMeta

use of org.openremote.model.asset.AssetMeta in project openremote by openremote.

the class MetaEditor method onMetaItemTypeChanged.

protected void onMetaItemTypeChanged(MetaItemEditor itemEditor, boolean updateItem) {
    if (updateItem) {
        itemEditor.item.clearValue();
        // TODO Should use meta item descriptors from server
        Value initialValue = Arrays.stream(AssetMeta.values()).filter(assetMeta -> assetMeta.getUrn().equals(itemEditor.nameList.getSelectedValue())).map(MetaItemDescriptor::getInitialValue).findFirst().orElse(null);
        ValueType valueType = EnumUtil.enumFromString(ValueType.class, itemEditor.typeList.getSelectedValue()).orElse(null);
        if (valueType == ValueType.BOOLEAN && initialValue == null) {
            initialValue = Values.create(false);
        }
        itemEditor.onModified(initialValue);
    }
    itemEditor.updateValueEditor();
}
Also used : IntStream(java.util.stream.IntStream) Supplier(org.openremote.model.interop.Supplier) java.util(java.util) ValueType(org.openremote.model.value.ValueType) Environment(org.openremote.app.client.Environment) MetaItemDescriptor(org.openremote.model.attribute.MetaItemDescriptor) Pair(org.openremote.model.util.Pair) EnumUtil(org.openremote.model.util.EnumUtil) ValidationFailure(org.openremote.model.ValidationFailure) org.openremote.app.client.widget(org.openremote.app.client.widget) Collectors(java.util.stream.Collectors) AssetMeta(org.openremote.model.asset.AssetMeta) AttributeValidationResult(org.openremote.model.attribute.AttributeValidationResult) MetaItem(org.openremote.model.attribute.MetaItem) AgentLink(org.openremote.model.asset.agent.AgentLink) Value(org.openremote.model.value.Value) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) ProtocolDescriptor(org.openremote.model.asset.agent.ProtocolDescriptor) IsWidget(com.google.gwt.user.client.ui.IsWidget) Values(org.openremote.model.value.Values) TextUtil.isNullOrEmpty(org.openremote.model.util.TextUtil.isNullOrEmpty) AssetAttribute(org.openremote.model.asset.AssetAttribute) ValueType(org.openremote.model.value.ValueType) Value(org.openremote.model.value.Value) MetaItemDescriptor(org.openremote.model.attribute.MetaItemDescriptor)

Aggregations

FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Environment (org.openremote.app.client.Environment)1 org.openremote.app.client.widget (org.openremote.app.client.widget)1 ValidationFailure (org.openremote.model.ValidationFailure)1 AssetAttribute (org.openremote.model.asset.AssetAttribute)1 AssetMeta (org.openremote.model.asset.AssetMeta)1 AgentLink (org.openremote.model.asset.agent.AgentLink)1 ProtocolDescriptor (org.openremote.model.asset.agent.ProtocolDescriptor)1 AttributeValidationResult (org.openremote.model.attribute.AttributeValidationResult)1 MetaItem (org.openremote.model.attribute.MetaItem)1 MetaItemDescriptor (org.openremote.model.attribute.MetaItemDescriptor)1 Supplier (org.openremote.model.interop.Supplier)1 EnumUtil (org.openremote.model.util.EnumUtil)1 Pair (org.openremote.model.util.Pair)1 TextUtil.isNullOrEmpty (org.openremote.model.util.TextUtil.isNullOrEmpty)1 Value (org.openremote.model.value.Value)1