From: Tuukka Lehtonen Date: Wed, 23 Nov 2016 12:43:43 +0000 (+0200) Subject: Fixed record-type value editing in the old property tab implementation X-Git-Tag: v1.25.0~35^2~1 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=a571699746e406c8fd0f69eaf20a0b005e68c592;p=simantics%2Fplatform.git Fixed record-type value editing in the old property tab implementation refs #4583 Change-Id: I7ff3a4d57df864a38132c7551dedb829d5d78036 --- diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/StringIndexModifierImpl.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/StringIndexModifierImpl.java index 33fed9cc1..452e5e8f2 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/StringIndexModifierImpl.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/StringIndexModifierImpl.java @@ -16,11 +16,13 @@ import java.util.List; import org.simantics.databoard.Bindings; import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.binding.RecordBinding; import org.simantics.databoard.binding.error.BindingException; import org.simantics.databoard.parser.repository.DataTypeSyntaxError; import org.simantics.databoard.parser.repository.DataValueRepository; import org.simantics.databoard.type.ArrayType; import org.simantics.databoard.type.Datatype; +import org.simantics.databoard.type.RecordType; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.VirtualGraph; @@ -142,7 +144,15 @@ public final class StringIndexModifierImpl implements StringIndexModifier { OrderedSetUtils.replace(graph, resource, list.get(index), el); } else { Datatype dt = graph.getPossibleRelatedValue(resource, l0.HasDataType, Bindings.getBindingUnchecked(Datatype.class)); - if (dt instanceof ArrayType) { + if (dt instanceof RecordType) { + RecordType rt = (RecordType) dt; + RecordBinding rb = Bindings.getBinding(rt); + Binding indexBinding = rb.getComponentBinding(index); + Object parsedValue = indexBinding.parseValue(value, new DataValueRepository()); + Object v = graph.getValue(resource, rb); + rb.setComponent(v, index, parsedValue); + graph.claimValue(resource, v, rb); + } else if (dt instanceof ArrayType) { ArrayType at = (ArrayType) dt; Binding binding = Bindings.getBinding(at); Binding indexBinding = Bindings.getBinding(at.componentType());