From: Marko Luukkainen Date: Tue, 3 Dec 2019 12:37:32 +0000 (+0200) Subject: Disable DB level undo, when model modifying actions are active X-Git-Tag: v1.43.0~104 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=b6de12aa6ceb6d0a77264ee7a1b2e01f3138411c;p=simantics%2F3d.git Disable DB level undo, when model modifying actions are active gitlab #60 Change-Id: Idf996ffa7ee87eac42ecd1118c4a4bd99aa0cc2c (cherry picked from commit 0a4af0014e06aa2f295bed0b4ab94c3a2bab37f3) --- diff --git a/org.simantics.g3d.vtk/META-INF/MANIFEST.MF b/org.simantics.g3d.vtk/META-INF/MANIFEST.MF index e0a83e09..1e0a2fed 100644 --- a/org.simantics.g3d.vtk/META-INF/MANIFEST.MF +++ b/org.simantics.g3d.vtk/META-INF/MANIFEST.MF @@ -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 diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java index 01327c51..da908804 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java @@ -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); + } + } diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java index f9ea1877..eb557eed 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java @@ -173,12 +173,13 @@ public class RotateAction extends vtkSwtAction{ update(); } }); - + setDBUndo(false); } public void deattach() { + setDBUndo(true); if (toolComposite != null) { toolComposite.clear(); axisCombo = null; diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java index 682112cf..f80583a2 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java @@ -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(); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java index 389f3be5..c7c7234e 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java @@ -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() {