]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Multiple dependency arrows show only one dependency in the table
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 20 Jan 2010 16:12:22 +0000 (16:12 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 20 Jan 2010 16:12:22 +0000 (16:12 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@13571 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 742ae5a350b6eb54e7e21ffb53f10bd0b3425bb4..b39f0044fde52472c88fd600cc6a1a419d69dd4c 100644 (file)
@@ -48,10 +48,10 @@ public class EquationView extends ViewPart implements ISelectionListener {
     //Resources\r
     Resource variable;\r
     Resource configuration;\r
-    \r
+\r
     boolean disposed = false;\r
     org.eclipse.ui.IPartListener2 focusLostListener;   \r
-    \r
+\r
     ShortcutTabs shortcutTabs;\r
     ExpressionTypeSelector expressionController;    \r
     Composite unitComposite;\r
@@ -62,7 +62,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
     Text nameText;\r
     Composite unitsAndRange;  \r
     Composite emptyComposite;\r
-    \r
+\r
     @Override    \r
     public void createPartControl(Composite parent) {\r
         // Listeners\r
@@ -81,7 +81,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
                         expressionComposite.save();\r
                     }\r
 \r
-                    \r
+\r
                     // Save unit\r
                     if(unitSelector != null) {\r
                         unitSelector.save();                       \r
@@ -104,18 +104,18 @@ public class EquationView extends ViewPart implements ISelectionListener {
         nameText.setFont(FONT);\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);\r
 \r
-       \r
+\r
         // Upper part of the view: Expression type\r
         expressionController = new ExpressionTypeSelector(parent, SWT.NONE);\r
         GridDataFactory.fillDefaults().applyTo(expressionController);\r
         addVariableTypeSelectionListener();\r
-        \r
+\r
         // Upper part of the view: Unit input/selection\r
         unitComposite = new Composite(parent, SWT.NONE);\r
         GridDataFactory.fillDefaults().applyTo(unitComposite);\r
         GridLayoutFactory.fillDefaults().applyTo(unitComposite);\r
         unitSelector = new UnitSelector(unitComposite, SWT.NONE);\r
\r
+\r
         // Center of the view: variables and possible functions\r
         shortcutTabs = new ShortcutTabs(parent, SWT.NONE);\r
         GridDataFactory.fillDefaults().span(1, 4).applyTo(shortcutTabs);\r
@@ -129,7 +129,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
         // Below variable name: Equation\r
         expressionComposite = new ExpressionComposite(parent, SWT.NONE);\r
         GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(expressionComposite);\r
-        \r
+\r
 \r
         // Lower part of the view: Units and Range\r
         unitsAndRange = new Composite(parent, SWT.NONE); \r
@@ -199,7 +199,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
 \r
                                         @Override\r
                                         public void run(){\r
-                                            \r
+\r
                                             if(configuration == null || !configuration.equals(result.configuration)) {\r
                                                 configuration = result.configuration;\r
                                                 if(unitSelector!= null) {\r
@@ -209,15 +209,15 @@ public class EquationView extends ViewPart implements ISelectionListener {
                                             } else {\r
                                                 unitSelector.updateUnits(variable);\r
                                             }\r
-                                            \r
+\r
                                             if(shortcutTabs != null) shortcutTabs.updateTables(variable);\r
-                                            \r
+\r
                                             String expressionType = expressionComposite.resetExpressionView(variable);\r
                                             addExpressionFieldListeners();\r
                                             validateExpressionFields();\r
                                             expressionController.setExpressionTypes(expressionComposite.getExpressionTypes());  \r
                                             expressionController.select(expressionType);\r
-                                            \r
+\r
                                             nameText.setText(result.name);\r
                                         }\r
                                     });      \r
@@ -238,17 +238,17 @@ public class EquationView extends ViewPart implements ISelectionListener {
     @Override\r
     public void setFocus() {\r
         if(expressionComposite != null)\r
-           expressionComposite.focus();\r
+            expressionComposite.focus();\r
     }\r
-    \r
+\r
     @Override\r
     public void dispose() {\r
         disposed = true;\r
         getViewSite().getPage().removePartListener(focusLostListener);\r
         super.dispose();\r
     }\r
-   \r
-    \r
+\r
+\r
     private void addVariableTypeSelectionListener() { \r
         expressionController.getTypeCombo().addSelectionListener(new SelectionListener() {\r
 \r
@@ -264,7 +264,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
             }\r
         });\r
     }\r
-    \r
+\r
     private void addVariableTableListeners() {\r
         final Table variableTable = this.shortcutTabs.getVariableTable();\r
         variableTable.addMouseListener(new MouseListener(){\r
@@ -309,24 +309,24 @@ public class EquationView extends ViewPart implements ISelectionListener {
 \r
         });\r
     }\r
-    \r
+\r
     private void addExpressionFieldListeners() {\r
-    if(expressionComposite.getExpressionViewFactor() != null)\r
-        for(Text text : expressionComposite.getExpressionViewFactor().getExpressionFields()) {\r
-            text.addModifyListener(new ModifyListener() {\r
+        if(expressionComposite.getExpressionViewFactor() != null)\r
+            for(Text text : expressionComposite.getExpressionViewFactor().getExpressionFields()) {\r
+                text.addModifyListener(new ModifyListener() {\r
 \r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    validateExpressionFields();\r
-                }\r
-            });\r
-        }\r
+                    @Override\r
+                    public void modifyText(ModifyEvent e) {\r
+                        validateExpressionFields();\r
+                    }\r
+                });\r
+            }\r
     }\r
-    \r
+\r
     private void validateExpressionFields() {\r
         ExpressionParser parser = new ExpressionParser(new StringReader(""));\r
         Set<String> variables = new HashSet<String>();\r
-        \r
+\r
         if(expressionComposite.getExpressionViewFactor() != null)\r
             for(Text text : expressionComposite.getExpressionViewFactor().getExpressionFields()) {\r
                 String textString = text.getText();\r
@@ -340,7 +340,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
                     return;\r
                 }\r
             }\r
-        \r
+\r
         for(TableItem ti : this.shortcutTabs.getVariableTable().getItems()) {\r
             if(!variables.contains(ti.getText())) {\r
                 for(Text text : expressionComposite.getExpressionViewFactor().getExpressionFields())\r
@@ -348,7 +348,16 @@ public class EquationView extends ViewPart implements ISelectionListener {
                 ti.setBackground(new Color(ti.getDisplay(), 255, 230, 230));\r
             } else {\r
                 ti.setBackground(new Color(ti.getDisplay(), 255, 255, 255));\r
+                variables.remove(ti.getText());\r
+            }\r
+        }\r
+\r
+        if(!variables.isEmpty()) {\r
+            String no_connections = "No connections for: ";\r
+            for(String s : variables) {\r
+                no_connections = no_connections + s + " ";\r
             }\r
+            System.out.println(no_connections);\r
         }\r
     }\r
 \r
index 533b6312305eae2bdfe6f9062e10bedc3c4e5dae..0835eb68c30598e218f4ca49cfab749103d7812f 100644 (file)
@@ -1,7 +1,7 @@
 package org.simantics.sysdyn.ui.equation;\r
 \r
-import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.HashSet;\r
 \r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
@@ -55,8 +55,8 @@ public class ShortcutTabs extends Composite {
         this.layout();\r
     }\r
     \r
-    public ArrayList<String> updateTables(Resource variable) {\r
-        ArrayList<String> dependencies = getDependencies(variable);\r
+    public HashSet<String> updateTables(Resource variable) {\r
+        HashSet<String> dependencies = getDependencies(variable);\r
         variableTable.removeAll();\r
         TableItem item;\r
         for(String d : dependencies) {\r
@@ -67,15 +67,15 @@ public class ShortcutTabs extends Composite {
     }\r
     \r
     // Returns the names of the related variables (dependencies)\r
-    private ArrayList<String> getDependencies(final Resource r){\r
-        ArrayList<String> variables = null;\r
+    private HashSet<String> getDependencies(final Resource r){\r
+        HashSet<String> variables = null;\r
         try {\r
-            variables = SimanticsUI.getSession().syncRequest(new Read<ArrayList<String>>() {\r
+            variables = SimanticsUI.getSession().syncRequest(new Read<HashSet<String>>() {\r
 \r
                 @Override\r
-                public ArrayList<String> perform(ReadGraph graph)\r
+                public HashSet<String> perform(ReadGraph graph)\r
                 throws DatabaseException {\r
-                    ArrayList<String> variables = new ArrayList<String>();\r
+                    HashSet<String> variables = new HashSet<String>();\r
                     SysdynResource sr = SysdynResource.getInstance(graph);\r
                     Builtins b = graph.getBuiltins();\r
 \r