]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #5093
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 15 Jul 2014 08:03:06 +0000 (08:03 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 15 Jul 2014 08:03:06 +0000 (08:03 +0000)
Fixing undo problems in Sysdyn by adding graph.markUndoPoint() calls in write transactions

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

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/DelayMarkWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/IsOutputWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivitySeriesPropertyComposite.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java

index 194c0df12332d2d2f93fefc8b22f02b7606e7b35..666d10088a5a2c8253d6b5249743e704808722af 100644 (file)
@@ -31,8 +31,10 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.jfreechart.chart.properties.AdjustableTab;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.elements.connections.DependencyEdgeClass;\r
 import org.simantics.sysdyn.ui.elements.connections.DependencyNode;\r
@@ -83,6 +85,7 @@ public class DependencyTab  extends AdjustableTab {
             SysdynResource sr = SysdynResource.getInstance(graph);\r
             float width = ((float)selection) / 10.0f;\r
             graph.claimLiteral(connectionElement, sr.DependencyConnection_strokeWidth, width);\r
+            Layer0Utils.addCommentMetadata(graph, "Modified Line thickness for connection " + graph.getPossibleRelatedValue2(connectionElement, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to " + width);\r
         }\r
         \r
     }\r
@@ -114,9 +117,12 @@ public class DependencyTab  extends AdjustableTab {
         @Override\r
         public void apply(WriteGraph graph, Resource connectionElement) throws DatabaseException {\r
             SysdynResource sr = SysdynResource.getInstance(graph);\r
+            String currentLocation = graph.getPossibleRelatedValue2(connectionElement, sr.DependencyConnection_polarityLocation, Bindings.STRING);\r
+            if (currentLocation != null && currentLocation.equals(location))\r
+                return;\r
             graph.claimLiteral(connectionElement, sr.DependencyConnection_polarityLocation, location);\r
+            Layer0Utils.addCommentMetadata(graph, "Modified Location for connection " + graph.getPossibleRelatedValue2(connectionElement, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to " + location);\r
         }\r
-        \r
     }\r
     \r
     class PolarityLocationRadioSelectionFactory extends ReadFactoryImpl<Resource, Boolean> {\r
@@ -157,7 +163,11 @@ public class DependencyTab  extends AdjustableTab {
         @Override\r
         public void apply(WriteGraph graph, Resource connectionElement) throws DatabaseException {\r
             SysdynResource sr = SysdynResource.getInstance(graph);\r
+            String currentPolarity = graph.getPossibleRelatedValue2(connectionElement, sr.DependencyConnection_polarity, Bindings.STRING);\r
+            if (currentPolarity != null && currentPolarity.equals(polarity))\r
+                return;\r
             graph.claimLiteral(connectionElement, sr.DependencyConnection_polarity, polarity.trim());\r
+            Layer0Utils.addCommentMetadata(graph, "Modified Polarity for connection " + graph.getPossibleRelatedValue2(connectionElement, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to " + polarity.trim());\r
         }\r
         \r
     }\r
index 429014df04e1bf08bb075063a520d4fc3fe2f617..4d45a5cbad577d80891f6d51d3b3f8b674d1c4ba 100644 (file)
@@ -46,6 +46,7 @@ import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.AsyncReadGraph;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -56,6 +57,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.request.WriteResultRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.procedure.AsyncListener;\r
@@ -472,6 +474,7 @@ public class EquationTab extends AdjustableTab implements Widget {
                                                );\r
                                        }\r
                                });\r
+                               Layer0Utils.addCommentMetadata(graph, "Deleted Expression " + activeExpression + " from " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
                        }\r
                });\r
 \r
@@ -496,10 +499,12 @@ public class EquationTab extends AdjustableTab implements Widget {
                                        graph.claim(newExpression, l0.InstanceOf, graph.getSingleObject(activeExpression, l0.InstanceOf));\r
                                        if(graph.isInstanceOf(newExpression, sr.StockExpression)) {\r
                                                graph.claimLiteral(newExpression, sr.StockExpression_initialEquation, "");\r
+                                               Layer0Utils.addCommentMetadata(graph, "Created new Stock Expression " + newExpression + " for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
                                        }\r
                                } else {\r
                                    // If there was no active expression, create a normal expression\r
                                        graph.claim(newExpression, l0.InstanceOf, sr.NormalExpression);\r
+                                       Layer0Utils.addCommentMetadata(graph, "Created new Normal Expression " + newExpression + " for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
                                }\r
                                ArrayList<Resource> addition = new ArrayList<Resource>(1);\r
                                addition.add(newExpression);\r
index e5d4e0eca7cb2beccd440ead451844e8d236a6cb..d13f3e6ba68c5f2307f9ae75520dde184b8adb93 100644 (file)
@@ -22,12 +22,15 @@ import org.eclipse.swt.widgets.Composite;
 import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
 \r
@@ -155,8 +158,10 @@ public class DelayMarkWidget implements Widget{
                 final SysdynResource sr =  SysdynResource.getInstance(graph);\r
                 if(graph.hasStatement(input, sr.DependencyConnection_delayMark)) {\r
                            graph.deny(input, sr.DependencyConnection_delayMark);\r
+                           Layer0Utils.addCommentMetadata(graph, "Modified Delay mark for connection " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to False");\r
                        } else {\r
                            graph.claim(input, SysdynResource.getInstance(graph).DependencyConnection_delayMark, null, input);\r
+                           Layer0Utils.addCommentMetadata(graph, "Modified Delay mark for connection " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to True");\r
                        }\r
             }  \r
         });\r
index 5297182de0526ce2a9452f5d4241e066dd4f76dc..db9a513fde029e4b89e5ee308ca9374a56a05931 100644 (file)
@@ -19,12 +19,15 @@ import org.eclipse.swt.widgets.Composite;
 import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
 \r
@@ -88,8 +91,10 @@ public class IsOutputWidget implements Widget{
                 SysdynResource sr =  SysdynResource.getInstance(graph);\r
                 if(graph.hasStatement(input, sr.IsOutput)) {\r
                     graph.deny(input, sr.IsOutput);\r
+                    Layer0Utils.addCommentMetadata(graph, "Modified Is Output for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to False");\r
                 } else {\r
                     graph.claim(input, SysdynResource.getInstance(graph).IsOutput, null, input);\r
+                    Layer0Utils.addCommentMetadata(graph, "Modified Is Output for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to True");\r
                 }\r
             }\r
         });\r
index 4be6de7fb3c84a4bea89544775ce618f56e2d9bc..b6c5aed98c451193c622fc0430e9c04524fb536a 100644 (file)
@@ -23,7 +23,9 @@ import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.jfreechart.chart.properties.xyline.SeriesPropertyComposite;\r
 import org.simantics.layer0.Layer0;\r
@@ -81,9 +83,10 @@ public class SensitivitySeriesPropertyComposite extends SeriesPropertyComposite
                 Boolean result = graph.getPossibleRelatedValue(dataset, SR.Charts_SensitivityDataset_median, Bindings.BOOLEAN);\r
                 if(result == null)\r
                     result = false;\r
-                graph.claimLiteral(dataset, SR.Charts_SensitivityDataset_median, Boolean.FALSE.equals(result));\r
+                boolean newValue = Boolean.FALSE.equals(result);\r
+                graph.claimLiteral(dataset, SR.Charts_SensitivityDataset_median, newValue);\r
+                Layer0Utils.addCommentMetadata(graph, "Display Median for " + NameUtils.getSafeName(graph, series) + " to " + newValue);\r
             }\r
-            \r
         });\r
         \r
         Composite c = new Composite(this, SWT.NONE);\r
index 5b63087588acfc1f1ac32b08b070f774116db821..8418b14fe91cee2f3b4d7d35e9b8b406b4b02173 100644 (file)
@@ -94,7 +94,8 @@ public class UnitUtils {
     public static String matchUnits(ReadGraph graph, SysdynModel model, Configuration configuration, String unit, String expression) {\r
         if(unit == null)\r
             return "Unit not defined";\r
-        \r
+        if (expression == null)\r
+            return "Expression not defined";\r
         try {\r
             StringReader rightReader = new StringReader(expression);\r
             UnitParser rightParser = new UnitParser(rightReader);\r