From: miettinen Date: Mon, 28 Jan 2013 11:53:32 +0000 (+0000) Subject: * Added "time" variable to text feed assistants: in expression editor, shortcut tab... X-Git-Tag: simantics-1.10.1~57 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=2787d90b6af3230b5e2c839110659d03ecc56bbb;p=simantics%2Fsysdyn.git * Added "time" variable to text feed assistants: in expression editor, shortcut tab, and charts (refs #3990) * Refactoring the deselecting in shortcutTabWidget: listeners changed to style definitions git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26692 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java index 9ae392a5..12baba91 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java @@ -24,8 +24,6 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.custom.VerifyKeyListener; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.MouseEvent; @@ -591,22 +589,6 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget { } }); - - /* - * Shortcut tab widget should not maintain any selections for visual reasons - */ - shortcutTabWidget.addFocusListener(new FocusListener() { - - @Override - public void focusGained(FocusEvent e) { - } - - @Override - public void focusLost(FocusEvent e) { - ((Table)e.widget).deselectAll(); - } - - }); /* Modifying an expression sets a timed validation. The timer is * reset after each modification diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ShortcutTabWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ShortcutTabWidget.java index f9f13d1e..ee1e9d94 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ShortcutTabWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ShortcutTabWidget.java @@ -69,14 +69,14 @@ public class ShortcutTabWidget implements Widget { GridLayoutFactory.fillDefaults().applyTo(tabFolder); variables = new TabItem(tabFolder, SWT.NULL); variables.setText("Variables"); - variableTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); - + variableTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.NO_FOCUS | SWT.HIDE_SELECTION); + variables.setControl(variableTable); functions = new TabItem(tabFolder, SWT.NULL); functions.setText("Functions"); - functionTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); + functionTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.NO_FOCUS | SWT.HIDE_SELECTION); TableItem item = new TableItem(functionTable, SWT.NONE); //Finding functions @@ -149,7 +149,7 @@ public class ShortcutTabWidget implements Widget { @Override public void setInput(ISessionContext context, Object input) { if(input instanceof IStructuredSelection) { - final Resource variable = ISelectionUtils.filterSingleSelection((IStructuredSelection)input, Resource.class); + final Resource variable = ISelectionUtils.filterSingleSelection(input, Resource.class); if(variable != null) { SimanticsUI.getSession().asyncRequest(new Read>() { @@ -194,6 +194,11 @@ public class ShortcutTabWidget implements Widget { } } + // Add the time variable + item = new TableItem(variableTable, SWT.NONE); + item.setText("time"); + item.setData("time"); + synchronized(dependencyListeners) { for(Runnable listener : dependencyListeners) listener.run(); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/AllVariablesOfModel.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/AllVariablesOfModel.java index 9b7e8ae6..241b7cba 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/AllVariablesOfModel.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/AllVariablesOfModel.java @@ -24,11 +24,12 @@ import org.simantics.utils.strings.AlphanumComparator; * variables inside modules. * * @author Teemu Lempinen + * @author Tuomas Miettinen * */ public class AllVariablesOfModel implements IAllVariablesOfModel{ - private Resource model; + private final Resource model; public AllVariablesOfModel(Resource model) { this.model = model; @@ -40,7 +41,8 @@ public class AllVariablesOfModel implements IAllVariablesOfModel{ } - public String getVariablesLabel(ReadGraph graph, String variableId) + @Override + public String getVariablesLabel(ReadGraph graph, String variableId) throws DatabaseException { return variableId.substring(1).replace('/', '.'); } @@ -69,7 +71,7 @@ public class AllVariablesOfModel implements IAllVariablesOfModel{ ReadConfiguration(graph, conf, "", result); // Add time to the variable list - result.add(new ChartVariable("time")); + result.add(new ChartVariable("time", "time")); // Finally sort the results Collections.sort(result, AlphanumComparator.CASE_INSENSITIVE_COMPARATOR); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java index 15c8ddaa..ac22c1a6 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java @@ -235,7 +235,9 @@ public class ExpressionUtils { if(parsingSucceeded && variableTable != null && !variableTable.isDisposed()) { TableItem[] connectedVariables = variableTable.getItems(); for(TableItem ti : connectedVariables) { - if(!variables.contains(ti.getText())) { + if (ti.getText().equals("time")) { + ti.setForeground(new Color(ti.getDisplay(), 127,127,127)); + } else if (!variables.contains(ti.getText())) { ti.setForeground(new Color(ti.getDisplay(), 255,125,0)); } else { ti.setForeground(new Color(ti.getDisplay(), 0, 0, 0)); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/SyntaxError.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/SyntaxError.java index a2f86e76..94979244 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/SyntaxError.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/SyntaxError.java @@ -19,6 +19,7 @@ import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField; /** * Class for containing errors caught in expression validation * @author Teemu Lempinen + * @author Tuomas Miettinen * */ public class SyntaxError { @@ -113,7 +114,7 @@ public class SyntaxError { try { start = document.getLineOffset(beginLine - 1) + beginColumn - 1; } catch (BadLocationException e) { - e.printStackTrace(); + //e.printStackTrace(); } } return start; @@ -139,7 +140,7 @@ public class SyntaxError { try { offset = document.getLineOffset(endLine - 1) + endColumn - start; } catch (BadLocationException e) { - e.printStackTrace(); + //e.printStackTrace(); } } return offset;