]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateNodeManager.java
Ability to get StatePropertyNode from StateNodeManager
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / state / StateNodeManager.java
index 97bc4b1c732df93b6ce1671c8b6c6d0a9acb58a5..399fbd7d19c17d99c868ab4a28a7c455e3215539 100644 (file)
@@ -42,6 +42,31 @@ public class StateNodeManager extends StandardVariableNodeManager<StateNode, Sta
                        LOGGER.error("Setting state was interrupted.", e);
                }
        }
+       private class PropertyRunnable implements Runnable {
+               String key;
+               StatePropertyNode propertyNode;
+               
+               public PropertyRunnable(String key) {
+                       this.key = key;
+               }
+               
+               @Override
+               public void run() {
+                       StateRootNode rootNode = (StateRootNode) getRoot();
+                       propertyNode = rootNode.getProperty(key);
+               }
+       }
+       
+       public StatePropertyNode getState(String key) {
+               try {
+                       PropertyRunnable r = new PropertyRunnable(key);
+                       getRealm().syncExec(r);
+                       return r.propertyNode;
+               } catch (InterruptedException e) {
+                       LOGGER.error("Getting state was interrupted.", e);
+                       return null;
+               }
+       }
 
        public byte[] serialize() {
                final byte [][] result = new byte[1][];