]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #5093
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 11 Jul 2014 11:18:05 +0000 (11:18 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 11 Jul 2014 11:18:05 +0000 (11:18 +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@29865 ac1ea38d-2e2b-0410-8846-a27921b304fc

14 files changed:
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/EnumerationNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SCLModule.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SharedFunctionLibraryNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SharedOntologyNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectionBuilder.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewExperimentNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionLibraryHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewModuleNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java

index 7d7ee9dcb7f29ac2d45f83d58c21184858e3412a..bfa2943d6f2332794e53daedf9c6f27b301c086b 100644 (file)
@@ -5,6 +5,7 @@ import org.simantics.browsing.ui.common.node.IDeletableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.WriteGraph;\r
@@ -13,6 +14,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.layer0.Layer0;\r
@@ -76,6 +78,7 @@ public class EnumerationNode extends VariableNode<Resource> implements IModifiab
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    graph.markUndoPoint();\r
                     SysdynResource sr = SysdynResource.getInstance(graph);\r
                     for(Resource redeclaration : graph.getObjects(data, sr.Redeclaration_replacedEnumeration_Inverse)) {\r
                        graph.deny(redeclaration, sr.Module_redeclaration_Inverse);\r
@@ -96,8 +99,9 @@ public class EnumerationNode extends VariableNode<Resource> implements IModifiab
                         }\r
                     }\r
                     \r
+                    String enumerationName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
-                    \r
+                    Layer0Utils.addCommentMetadata(graph, "Removed Enumeration " + enumerationName + " "+ data.toString());\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index deeb8dd7082e0fbfedcdfc9bc91818477baf6cd7..e059b644b23223fc0e0646f840ad2738131b7f5e 100644 (file)
@@ -20,12 +20,15 @@ import org.simantics.browsing.ui.common.node.IDoubleClickableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.project.IProject;\r
 import org.simantics.simulation.project.IExperimentManager;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -81,7 +84,9 @@ public class ExperimentNode extends AbstractNode<Resource> implements IDoubleCli
                     if(resultSets != null)\r
                         for(Resource resultSet : resultSets) \r
                             SimulationResultSetNode.unlinkResultSet(graph, resultSet);\r
+                    String ontologyName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed experiment " + ontologyName + " "+ data.toString());\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index 660fe185108c48855429b56772caf8a948886266..13971866e315e2a9e6594920019bcc259784c648 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.browser.nodes;\r
 \r
+import org.simantics.Simantics;\r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.browsing.ui.common.node.DeleteException;\r
 import org.simantics.browsing.ui.common.node.IDeletableNode;\r
@@ -18,6 +19,7 @@ import org.simantics.browsing.ui.common.node.IDoubleClickableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\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
@@ -25,6 +27,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
@@ -49,14 +52,22 @@ public class ModelNode extends AbstractNode<Resource> implements IDoubleClickabl
 \r
                @Override\r
                        public void execute(final String result) {\r
-                               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                   if (result == null)\r
+                       return;\r
+                               Simantics.getSession().asyncRequest(new WriteRequest() {\r
                                        \r
                                        @Override\r
                                        public void perform(WriteGraph graph) throws DatabaseException {\r
                                                Layer0 l0 = Layer0.getInstance(graph);\r
                                                SimulationResource sim = SimulationResource.getInstance(graph);\r
                                                Resource configuration = graph.getPossibleObject(data, sim.HasConfiguration);\r
+                                               \r
+                                               String label = graph.getPossibleRelatedValue2(configuration, l0.HasLabel, Bindings.STRING);\r
+                                               if (label != null)\r
+                                                   return;\r
+                                               \r
                                                graph.claimLiteral(configuration, l0.HasLabel, result);\r
+                                               Layer0Utils.addCommentMetadata(graph, "Created ModelNode to model browser for model " + result);\r
                                        }\r
                                });\r
                        }\r
@@ -98,10 +109,13 @@ public class ModelNode extends AbstractNode<Resource> implements IDoubleClickabl
                 return new WriteRequest() {\r
                     @Override\r
                     public void perform(WriteGraph g) throws DatabaseException {\r
+                        g.markUndoPoint();\r
                        Layer0 l0 = Layer0.getInstance(g);\r
+                       String oldName = g.getPossibleRelatedValue2(data, l0.HasLabel, Bindings.STRING);\r
                         g.claimLiteral(data, l0.HasLabel, label);\r
                         String safeName = NameUtils.findFreshName(g, label, g.getSingleObject(data, l0.PartOf), l0.ConsistsOf, "%s%d");\r
                         g.claimLiteral(data, l0.HasName, safeName);\r
+                        Layer0Utils.addCommentMetadata(g, "Renamed model " + oldName + " to " + label + " " + data.toString());\r
                     }\r
                 };\r
             }\r
@@ -116,13 +130,20 @@ public class ModelNode extends AbstractNode<Resource> implements IDoubleClickabl
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    \r
+                    graph.markUndoPoint();\r
+                    \r
                        Layer0 l0 = Layer0.getInstance(graph);\r
                        \r
                     for(Resource r : graph.getObjects(data, l0.ConsistsOf))\r
                         if(graph.isInstanceOf(r, SysdynResource.getInstance(graph).Result))\r
                             SimulationResultNode.deleteResultFiles(graph, r);\r
 \r
+                    String modelName = graph.getPossibleRelatedValue2(data, l0.HasName, Bindings.STRING);\r
+                    String modelResource = data.toString();\r
                     RemoverUtil.remove(graph, data);\r
+                    \r
+                    Layer0Utils.addCommentMetadata(graph, "Removed model '" + modelName +"' " + modelResource);\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index 6d7734460b06799a8a4fe90163c93e29b18592c4..06e93bd0b22b7d5c5f04e5f7b434afcf0978230a 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.browsing.ui.common.node.IDeletableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\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
@@ -34,6 +35,7 @@ import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
 import org.simantics.db.exception.ServiceException;\r
 import org.simantics.db.layer0.adapter.PasteHandler;\r
 import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
@@ -78,8 +80,12 @@ public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletable
                                        \r
                                        @Override\r
                                        public void perform(WriteGraph graph) throws DatabaseException {\r
-                                               if(configuration != null)\r
-                                                       graph.claimLiteral(configuration, Layer0.getInstance(graph).HasLabel, result);\r
+                                               if(configuration != null) {\r
+                                                   Layer0 L0 = Layer0.getInstance(graph);\r
+                                                   String currentLabel = graph.getRelatedValue2(configuration, L0.HasLabel, Bindings.STRING);\r
+                                                   if (!currentLabel.equals(result))\r
+                                                       graph.claimLiteral(configuration, L0.HasLabel, result);\r
+                                               }\r
                                        }\r
                                });\r
                        }\r
@@ -150,6 +156,7 @@ public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletable
 \r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException{\r
+                    graph.markUndoPoint();\r
                        Layer0 l0 = Layer0.getInstance(graph);\r
                     StructuralResource2 st = StructuralResource2.getInstance(graph);\r
                     ModelingResources mr = ModelingResources.getInstance(graph);\r
@@ -175,6 +182,7 @@ public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletable
                             RemoverUtil.remove(graph, issue);\r
                         }\r
                     }\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed Module Type " + graph.getRelatedValue2(type, l0.HasName, Bindings.STRING) + " " + type.toString());\r
                     RemoverUtil.remove(graph, type);\r
                 }\r
             });\r
index 70815ee471a1201b004dd4e31c91f74462f6079b..9307287ea630a3888b389a94a6d2b25a0428bce6 100644 (file)
@@ -17,12 +17,14 @@ import org.simantics.browsing.ui.common.node.IDeletableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.ui.SimanticsUI;\r
@@ -40,7 +42,9 @@ public class SCLModule extends AbstractNode<Resource> implements IDeletableNode,
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    String ontologyName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed SCL Module " + ontologyName + " "+ data.toString());\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index e2269ebaa27f445fd4bb687553cd786115e5c62f..b508227732e4818dc2c11314bf989653314e2c65 100644 (file)
@@ -15,10 +15,13 @@ import org.simantics.browsing.ui.common.node.DeleteException;
 import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.utils.SharedFunctionLibraryNameValidator;\r
@@ -37,12 +40,9 @@ public class SharedFunctionLibraryNode extends FunctionLibraryNode<Resource> imp
 \r
                        @Override\r
                        public void perform(WriteGraph graph) throws DatabaseException {\r
-                               Layer0 l0 = Layer0.getInstance(graph);\r
-                               \r
-                               graph.deny(data, l0.PartOf);\r
-                               graph.deny(data, l0.IsLinkedTo_Inverse);\r
-\r
-                               // TODO: remove file\r
+                String ontologyName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
+                RemoverUtil.remove(graph, data);\r
+                Layer0Utils.addCommentMetadata(graph, "Removed Shared Function Library " + ontologyName + " "+ data.toString());\r
                        }\r
                });\r
        }\r
index 6e6d5951bdb4f1b7b2fd83276ff842cf119e10fb..678a4c05256834b00accbb5c1fe304cbec81241d 100644 (file)
@@ -1,17 +1,20 @@
 package org.simantics.sysdyn.ui.browser.nodes;\r
 \r
+import org.simantics.Simantics;\r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.browsing.ui.common.node.DeleteException;\r
 import org.simantics.browsing.ui.common.node.IDeletableNode;\r
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
-import org.simantics.ui.SimanticsUI;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.utils.ui.ExceptionUtils;\r
 \r
 public class SharedOntologyNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
@@ -23,10 +26,13 @@ public class SharedOntologyNode extends AbstractNode<Resource> implements IDelet
     @Override\r
     public void delete() throws DeleteException {\r
         try {\r
-            SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+            Simantics.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    graph.markUndoPoint();\r
+                    String ontologyName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed Shared Ontology " + ontologyName + " "+ data.toString());\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index 159abc54e33267ad5da55dffa8acc3ae243a3957..5f3c32594ab5b90e1d2fe96bbab8bf7a7171b566 100644 (file)
@@ -22,6 +22,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.diagram.content.ConnectionUtil;\r
 import org.simantics.diagram.participant.ConnectionBuilder;\r
 import org.simantics.diagram.participant.ControlPoint;\r
@@ -65,6 +66,9 @@ public class SysdynConnectionBuilder extends ConnectionBuilder{
      */\r
     public void create(WriteGraph graph, ConnectionJudgement judgment, Deque<ControlPoint> controlPoints,\r
             TerminalInfo startTerminal, TerminalInfo endTerminal) throws DatabaseException {\r
+        \r
+        graph.markUndoPoint();\r
+        \r
        // If needs a valve, we will create two separate connections\r
         if(needsValve(startTerminal, endTerminal)) {\r
                createValveAndConnections(graph, judgment, controlPoints, startTerminal, endTerminal);\r
@@ -73,6 +77,14 @@ public class SysdynConnectionBuilder extends ConnectionBuilder{
         else {\r
                createConnection(graph, judgment, controlPoints, startTerminal, endTerminal, false);\r
         }\r
+        \r
+        String startElementName = startTerminal.e.getHint(ElementHints.KEY_TEXT);\r
+        String endElementName = endTerminal.e.getHint(ElementHints.KEY_TEXT);\r
+        \r
+        String startElementResource = startTerminal.e.getHint(ElementHints.KEY_OBJECT).toString();\r
+        String endElementResource = endTerminal.e.getHint(ElementHints.KEY_OBJECT).toString();\r
+        \r
+        Layer0Utils.addCommentMetadata(graph, "Created dependency starting from " + startElementName + " " + startElementResource + " and ending to " + endElementName + " " + endElementResource);\r
     }\r
     /**\r
      * @param graph\r
index 6801225c1d069a66cfd542c12e046bfb2a83312f..81128020d790d378897b92cfc81c8a6ae49f0f55 100644 (file)
@@ -18,12 +18,14 @@ import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;\r
 import org.eclipse.jface.viewers.ISelection;\r
 import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.ListUtils;\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.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.modeling.ModelingResources;\r
@@ -51,6 +53,7 @@ public class NewEnumerationNodeHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                SysdynResource sr = SysdynResource.getInstance(g);\r
                Layer0 l0 = Layer0.getInstance(g);\r
                \r
@@ -79,6 +82,7 @@ public class NewEnumerationNodeHandler extends AbstractHandler {
                                l0.HasName, name,\r
                                sr.Enumeration_enumerationIndexList, ListUtils.create(g, new ArrayList<Resource>()),\r
                                l0.PartOf, configuration);\r
+               Layer0Utils.addCommentMetadata(g, "Created new Enumeration " + name + " to " + g.getRelatedValue2(configuration, l0.HasLabel, Bindings.STRING));\r
             }\r
         });\r
                return null;\r
index 0ddf1a3b8ea2295c99bc7f38acdbadd73bc0934a..ddfc2b1d58ef4e052d02b2eae9388f79d2b051c3 100644 (file)
@@ -24,6 +24,7 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.WriteRequest;\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.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -56,6 +57,7 @@ public class NewExperimentNodeHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 String label = NameUtils.findFreshName(g, getNameSuggestion(), model, l0.ConsistsOf, l0.HasLabel, "%s%d");\r
                 Resource experiment = GraphUtils.create2(g, getExperimentType(g),\r
@@ -63,6 +65,7 @@ public class NewExperimentNodeHandler extends AbstractHandler {
                         l0.HasLabel, label,\r
                         l0.PartOf, model);\r
                 configureExperiment(g, experiment);\r
+                Layer0Utils.addCommentMetadata(g, "Created new experiment " + label + " " + experiment.toString());\r
             }\r
         });\r
         return null;\r
index bf62f3efdf04d739becd531ae55e2af1c4fdf0c9..62d88a4ad474287d704bb3ab476d3f94830ff630 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -63,6 +64,7 @@ public class NewFunctionLibraryHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                Layer0 l0 = Layer0.getInstance(g);\r
                 SysdynResource sr = SysdynResource.getInstance(g);\r
 \r
@@ -100,6 +102,8 @@ public class NewFunctionLibraryHandler extends AbstractHandler {
                 \r
                 if(shared)\r
                        g.claim(model, l0.IsLinkedTo, functionLibrary);\r
+                \r
+                Layer0Utils.addCommentMetadata(g, "Created new Function Library " + name + " " + functionLibrary.toString());\r
             }\r
         });\r
        }\r
index 60170f7eccc9fd459d52038d5cbc47bde51aae0f..b5939cb726d4ea9a92a1080a4cff87ca821af6cf 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.adapter.Template;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
@@ -33,8 +34,8 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.sysdyn.ui.browser.actions.newActions.NewModuleTypeAction;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.ui.AdaptionUtils;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Creates a new module node for a model.\r
@@ -62,6 +63,7 @@ public class NewModuleNodeHandler extends AbstractHandler {
             \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                 SysdynResource sr = SysdynResource.getInstance(g);\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 Layer0X L0X = Layer0X.getInstance(g);\r
@@ -122,7 +124,7 @@ public class NewModuleNodeHandler extends AbstractHandler {
                                 \r
                 g.claim(moduleSymbol, sr2.IsDefinedBy, OrderedSetUtils.create(g, sr2.Composite, terminal, terminal2));\r
             \r
-                \r
+                Layer0Utils.addCommentMetadata(g, "Created new Module Type " + name + " " + moduleType.toString());\r
             }\r
         });\r
         return null;\r
index f091b37ab32868d896a104784c2e2bc4c3f2406b..bb66b6e4f031d938f2c697840b66bcfebeab1d78 100644 (file)
@@ -355,15 +355,23 @@ public class VariableInformationTab extends AdjustableTab implements Widget {
 \r
             @Override\r
             public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+                graph.markUndoPoint();\r
                 Resource element = graph.getPossibleObject(input, ModelingResources.getInstance(graph).ComponentToElement);\r
                 if(element != null) {\r
                     G2DResource g2d = G2DResource.getInstance(graph);\r
                     graph.deny(element, g2d.HasFont);\r
-                    if(f != null)\r
+                    StringBuilder sb = new StringBuilder();\r
+                    if(f != null) {\r
                         graph.claim(element, g2d.HasFont, G2DUtils.createFont(graph, f));\r
+                        sb.append(" font to " + f.getName());\r
+                    }\r
                     graph.deny(element, g2d.HasColor);\r
-                    if(color != null)\r
+                    if(color != null) {\r
                         graph.claim(element,  g2d.HasColor, G2DUtils.createColor(graph, color));\r
+                        sb.append(" color to " + color.getRGB());\r
+                    }\r
+                    sb.insert(0, "Modified");\r
+                    Layer0Utils.addCommentMetadata(graph, sb.toString());\r
                 }\r
             }\r
 \r
index e3212abadf01480148dd62e73eac509b6e5ca839..98fb37c0c6362a86eefd56afe3b806a0a6519ce2 100644 (file)
@@ -11,6 +11,7 @@ import org.simantics.db.common.utils.Logger;
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.adapter.Template;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.document.DocumentResource;\r
 import org.simantics.issues.ontology.IssueResource;\r
 import org.simantics.layer0.Layer0;\r
@@ -56,6 +57,8 @@ public class ModelUtils {
 \r
     // TODO: remove this\r
     public static Resource createModelAt(WriteGraph g, Resource library) {\r
+        \r
+        g.markUndoPoint();\r
         try {\r
             Layer0 l0 = Layer0.getInstance(g);\r
             Layer0X L0X = Layer0X.getInstance(g);\r
@@ -178,6 +181,8 @@ public class ModelUtils {
             \r
             ProfileEntries.createStandardProfiles(g, model);\r
             \r
+            Layer0Utils.addCommentMetadata(g, "Created new Sysdyn Model '" + modelName + "' " + model.toString());\r
+            \r
             return model;\r
             \r
         } catch (DatabaseException e ) {\r