From 3a6f2987166e821a166375be509723bda919e677 Mon Sep 17 00:00:00 2001 From: villberg Date: Wed, 30 Apr 2014 11:38:40 +0000 Subject: [PATCH] Some implementation based on new paradigm refs #4849 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29399 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../widgets/expressions/BasicExpression.java | 5 +++++ .../widgets/expressions/DelayExpression.java | 6 ++++++ .../widgets/expressions/ParameterExpression.java | 6 ++++++ .../widgets/expressions/StockExpression.java | 14 ++++++++++++++ .../widgets/expressions/WithLookupExpression.java | 6 ++++++ .../sysdyn/ui/utils/VariableNameValidator.java | 3 ++- org.simantics.sysdyn.ui/sysdyn.product | 3 +-- 7 files changed, 40 insertions(+), 3 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java index b5226951..742a4f3d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java @@ -32,6 +32,7 @@ import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; +import org.simantics.db.common.CommentMetadata; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.exception.DatabaseException; @@ -158,6 +159,10 @@ public class BasicExpression implements IExpression { expressionType = sr.NormalExpression; } + g.startUndoContext(); + CommentMetadata cm = g.getMetadata(CommentMetadata.class); + g.addMetadata(cm.add("Set equation")); + // If the current expression type is different than the target expression type, create a new expression if(!g.isInstanceOf(expression, expressionType)) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java index e7e5314c..258ee484 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java @@ -40,6 +40,7 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; +import org.simantics.db.common.CommentMetadata; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.exception.DatabaseException; @@ -328,6 +329,11 @@ public class DelayExpression implements IExpression { g.claim(expression, sr.DelayExpression_isInformationDelay, expression); else g.deny(expression, sr.DelayExpression_isInformationDelay, expression); + + g.startUndoContext(); + CommentMetadata cm = g.getMetadata(CommentMetadata.class); + g.addMetadata(cm.add("Set delay expression")); + } }); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/ParameterExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/ParameterExpression.java index cfaf2a6d..274ea5a2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/ParameterExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/ParameterExpression.java @@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Table; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; +import org.simantics.db.common.CommentMetadata; import org.simantics.db.common.request.WriteResultRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; @@ -135,6 +136,11 @@ public class ParameterExpression extends BasicExpression { if(valuesVariable == null) return false; valuesVariable.setValue(graph, new double[] {Double.parseDouble(currentText)}); + + graph.startUndoContext(); + CommentMetadata cm = graph.getMetadata(CommentMetadata.class); + graph.addMetadata(cm.add("Set parameter")); + return true; } catch (Exception e) { return false; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java index 3aced206..e8c51d20 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java @@ -37,6 +37,7 @@ import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; +import org.simantics.db.common.CommentMetadata; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; @@ -103,9 +104,14 @@ public class StockExpression implements IExpression { throws DatabaseException { // Delete the possible integral expression from the database to note // that we are in the "default" mode. + graph.startUndoContext(); SysdynResource sr = SysdynResource.getInstance(graph); graph.deny(input.expression, sr.StockExpression_useCustomIntegral); graph.claimLiteral(input.expression, sr.StockExpression_integralEquation, getDefaultIntegral(graph, input.expression)); + + CommentMetadata cm = graph.getMetadata(CommentMetadata.class); + graph.addMetadata(cm.add("Use default")); + } }); break; @@ -176,6 +182,9 @@ public class StockExpression implements IExpression { public void perform(WriteGraph graph) throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(graph); graph.claimLiteral(input.expression, sr.StockExpression_integralEquation, getDefaultIntegral(graph, input.expression)); + graph.startUndoContext(); + CommentMetadata cm = graph.getMetadata(CommentMetadata.class); + graph.addMetadata(cm.add("Set expression")); } }); @@ -265,6 +274,11 @@ public class StockExpression implements IExpression { g.claim(expression, sr.StockExpression_useCustomIntegral, expression); } g.claimLiteral(expression, sr.StockExpression_integralEquation, currentIntegral); + + g.startUndoContext(); + CommentMetadata cm = g.getMetadata(CommentMetadata.class); + g.addMetadata(cm.add("Save")); + } }); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java index 32b0bfed..cdb346fa 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java @@ -53,6 +53,7 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; +import org.simantics.db.common.CommentMetadata; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.exception.DatabaseException; @@ -312,6 +313,11 @@ public class WithLookupExpression implements IExpression { } g.claimLiteral(expr, sr.WithLookupExpression_expression, currentExpression); g.claimLiteral(expr, sr.WithLookupExpression_lookup, currentLookupTable); + + g.startUndoContext(); + CommentMetadata cm = g.getMetadata(CommentMetadata.class); + g.addMetadata(cm.add("Set lookup expression")); + } }); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameValidator.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameValidator.java index 5775f80a..b818a50b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameValidator.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameValidator.java @@ -65,7 +65,8 @@ public class VariableNameValidator extends NameValidator { if(o != null && graph.isInstanceOf(o, l0.String) && !p.equals(sr.Expression_arrayRange)) { String string = graph.getRelatedValue(s, p); String replaced = replaceAllWords(string, originalName, newName); - graph.claimLiteral(s, p, replaced); + if(!string.equals(replaced)) + graph.claimLiteral(s, p, replaced); } } } diff --git a/org.simantics.sysdyn.ui/sysdyn.product b/org.simantics.sysdyn.ui/sysdyn.product index 5c3c71bb..85a5e74e 100644 --- a/org.simantics.sysdyn.ui/sysdyn.product +++ b/org.simantics.sysdyn.ui/sysdyn.product @@ -16,7 +16,7 @@ -fixerrors --launcher.XXMaxPermSize 192m -data @noDefault - -ea -Xmx768M -XX:MaxPermSize=192m -Xshare:off -Dorg.simantics.undo.enabled=false + -ea -Xmx768M -XX:MaxPermSize=192m -Xshare:off -Dorg.simantics.undo.enabled=true -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Dorg.osgi.framework.os.name=win32 @@ -32,7 +32,6 @@ - org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6 -- 2.47.1