]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableNodeManager.java
Update structure and value cache when refreshing variable
[simantics/platform.git] / bundles / org.simantics.simulator.toolkit.db / src / org / simantics / simulator / toolkit / db / StandardVariableNodeManager.java
1 /*******************************************************************************
2  * Copyright (c) 2013 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *     Semantum Oy - initial API and implementation
12  *******************************************************************************/
13 package org.simantics.simulator.toolkit.db;
14
15 import org.simantics.db.layer0.variable.NodeSupport;
16 import org.simantics.simulator.toolkit.StandardNodeManager;
17 import org.simantics.simulator.toolkit.StandardNodeManagerSupport;
18 import org.simantics.simulator.toolkit.StandardRealm;
19 import org.simantics.simulator.variable.exceptions.NodeManagerException;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24  * Adds support for Layer0 Variable interface in StandardNodeManager
25  *
26  * @author Antti Villberg
27  */
28 public class StandardVariableNodeManager<Node, Engine extends StandardNodeManagerSupport<Node>> extends StandardNodeManager<Node,Engine> {
29
30     private static final Logger LOGGER = LoggerFactory.getLogger(StandardVariableNodeManager.class); 
31     protected NodeSupport<Node> support;
32
33     public StandardVariableNodeManager(StandardRealm<Node, Engine> realm, Node root) {
34         super(realm, root);
35         this.support = new NodeSupport<>(this);
36     }
37
38 /*    public void registerNodeSupport(NodeSupport<Node> support) {
39         this.support = support;
40     }
41
42
43     public void registerSupport(NodeSupport<Node> support) {
44         this.support = support;
45     }*/
46
47     @Override
48     public void refreshVariable(Node node) {
49         try {
50             support.refreshCache(node);
51         } catch (NodeManagerException e) {
52             LOGGER.error("Failed to refresh variable", e);
53             throw new RuntimeException(e);
54         }
55         super.refreshVariable(node);
56     }
57
58 }