From 83caaa0466147628aeb4930623f76840f0498f3b Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 16 Jul 2014 07:03:25 +0000 Subject: [PATCH] refs #5093 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 --- .../sysdyn/utils/imports/ImportUtils.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java index 7523baef..ceeff8aa 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java @@ -50,6 +50,7 @@ import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor; import org.simantics.db.layer0.migration.MigrationState; import org.simantics.db.layer0.migration.MigrationStateKeys; import org.simantics.db.layer0.migration.MigrationUtils; +import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.layer0.util.ModelDependenciesBean; import org.simantics.db.layer0.util.ModelDependency; import org.simantics.db.layer0.util.RemoverUtil; @@ -148,7 +149,7 @@ public class ImportUtils { if(project == null) return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model: project not found", null); beginTask(monitor, "Import model", 10); - File importFile = new File(path); + final File importFile = new File(path); MigrationState state = MigrationUtils.newState(); state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration); state.setProperty(MigrationStateKeys.MODEL_FILE, importFile); @@ -156,6 +157,17 @@ public class ImportUtils { Session session = Simantics.getSession(); + //TODO + // With this empty write it is possible to group change sets nicely in undo view and make good undoable collection + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); + Layer0Utils.addCommentMetadata(graph, "Imported Sysdyn model from " + importFile.getName()); + } + }); + final ModelDependenciesBean dependenciesBean = getModelDependenciesBean(state); if(dependenciesBean != null) { for(ModelDependency dependency : dependenciesBean.dependencies) { -- 2.47.1