]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Variables can be dragged to operating user interface elements directly from model...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 24 Sep 2010 11:42:52 +0000 (11:42 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 24 Sep 2010 11:42:52 +0000 (11:42 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18076 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java

index bfb49594e90c2c09e87cdfa54accb3c62b08815f..fe8e878b1941288983e25538b857f76ac65479c8 100644 (file)
@@ -50,11 +50,14 @@ public class SysdynBrowser extends GraphExplorerView {
                        NodeContext ctx = (NodeContext)objects[i];        \r
                    @SuppressWarnings("unchecked")\r
                                VariableNode<Resource> vn = (VariableNode<Resource>) ctx.getAdapter(VariableNode.class);\r
-                   IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
+                   IHintContext context;\r
                    if(vn != null) {\r
                        Resource resource = vn.getResource() == null ? vn.data : vn.getResource();\r
+                       context = new AdaptableHintContext(SelectionHints.KEY_MAIN, SelectionHints.KEY_SELECTION_PROPERTY);\r
                        context.setHint(SelectionHints.KEY_MAIN, new BrowserSelection(resource, vn.getURI(), vn.getModel()));\r
+                       context.setHint(SelectionHints.KEY_SELECTION_PROPERTY, vn.getVariable());\r
                    } else {\r
+                       context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
                        context.setHint(SelectionHints.KEY_MAIN, objects[i]);\r
                    }\r
                    result[i] = context;\r
index 4347140c98af62f4b57f1f0d82c8dd3f2d55cf4c..3f218f5f6c1be0420f3d2fdef7efa7a153a734d4 100644 (file)
@@ -16,6 +16,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
@@ -25,6 +26,7 @@ public class VariableNode<T> extends AbstractNode<Resource> {
        Resource model = null;\r
        String uri;\r
        Resource resource;\r
+       Variable variable;\r
 \r
        public VariableNode(Resource resource) {\r
                super(resource);\r
@@ -33,6 +35,8 @@ public class VariableNode<T> extends AbstractNode<Resource> {
 \r
                        @Override\r
                        public void run(ReadGraph graph) throws DatabaseException {\r
+                               \r
+                               variable = graph.adapt(data, Variable.class);\r
                                Layer0 l0 = Layer0.getInstance(graph);\r
                                SysdynResource sr = SysdynResource.getInstance(graph);\r
                                \r
@@ -67,6 +71,10 @@ public class VariableNode<T> extends AbstractNode<Resource> {
        public Resource getModel() {\r
                return model;\r
        }\r
+       \r
+       public Variable getVariable() {\r
+               return variable;\r
+       }\r
 \r
        public String getName(ReadGraph graph) throws DatabaseException {\r
                return (String)graph.getRelatedValue(data, Layer0.getInstance(graph).HasName);\r