]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Activate variable save when the respective EquationTab is disposed.
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 13 Nov 2013 08:51:44 +0000 (08:51 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 13 Nov 2013 08:51:44 +0000 (08:51 +0000)
Save variable also when only the type of variable is changed.
(refs #4544).

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28247 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java

index 2ea9023a9d9bf6087ca67e8f528646ae8fa4b879..51ec05150c273214af029740a679bf5cd4291ac4 100644 (file)
             targetID="org.simantics.sysdyn.ui.perspective.equation">\r
          <view\r
                id="org.simantics.browsing.ui.graph.propertyView"\r
-               minimized="true"\r
-               ratio="0.8f"\r
+               minimized="false"\r
+               ratio="0.75f"\r
                relationship="bottom"\r
                relative="org.eclipse.ui.editorss">\r
          </view>\r
index 238a21b26eccae9dab96d85f5d1898827aca6c92..2f9e4380344bdf406c0cdeb510d645e8cd8e65ec 100644 (file)
@@ -73,6 +73,7 @@ import org.simantics.sysdyn.ui.properties.widgets.ExpressionWidget;
 import org.simantics.sysdyn.ui.properties.widgets.IsOutputWidget;\r
 import org.simantics.sysdyn.ui.properties.widgets.ShortcutTabWidget;\r
 import org.simantics.sysdyn.ui.properties.widgets.arrays.NameAndArrayRangeModifyListener;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.DelayExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionComposite;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionWidgetInput;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameInputValidator;\r
@@ -779,6 +780,11 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
 \r
        @Override\r
        public void dispose() {\r
+        if(expressionWidget != null && !(expressionWidget.getExpression() instanceof DelayExpression)) {\r
+               // For delay expression this doesn't work, \r
+               // but it doesn't matter since the saving is succeeded elsewhere.\r
+            expressionWidget.save();\r
+        }\r
                if(focusLostListener != null && site != null)\r
                        site.getPage().removePartListener(focusLostListener);\r
                super.dispose();\r
index 0ddbebc54434d93fb4bec9e6bce62734cd18a052..b522695163fd9635e1b6dbae413689b5ce193662 100644 (file)
@@ -131,10 +131,7 @@ public class BasicExpression implements IExpression {
     public void save(final Resource expression, Map<String, Object> data) {\r
         final String currentText = this.expression.getExpression();\r
         final String oldEquation = (String)data.get("equation");\r
-        \r
-        if(currentText != null && oldEquation != null && currentText.equals(oldEquation))\r
-            return; // Nothing is changed, no need to save\r
-        \r
+\r
         if(oldEquation == null || \r
                 (currentText != null && expressionType != null)) {\r
             data.put("equation", currentText);\r
@@ -145,14 +142,6 @@ public class BasicExpression implements IExpression {
                     SysdynResource sr = SysdynResource.getInstance(g);\r
                     Layer0 l0 = Layer0.getInstance(g);\r
 \r
-                    // Force change to parameter, if the equation is a parameter\r
-                    if(ExpressionUtils.isParameter(currentText)) {\r
-                       if(!expressionType.equals(sr.ConstantExpression))\r
-                               expressionType = sr.ParameterExpression;\r
-                    } else {\r
-                       expressionType = sr.NormalExpression;\r
-                    }\r
-                    \r
                     // If nothing has changed, do nothing\r
                     if (oldEquation != null \r
                             && expression != null \r
@@ -161,6 +150,14 @@ public class BasicExpression implements IExpression {
                         return;\r
                     }\r
                     \r
+                    // Force change to parameter, if the equation is a parameter\r
+                    if(ExpressionUtils.isParameter(currentText)) {\r
+                       if(!expressionType.equals(sr.ConstantExpression))\r
+                               expressionType = sr.ParameterExpression;\r
+                    } else {\r
+                       expressionType = sr.NormalExpression;\r
+                    }\r
+                    \r
                     // If the current expression type is different than the target expression type, create a new expression\r
                     if(!g.isInstanceOf(expression, expressionType)) {\r
 \r