]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
* Added "time" variable to text feed assistants: in expression editor, shortcut tab...
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 28 Jan 2013 11:53:32 +0000 (11:53 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 28 Jan 2013 11:53:32 +0000 (11:53 +0000)
* 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

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ShortcutTabWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/AllVariablesOfModel.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/SyntaxError.java

index 9ae392a57822e54be614538b3b7e170c05781da9..12baba9105108e36c8927d378d024b87fe488cb6 100644 (file)
@@ -24,8 +24,6 @@ import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.StyledText;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
-import org.eclipse.swt.events.FocusEvent;\r
-import org.eclipse.swt.events.FocusListener;\r
 import org.eclipse.swt.events.ModifyEvent;\r
 import org.eclipse.swt.events.ModifyListener;\r
 import org.eclipse.swt.events.MouseEvent;\r
@@ -591,22 +589,6 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
                        }\r
 \r
                });\r
-               \r
-               /*\r
-                * Shortcut tab widget should not maintain any selections for visual reasons\r
-                */\r
-               shortcutTabWidget.addFocusListener(new FocusListener() {\r
-\r
-                       @Override\r
-                       public void focusGained(FocusEvent e) {    \r
-                       }\r
-\r
-                       @Override\r
-                       public void focusLost(FocusEvent e) {\r
-                               ((Table)e.widget).deselectAll();\r
-                       }\r
-\r
-               });\r
 \r
                /* Modifying an expression sets a timed validation. The timer is\r
                 * reset after each modification \r
index f9f13d1e4af91baa361b7ef09dc774da8b06b4ba..ee1e9d94e895311be63478953a3524b7ad2bdfe8 100644 (file)
@@ -69,14 +69,14 @@ public class ShortcutTabWidget implements Widget {
         GridLayoutFactory.fillDefaults().applyTo(tabFolder);\r
         variables = new TabItem(tabFolder, SWT.NULL);\r
         variables.setText("Variables");\r
-        variableTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);\r
-\r
+        variableTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.NO_FOCUS | SWT.HIDE_SELECTION);\r
+        \r
         variables.setControl(variableTable);\r
 \r
         functions = new TabItem(tabFolder, SWT.NULL);\r
         functions.setText("Functions"); \r
 \r
-        functionTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);\r
+        functionTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.NO_FOCUS | SWT.HIDE_SELECTION);\r
         TableItem item = new TableItem(functionTable, SWT.NONE);\r
         \r
         //Finding functions\r
@@ -149,7 +149,7 @@ public class ShortcutTabWidget implements Widget {
     @Override\r
     public void setInput(ISessionContext context, Object input) {\r
         if(input instanceof IStructuredSelection) {\r
-            final Resource variable = ISelectionUtils.filterSingleSelection((IStructuredSelection)input, Resource.class);\r
+            final Resource variable = ISelectionUtils.filterSingleSelection(input, Resource.class);\r
             if(variable != null) {\r
                \r
                SimanticsUI.getSession().asyncRequest(new Read<HashSet<String>>() {\r
@@ -194,6 +194,11 @@ public class ShortcutTabWidget implements Widget {
                                                        }\r
                                                }\r
                                                \r
+                                               // Add the time variable\r
+                                               item = new TableItem(variableTable, SWT.NONE);\r
+                                item.setText("time");\r
+                                item.setData("time");\r
+                                               \r
                                                                synchronized(dependencyListeners) {\r
                                                                        for(Runnable listener : dependencyListeners)\r
                                                                                listener.run();\r
index 9b7e8ae6580441c759e55b339f3f5132ada0f3b3..241b7cbacde9ca3b92fbc60f7b06e1fa038910b5 100644 (file)
@@ -24,11 +24,12 @@ import org.simantics.utils.strings.AlphanumComparator;
  * variables inside modules.\r
  * \r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 public class AllVariablesOfModel implements IAllVariablesOfModel{\r
     \r
-    private Resource model;\r
+    private final Resource model;\r
     \r
     public AllVariablesOfModel(Resource model) {\r
         this.model = model;\r
@@ -40,7 +41,8 @@ public class AllVariablesOfModel implements IAllVariablesOfModel{
        }   \r
        \r
        \r
-       public String getVariablesLabel(ReadGraph graph, String variableId)\r
+       @Override\r
+    public String getVariablesLabel(ReadGraph graph, String variableId)\r
                        throws DatabaseException {\r
                   return variableId.substring(1).replace('/', '.');\r
        }\r
@@ -69,7 +71,7 @@ public class AllVariablesOfModel implements IAllVariablesOfModel{
                ReadConfiguration(graph, conf, "", result);\r
                \r
                // Add time to the variable list\r
-               result.add(new ChartVariable("time"));\r
+               result.add(new ChartVariable("time", "time"));\r
                \r
                // Finally sort the results\r
                Collections.sort(result, AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
index 15c8ddaa3e1689b044e1b4ce35a7e5c8f5073f30..ac22c1a68656271a62954539257cdf94f0640eac 100644 (file)
@@ -235,7 +235,9 @@ public class ExpressionUtils {
             if(parsingSucceeded && variableTable != null && !variableTable.isDisposed()) {\r
                 TableItem[] connectedVariables = variableTable.getItems();\r
                 for(TableItem ti : connectedVariables) {\r
-                    if(!variables.contains(ti.getText())) {\r
+                    if (ti.getText().equals("time")) {\r
+                        ti.setForeground(new Color(ti.getDisplay(), 127,127,127));\r
+                    } else if (!variables.contains(ti.getText())) {\r
                         ti.setForeground(new Color(ti.getDisplay(), 255,125,0));\r
                     } else {\r
                         ti.setForeground(new Color(ti.getDisplay(), 0, 0, 0));\r
index a2f86e76745b9044a6e05fefb00f4113471785b2..94979244794532ddde8e524cedce3bb0c6ed19d1 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField;
 /**\r
  * Class for containing errors caught in expression validation\r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 public class SyntaxError {\r
@@ -113,7 +114,7 @@ public class SyntaxError {
                 try {\r
                     start = document.getLineOffset(beginLine - 1) + beginColumn - 1;\r
                 } catch (BadLocationException e) {\r
-                    e.printStackTrace();\r
+                    //e.printStackTrace();\r
                 }\r
             }\r
             return start;\r
@@ -139,7 +140,7 @@ public class SyntaxError {
                 try {\r
                     offset = document.getLineOffset(endLine - 1) + endColumn - start;\r
                 } catch (BadLocationException e) {\r
-                    e.printStackTrace();\r
+                    //e.printStackTrace();\r
                 }\r
             }\r
             return offset;\r