]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateNodeManagerSupport.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / state / StateNodeManagerSupport.java
1 package org.simantics.document.server.state;
2
3 import java.util.Collections;
4 import java.util.Map;
5
6 import org.simantics.databoard.Bindings;
7 import org.simantics.databoard.binding.Binding;
8 import org.simantics.simulator.toolkit.StandardNodeManagerSupport;
9 import org.simantics.simulator.variable.exceptions.NoValueException;
10 import org.simantics.simulator.variable.exceptions.NodeManagerException;
11
12 public class StateNodeManagerSupport implements StandardNodeManagerSupport<StateNode> {
13
14         @Override
15         public Object getEngineValue(StateNode node) throws NodeManagerException {
16                 if (node instanceof StatePropertyNode) {
17                         return ((StatePropertyNode) node).getValue();
18                 }
19                 else throw new NoValueException();
20         }
21
22         @Override
23         public Binding getEngineBinding(StateNode node) throws NodeManagerException {
24                 if (node instanceof StatePropertyNode) {
25                         return Bindings.OBJECT;
26                 }
27                 else throw new NoValueException();
28         }
29
30         @Override
31         public void setEngineValue(StateNode node, Object value) throws NodeManagerException {
32                 if (node instanceof StatePropertyNode) {
33                         ((StatePropertyNode) node).setValue(value);
34                 }
35                 else throw new NodeManagerException();
36         }
37
38         @Override
39         public String getName(StateNode node) {
40                 if (node instanceof StatePropertyNode) {
41                         return ((StatePropertyNode) node).getName();
42                 } else return "@";
43         }
44
45         @Override
46         public Map<String, StateNode> getChildren(StateNode node) {
47                 return Collections.emptyMap();
48         }
49
50         @Override
51         public Map<String, StateNode> getProperties(StateNode node) {
52                 if (node instanceof StateRootNode) {
53                         return ((StateRootNode) node).getProperties();
54                 } else return Collections.emptyMap();
55         }
56
57 }