]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/NodeSupport.java
Update structure and value cache when refreshing variable
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / NodeSupport.java
index 79bc4eb5ee2926e52c6cce934c80382651ee2357..3ac88ae6769eb24bea768ac66077a502864dced2 100644 (file)
@@ -5,6 +5,8 @@ import java.util.concurrent.TimeUnit;
 import org.simantics.databoard.binding.mutable.Variant;
 import org.simantics.db.layer0.variable.Variables.NodeStructure;
 import org.simantics.simulator.variable.NodeManager;
+import org.simantics.simulator.variable.exceptions.NoValueException;
+import org.simantics.simulator.variable.exceptions.NodeManagerException;
 
 /**
  * @author Antti Villberg
@@ -55,6 +57,18 @@ public class NodeSupport<Node> {
                                && manager.equals(other.manager);
        }
 
+       public void refreshCache(Node node) throws NodeManagerException {
+               VariableNode<Node> variableNode = new VariableNode<>(this, node);
+               NodeStructure ns = NodeStructureRequest.get(variableNode);
+               structureCache.put(node, ns);
+               try {
+                       Variant value = manager.getValue(node);
+                       valueCache.put(node, value);
+               } catch (NoValueException e) {
+                       valueCache.remove(node);
+               };
+       }
+
        public void dispose() {
                valueCache.dispose();
                structureCache.dispose();