From 104c08943ee34cafe2f7521730cad5a0cf4a42a4 Mon Sep 17 00:00:00 2001 From: lempinen Date: Mon, 11 Jan 2010 14:10:38 +0000 Subject: [PATCH] Expression type data saved when type changed git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@13474 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/equation/ExpressionController.java | 2 +- .../expressions/AuxiliaryExpressionViewFactor.java | 6 ++++++ .../expressions/ConstantExpressionViewFactor.java | 6 ++++++ .../equation/expressions/DelayExpressionViewFactor.java | 6 ++++++ .../ui/equation/expressions/IExpressionViewFactor.java | 5 +++++ .../equation/expressions/LookupExpressionViewFactor.java | 6 ++++++ .../expressions/ParameterExpressionViewFactor.java | 6 ++++++ .../equation/expressions/StockExpressionViewFactor.java | 8 +++++++- .../expressions/WithLookupExpressionViewFactor.java | 8 ++++++++ 9 files changed, 51 insertions(+), 2 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionController.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionController.java index 1f60cd03..d331d23d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionController.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionController.java @@ -138,8 +138,8 @@ public class ExpressionController extends Composite { @Override public void widgetSelected(SelectionEvent e) { + getExpressionViewFactor().updateData(data); displayExpressionView(variable, ExpressionType.valueOf(typeCombo.getItem(typeCombo.getSelectionIndex())), false); - } @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/AuxiliaryExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/AuxiliaryExpressionViewFactor.java index 6828ef1d..e756dbf6 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/AuxiliaryExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/AuxiliaryExpressionViewFactor.java @@ -136,4 +136,10 @@ public class AuxiliaryExpressionViewFactor implements IExpressionViewFactor { expression.setSelection(lastSelection.x + var.length()); } } + + @Override + public void updateData(Map data) { + if(this.expression != null && this.expression.getText() != null) + data.put("equation", this.expression.getText()); + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java index 708ef86c..4d0a1726 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java @@ -138,4 +138,10 @@ public class ConstantExpressionViewFactor implements IExpressionViewFactor { } } + @Override + public void updateData(Map data) { + if(this.expression != null && this.expression.getText() != null) + data.put("equation", this.expression.getText()); + } + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/DelayExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/DelayExpressionViewFactor.java index a2545511..fbb6392d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/DelayExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/DelayExpressionViewFactor.java @@ -37,4 +37,10 @@ public class DelayExpressionViewFactor implements IExpressionViewFactor { } + @Override + public void updateData(Map data) { + // TODO Auto-generated method stub + + } + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/IExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/IExpressionViewFactor.java index 0cee3b46..76ca7170 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/IExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/IExpressionViewFactor.java @@ -44,4 +44,9 @@ public interface IExpressionViewFactor { */ void replaceSelection(String var); + /** + * Updates data from text inputs to the data map + * @param data + */ + void updateData(Map data); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupExpressionViewFactor.java index 129c64ce..98571aa9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupExpressionViewFactor.java @@ -37,4 +37,10 @@ public class LookupExpressionViewFactor implements IExpressionViewFactor { } + @Override + public void updateData(Map data) { + // TODO Auto-generated method stub + + } + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ParameterExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ParameterExpressionViewFactor.java index a5c02fbe..cb60a230 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ParameterExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ParameterExpressionViewFactor.java @@ -138,5 +138,11 @@ public class ParameterExpressionViewFactor implements IExpressionViewFactor { } } + @Override + public void updateData(Map data) { + if(this.expression != null && this.expression.getText() != null) + data.put("equation", this.expression.getText()); + } + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java index f10447b9..7a920ace 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java @@ -202,5 +202,11 @@ public class StockExpressionViewFactor implements IExpressionViewFactor { } - + @Override + public void updateData(Map data) { + if(this.expression != null && this.expression.getText() != null) + data.put("initialEquation", this.expression.getText()); + if(this.integral != null && this.integral.getText() != null) + data.put("integral", this.integral.getText()); + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java index 78a5d5a8..6308759b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java @@ -183,4 +183,12 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { lastSelectedText.setSelection(lastSelection.x + var.length()); } } + + @Override + public void updateData(Map data) { + if(this.expression != null && this.expression.getText() != null) + data.put("equation", this.expression.getText()); + if(this.lookup != null && this.lookup.getText() != null) + data.put("lookup", this.lookup.getText()); + } } \ No newline at end of file -- 2.47.1