From: villberg Date: Mon, 5 May 2014 07:48:59 +0000 (+0000) Subject: Set value for scalar variable did not work X-Git-Tag: 1.8.1~69 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=870fc58f37730dfe475c063af4847970d9adacb9;p=simantics%2Fsysdyn.git Set value for scalar variable did not work refs #4854 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29405 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java index 3afc87f7..a052211e 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java @@ -163,7 +163,7 @@ public abstract class IndexVariable extends AbstractPropertyVariable { } - private void ensureInformationAvailable(ReadGraph graph) throws DatabaseException { + protected void ensureInformationAvailable(ReadGraph graph) throws DatabaseException { SimulationResource SIMU = SimulationResource.getInstance(graph); ModelingResources MOD = ModelingResources.getInstance(graph); diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java index b50195ba..ab3b0f17 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java @@ -1,6 +1,10 @@ package org.simantics.sysdyn.adapter; +import java.util.Arrays; + +import org.simantics.databoard.binding.Binding; import org.simantics.db.ReadGraph; +import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; @@ -20,4 +24,18 @@ public class ValueIndexVariableI extends ValueIndexVariableBase { return array[0]; } + @Override + public void setValue(WriteGraph graph, Object value) throws DatabaseException { + ensureInformationAvailable(graph); + double[] existing = getValueFull(); + double[] newValue = Arrays.copyOf(existing, existing.length); + newValue[0] = (Double)value; + super.setValue(graph, newValue); + } + + @Override + public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException { + setValue(graph, value); + } + }