]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Disable DB level undo, when model modifying actions are active 63/3663/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 3 Dec 2019 12:37:32 +0000 (14:37 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 3 Dec 2019 13:01:21 +0000 (13:01 +0000)
gitlab #60

Change-Id: Idf996ffa7ee87eac42ecd1118c4a4bd99aa0cc2c
(cherry picked from commit 0a4af0014e06aa2f295bed0b4ab94c3a2bab37f3)

org.simantics.g3d.vtk/META-INF/MANIFEST.MF
org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java
org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java
org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java
org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java

index e0a83e09297d5096f4266ca2f57dfd33c29f18b3..1e0a2fede32ee9ff9a9b9422579157817c6f5971 100644 (file)
@@ -18,6 +18,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.simantics.g3d.ontology;bundle-version="1.0.0",
  vtk;bundle-version="5.10.0",
  org.simantics.utils.ui;bundle-version="1.1.0",
+ org.simantics.ui;bundle-version="1.0.0",
  vtk.rendering;bundle-version="8.2.0",
  org.simantics.utils.thread.swt;bundle-version="1.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
index 01327c519cc577fdbb533992a13585c1bd959144..da9088049bcefd98f2a80458136b1efe4172e2f8 100644 (file)
@@ -1,9 +1,22 @@
 package org.simantics.g3d.vtk.action;
 
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.State;
 import org.eclipse.jface.action.Action;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.simantics.ui.states.TrackedTextState;
 
 public abstract class vtkAction extends Action{
 
        public abstract void attach();
        public abstract void deattach();
-}
+       
+       
+       protected void setDBUndo(boolean enabled) {
+           ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
+        Command command = service.getCommand( TrackedTextState.COMMAND_ID );
+        State state = command.getState( TrackedTextState.STATE_ID );
+        state.setValue(enabled);
+       }
+ }
index f9ea1877b154b13653963026501138a7b1a712be..eb557eed915f430f8e0710ee267e31dcd1e286fd 100644 (file)
@@ -173,12 +173,13 @@ public class RotateAction extends vtkSwtAction{
                                update();
                        }
                });
-               
+               setDBUndo(false);
                
                
        }
        
        public void deattach() {
+           setDBUndo(true);
            if (toolComposite != null) {
             toolComposite.clear();
             axisCombo = null;
index 682112cfefdbd12ba1dc6abac8752b01bd1d8a39..f80583a27ac3c966573cc080453d07cab7615513 100644 (file)
@@ -127,7 +127,7 @@ public class TranslateAction extends vtkSwtAction{
                if (toolComposite != null) {
                   createTools(toolComposite); 
                }
-               
+               setDBUndo(false);
                super.attach();
                ThreadUtils.asyncExec(panel.getThreadQueue(), new Runnable() {
                        public void run() {
@@ -142,7 +142,7 @@ public class TranslateAction extends vtkSwtAction{
                toolComposite.clear();
                axisCombo = null;
            }
-               
+           setDBUndo(true);
                node = null;
                nodeMap.commit("Translate");
                deattachUI();
index 389f3be5de60484f4370dbf3aafe3a14cc9fa746..c7c7234ef0f679a4b038253aa6a73b4c1be14a7c 100644 (file)
@@ -176,6 +176,7 @@ public class RoutePipeAction extends vtkSwtAction {
 
     public void deattach() {
         deactivate();
+        setDBUndo(true);
         if (toolComposite != null) {
             toolComposite.clear();
             axisCombo = null;
@@ -195,6 +196,7 @@ public class RoutePipeAction extends vtkSwtAction {
                if (toolComposite != null) {
                   createTools(toolComposite); 
            }
+               setDBUndo(false);
                super.attach();
                ThreadUtils.asyncExec(panel.getThreadQueue(), new Runnable() {
                        public void run() {