]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
empty shortcut tabs when cloud or dependency selected
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 10 Mar 2010 14:44:14 +0000 (14:44 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 10 Mar 2010 14:44:14 +0000 (14:44 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14791 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java

index 4ba9e745577e2678d28fc60c7d55fe8110775989..58b690c275d4308b86345f89bd30942c0f178963 100644 (file)
@@ -258,7 +258,9 @@ public class EquationView extends ViewPart implements ISelectionListener {
                                                 expressionController.setEnabled(false);\r
                                                 expressionComposite.setEnabled(false);\r
                                                 nameComposite.setEnabled(false);\r
+                                                \r
                                                 unitSelector.clear(); // empty units\r
+                                                shortcutTabs.updateTables(variable);\r
                                                 expressionController.setExpressionTypes(null);   \r
                                                 nameComposite.setName(result.name);\r
                                                 expressionComposite.resetExpressionView(variable);\r
index d256d01960d7c2b56367bf12bcf4bc63d6d1ccad..23b27d192d31dceef4f69d0190f2bcd64e619f8e 100644 (file)
@@ -27,7 +27,7 @@ public class ShortcutTabs extends Composite {
     TabItem functions;\r
     Table variableTable;\r
     Table functionTable;\r
-    \r
+\r
     public ShortcutTabs(Composite parent, int style) {\r
         super(parent, style);\r
 \r
@@ -58,10 +58,10 @@ public class ShortcutTabs extends Composite {
         item.setText("if then else");\r
         item.setData("if then else");\r
         functions.setControl(functionTable);\r
-        \r
+\r
         this.layout();\r
     }\r
-    \r
+\r
     public HashSet<String> updateTables(Resource variable) {\r
         HashSet<String> dependencies = getDependencies(variable);\r
         variableTable.removeAll();\r
@@ -73,46 +73,47 @@ public class ShortcutTabs extends Composite {
         }\r
         return dependencies;\r
     }\r
-    \r
+\r
     // Returns the names of the related variables (dependencies)\r
     private HashSet<String> getDependencies(final Resource r){\r
         HashSet<String> variables = null;\r
-        try {\r
-            variables = SimanticsUI.getSession().syncRequest(new Read<HashSet<String>>() {\r
-\r
-                @Override\r
-                public HashSet<String> perform(ReadGraph graph)\r
-                throws DatabaseException {\r
-                    HashSet<String> variables = new HashSet<String>();\r
-                    SysdynResource sr = SysdynResource.getInstance(graph);\r
-                    Builtins b = graph.getBuiltins();\r
-\r
-                    Collection<Resource> dependencies = graph.getObjects(r, sr.IsHeadOf);\r
-\r
-                    for(Resource d : dependencies) {\r
-                        if(graph.isInstanceOf(d, sr.Dependency)) {\r
-                            Resource tail = graph.getPossibleObject(d, sr.HasTail);\r
-                            if(tail != null) {\r
-                                Object name = graph.getPossibleRelatedValue(tail, b.HasName);\r
-                                if(name != null)\r
-                                    variables.add((String)name);\r
+        if(r != null)\r
+            try {\r
+                variables = SimanticsUI.getSession().syncRequest(new Read<HashSet<String>>() {\r
+\r
+                    @Override\r
+                    public HashSet<String> perform(ReadGraph graph)\r
+                    throws DatabaseException {\r
+                        HashSet<String> variables = new HashSet<String>();\r
+                        SysdynResource sr = SysdynResource.getInstance(graph);\r
+                        Builtins b = graph.getBuiltins();\r
+\r
+                        Collection<Resource> dependencies = graph.getObjects(r, sr.IsHeadOf);\r
+\r
+                        for(Resource d : dependencies) {\r
+                            if(graph.isInstanceOf(d, sr.Dependency)) {\r
+                                Resource tail = graph.getPossibleObject(d, sr.HasTail);\r
+                                if(tail != null) {\r
+                                    Object name = graph.getPossibleRelatedValue(tail, b.HasName);\r
+                                    if(name != null)\r
+                                        variables.add((String)name);\r
+                                }\r
                             }\r
                         }\r
-                    }\r
 \r
-                    return variables;\r
+                        return variables;\r
 \r
-                }\r
+                    }\r
 \r
 \r
-            });\r
-        } catch (DatabaseException ee) {\r
-            ExceptionUtils.logAndShowError(ee);\r
-        }\r
+                });\r
+            } catch (DatabaseException ee) {\r
+                ExceptionUtils.logAndShowError(ee);\r
+            }\r
 \r
-        return variables;\r
+            return variables;\r
     }\r
-   \r
+\r
     public Table getVariableTable() {\r
         return this.variableTable;\r
     }\r