]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Set value for scalar variable did not work
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 5 May 2014 07:48:59 +0000 (07:48 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 5 May 2014 07:48:59 +0000 (07:48 +0000)
refs #4854

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29405 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java

index 3afc87f746c766417cba6723b8f96503465f3ac7..a052211e74aa7814497729c84285e91b476d29d1 100644 (file)
@@ -163,7 +163,7 @@ public abstract class IndexVariable<T> extends AbstractPropertyVariable {
 \r
        }\r
        \r
-       private void ensureInformationAvailable(ReadGraph graph) throws DatabaseException {\r
+       protected void ensureInformationAvailable(ReadGraph graph) throws DatabaseException {\r
                SimulationResource SIMU = SimulationResource.getInstance(graph);\r
                ModelingResources MOD = ModelingResources.getInstance(graph);\r
                \r
index b50195ba4ee6921bb46cc4d3ce3c42f388955766..ab3b0f17e1b08acea584beb5c7cfa031df1df13d 100644 (file)
@@ -1,6 +1,10 @@
 package org.simantics.sysdyn.adapter;\r
 \r
+import java.util.Arrays;\r
+\r
+import org.simantics.databoard.binding.Binding;\r
 import org.simantics.db.ReadGraph;\r
+import org.simantics.db.WriteGraph;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 \r
@@ -20,4 +24,18 @@ public class  ValueIndexVariableI extends ValueIndexVariableBase<Double> {
                return array[0];\r
        }\r
        \r
+       @Override\r
+       public void setValue(WriteGraph graph, Object value) throws DatabaseException {\r
+               ensureInformationAvailable(graph);\r
+               double[] existing = getValueFull();\r
+               double[] newValue = Arrays.copyOf(existing, existing.length);\r
+               newValue[0] = (Double)value;\r
+               super.setValue(graph, newValue);\r
+       }\r
+       \r
+       @Override\r
+       public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException {\r
+               setValue(graph, value);\r
+       }\r
+       \r
 }\r