//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
Text nameText;\r
Composite unitsAndRange; \r
Composite emptyComposite;\r
- \r
+\r
@Override \r
public void createPartControl(Composite parent) {\r
// Listeners\r
expressionComposite.save();\r
}\r
\r
- \r
+\r
// Save unit\r
if(unitSelector != null) {\r
unitSelector.save(); \r
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
// 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
\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
} 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
@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
}\r
});\r
}\r
- \r
+\r
private void addVariableTableListeners() {\r
final Table variableTable = this.shortcutTabs.getVariableTable();\r
variableTable.addMouseListener(new MouseListener(){\r
\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
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
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
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
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
}\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