]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #5093
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jul 2014 07:03:25 +0000 (07:03 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jul 2014 07:03:25 +0000 (07: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@29903 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java

index 7523baeff6de50e561d408eb961ea4840bed347d..ceeff8aaefb53262cfa14a45a6e3a15a99e42fac 100644 (file)
@@ -50,6 +50,7 @@ import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;
 import org.simantics.db.layer0.migration.MigrationState;\r
 import org.simantics.db.layer0.migration.MigrationStateKeys;\r
 import org.simantics.db.layer0.migration.MigrationUtils;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.ModelDependenciesBean;\r
 import org.simantics.db.layer0.util.ModelDependency;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
@@ -148,7 +149,7 @@ public class ImportUtils {
         if(project == null) return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model: project not found", null);\r
 \r
         beginTask(monitor, "Import model", 10);\r
-        File importFile = new File(path);\r
+        final File importFile = new File(path);\r
         MigrationState state = MigrationUtils.newState();\r
         state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
         state.setProperty(MigrationStateKeys.MODEL_FILE, importFile);\r
@@ -156,6 +157,17 @@ public class ImportUtils {
 \r
         Session session = Simantics.getSession();\r
         \r
+        //TODO\r
+        // With this empty write it is possible to group change sets nicely in undo view and make good undoable collection\r
+        session.syncRequest(new WriteRequest() {\r
+            \r
+            @Override\r
+            public void perform(WriteGraph graph) throws DatabaseException {\r
+                graph.markUndoPoint();\r
+                Layer0Utils.addCommentMetadata(graph, "Imported Sysdyn model from " + importFile.getName());\r
+            }\r
+        });\r
+        \r
         final ModelDependenciesBean dependenciesBean = getModelDependenciesBean(state);\r
         if(dependenciesBean != null) {\r
             for(ModelDependency dependency : dependenciesBean.dependencies) {\r