]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Ability to get StatePropertyNode from StateNodeManager 60/4760/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 7 Jul 2021 08:04:02 +0000 (11:04 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 7 Jul 2021 08:04:02 +0000 (11:04 +0300)
gitlab simupedia#163

Change-Id: Ie33d50386e5509e2c1e2a857dfa56f481ca54d0c

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][];