From 8f3b4aa83ea7c2fbc046a1b00bdd1240c9eeeed6 Mon Sep 17 00:00:00 2001 From: lempinen Date: Wed, 10 Mar 2010 14:44:14 +0000 Subject: [PATCH] empty shortcut tabs when cloud or dependency selected git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14791 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/equation/EquationView.java | 2 + .../sysdyn/ui/equation/ShortcutTabs.java | 65 ++++++++++--------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java index 4ba9e745..58b690c2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java @@ -258,7 +258,9 @@ public class EquationView extends ViewPart implements ISelectionListener { expressionController.setEnabled(false); expressionComposite.setEnabled(false); nameComposite.setEnabled(false); + unitSelector.clear(); // empty units + shortcutTabs.updateTables(variable); expressionController.setExpressionTypes(null); nameComposite.setName(result.name); expressionComposite.resetExpressionView(variable); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java index d256d019..23b27d19 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java @@ -27,7 +27,7 @@ public class ShortcutTabs extends Composite { TabItem functions; Table variableTable; Table functionTable; - + public ShortcutTabs(Composite parent, int style) { super(parent, style); @@ -58,10 +58,10 @@ public class ShortcutTabs extends Composite { item.setText("if then else"); item.setData("if then else"); functions.setControl(functionTable); - + this.layout(); } - + public HashSet updateTables(Resource variable) { HashSet dependencies = getDependencies(variable); variableTable.removeAll(); @@ -73,46 +73,47 @@ public class ShortcutTabs extends Composite { } return dependencies; } - + // Returns the names of the related variables (dependencies) private HashSet getDependencies(final Resource r){ HashSet variables = null; - try { - variables = SimanticsUI.getSession().syncRequest(new Read>() { - - @Override - public HashSet perform(ReadGraph graph) - throws DatabaseException { - HashSet variables = new HashSet(); - SysdynResource sr = SysdynResource.getInstance(graph); - Builtins b = graph.getBuiltins(); - - Collection dependencies = graph.getObjects(r, sr.IsHeadOf); - - for(Resource d : dependencies) { - if(graph.isInstanceOf(d, sr.Dependency)) { - Resource tail = graph.getPossibleObject(d, sr.HasTail); - if(tail != null) { - Object name = graph.getPossibleRelatedValue(tail, b.HasName); - if(name != null) - variables.add((String)name); + if(r != null) + try { + variables = SimanticsUI.getSession().syncRequest(new Read>() { + + @Override + public HashSet perform(ReadGraph graph) + throws DatabaseException { + HashSet variables = new HashSet(); + SysdynResource sr = SysdynResource.getInstance(graph); + Builtins b = graph.getBuiltins(); + + Collection dependencies = graph.getObjects(r, sr.IsHeadOf); + + for(Resource d : dependencies) { + if(graph.isInstanceOf(d, sr.Dependency)) { + Resource tail = graph.getPossibleObject(d, sr.HasTail); + if(tail != null) { + Object name = graph.getPossibleRelatedValue(tail, b.HasName); + if(name != null) + variables.add((String)name); + } } } - } - return variables; + return variables; - } + } - }); - } catch (DatabaseException ee) { - ExceptionUtils.logAndShowError(ee); - } + }); + } catch (DatabaseException ee) { + ExceptionUtils.logAndShowError(ee); + } - return variables; + return variables; } - + public Table getVariableTable() { return this.variableTable; } -- 2.47.1