]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fixed record-type value editing in the old property tab implementation 63/163/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 23 Nov 2016 12:43:43 +0000 (14:43 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 23 Nov 2016 12:43:43 +0000 (14:43 +0200)
refs #4583

Change-Id: I7ff3a4d57df864a38132c7551dedb829d5d78036

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/StringIndexModifierImpl.java

index 33fed9cc172a1386d3248b8748b2c5e4f680023a..452e5e8f265b54de4100aaedeaa0621e7fa2cb93 100644 (file)
@@ -16,11 +16,13 @@ import java.util.List;
 \r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.binding.RecordBinding;\r
 import org.simantics.databoard.binding.error.BindingException;\r
 import org.simantics.databoard.parser.repository.DataTypeSyntaxError;\r
 import org.simantics.databoard.parser.repository.DataValueRepository;\r
 import org.simantics.databoard.type.ArrayType;\r
 import org.simantics.databoard.type.Datatype;\r
+import org.simantics.databoard.type.RecordType;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.VirtualGraph;\r
@@ -142,7 +144,15 @@ public final class StringIndexModifierImpl implements StringIndexModifier {
                OrderedSetUtils.replace(graph, resource, list.get(index), el);\r
             } else {\r
                 Datatype dt = graph.getPossibleRelatedValue(resource, l0.HasDataType, Bindings.getBindingUnchecked(Datatype.class));\r
-                if (dt instanceof ArrayType) {\r
+                if (dt instanceof RecordType) {\r
+                    RecordType rt = (RecordType) dt;\r
+                    RecordBinding rb = Bindings.getBinding(rt);\r
+                    Binding indexBinding = rb.getComponentBinding(index);\r
+                    Object parsedValue = indexBinding.parseValue(value, new DataValueRepository());\r
+                    Object v = graph.getValue(resource, rb);\r
+                    rb.setComponent(v, index, parsedValue);\r
+                    graph.claimValue(resource, v, rb);\r
+                } else if (dt instanceof ArrayType) {\r
                     ArrayType at = (ArrayType) dt;\r
                     Binding binding = Bindings.getBinding(at);\r
                     Binding indexBinding = Bindings.getBinding(at.componentType());\r