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

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSpreadSheetHandler.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/SheetUtils.java

index 3a64607af182da73b28fbbcb20279ac3f7ab70cc..5a612a496de050c3e64317efc6f4449c49281beb 100644 (file)
@@ -19,7 +19,9 @@ import org.eclipse.ui.handlers.HandlerUtil;
 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.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.sysdyn.utils.SheetUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
@@ -44,7 +46,9 @@ public class NewSpreadSheetHandler extends AbstractHandler {
             \r
             @Override\r
             public void perform(WriteGraph graph) throws DatabaseException {\r
-                SheetUtils.createSheet(graph, book, null, new String[] {}, new int[] {50});\r
+                graph.markUndoPoint();\r
+                Resource sheet = SheetUtils.createSheet(graph, book, null, new String[] {}, new int[] {50});\r
+                Layer0Utils.addCommentMetadata(graph, "Created new Spreadsheet " + NameUtils.getSafeName(graph, sheet) + " " + sheet.toString());\r
             }\r
         });      \r
         return null;\r
index 5e93b99a16746f2430ffadedf49a06a49206d654..5525cc8d2598e0b002c28c09f4cd031e90e74e4e 100644 (file)
@@ -19,7 +19,6 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.ObjectsWithType;\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.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.layer0.Layer0;\r
@@ -30,7 +29,6 @@ import org.simantics.spreadsheet.resource.SpreadsheetResource;
 public class SheetUtils {\r
 \r
     public static Resource createSheet(WriteGraph graph, Resource book, String name, String[] colNames, int[] colWidths) throws DatabaseException {\r
-        graph.markUndoPoint();\r
         Layer0 L0 = Layer0.getInstance(graph);\r
         SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);\r
 \r
@@ -76,7 +74,6 @@ public class SheetUtils {
 //            graph.claim(result, L0.HasChildVariables, L0.HasChildVariables_Inverse, newCell);\r
 //            \r
 //        }\r
-        Layer0Utils.addCommentMetadata(graph, "Created new Spreadsheet " + name + " " + result.toString());\r
         return result;\r
 \r
     }\r