From e9285d29bb4e36cb7b74fd27f6235a52adb3e683 Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 24 Sep 2010 11:42:52 +0000 Subject: [PATCH] Variables can be dragged to operating user interface elements directly from model browser git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18076 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../org/simantics/sysdyn/ui/browser/SysdynBrowser.java | 5 ++++- .../simantics/sysdyn/ui/browser/nodes/VariableNode.java | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java index bfb49594..fe8e878b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java @@ -50,11 +50,14 @@ public class SysdynBrowser extends GraphExplorerView { NodeContext ctx = (NodeContext)objects[i]; @SuppressWarnings("unchecked") VariableNode vn = (VariableNode) ctx.getAdapter(VariableNode.class); - IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN); + IHintContext context; if(vn != null) { Resource resource = vn.getResource() == null ? vn.data : vn.getResource(); + context = new AdaptableHintContext(SelectionHints.KEY_MAIN, SelectionHints.KEY_SELECTION_PROPERTY); context.setHint(SelectionHints.KEY_MAIN, new BrowserSelection(resource, vn.getURI(), vn.getModel())); + context.setHint(SelectionHints.KEY_SELECTION_PROPERTY, vn.getVariable()); } else { + context = new AdaptableHintContext(SelectionHints.KEY_MAIN); context.setHint(SelectionHints.KEY_MAIN, objects[i]); } result[i] = context; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java index 4347140c..3f218f5f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java @@ -16,6 +16,7 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.ui.SimanticsUI; @@ -25,6 +26,7 @@ public class VariableNode extends AbstractNode { Resource model = null; String uri; Resource resource; + Variable variable; public VariableNode(Resource resource) { super(resource); @@ -33,6 +35,8 @@ public class VariableNode extends AbstractNode { @Override public void run(ReadGraph graph) throws DatabaseException { + + variable = graph.adapt(data, Variable.class); Layer0 l0 = Layer0.getInstance(graph); SysdynResource sr = SysdynResource.getInstance(graph); @@ -67,6 +71,10 @@ public class VariableNode extends AbstractNode { public Resource getModel() { return model; } + + public Variable getVariable() { + return variable; + } public String getName(ReadGraph graph) throws DatabaseException { return (String)graph.getRelatedValue(data, Layer0.getInstance(graph).HasName); -- 2.47.1