From f36bb7c63520639baddd1e8a37c054c27ad1e4a5 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Wed, 8 Apr 2020 09:29:39 +0300 Subject: [PATCH] Minor improvement for Plant3DEditor extensibility * AbstractVTKNodeMap needs an overridable postCommit() method which is executed after doCommit() finishes successfully. This is needed in an extending editor to know the first moment in time when the editor has been initialized properly. * Allow customization of FitToWindow action created by Plant3DEditor gitlab #117 Change-Id: I50a36740e579664ddab83b659b79220b5d33c135 (cherry picked from commit 370a955304d3aeacfdd59aa42d875c6142499dfd) --- .../g3d/vtk/common/AbstractVTKNodeMap.java | 5 ++++- .../src/org/simantics/g3d/vtk/swt/FocusAction.java | 1 - .../org/simantics/plant3d/editor/Plant3DEditor.java | 13 +++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java index bc7c3552..0df8367f 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java @@ -315,11 +315,14 @@ public abstract class AbstractVTKNodeMap implements VT ExceptionUtils.logAndShowError("Cannot commit editor changes", e); } }); + postCommit(); } catch (InvocationTargetException | InterruptedException e) { LOGGER.error("Unexpected exception", e); } } - + + protected void postCommit() {} + protected void commit(WriteGraph graph) throws DatabaseException { synchronized(syncMutex) { if (DEBUG) System.out.println("Commit"); diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/FocusAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/FocusAction.java index 97d5abf0..e7aa816d 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/FocusAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/FocusAction.java @@ -5,7 +5,6 @@ import java.util.Collection; import org.eclipse.jface.action.Action; import org.simantics.g3d.vtk.Activator; import org.simantics.g3d.vtk.common.VtkView; -import org.simantics.utils.threads.AWTThread; import vtk.vtkProp; import vtk.vtkProp3D; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java index 72f2c206..af7a67f5 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Set; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; @@ -332,7 +333,7 @@ public class Plant3DEditor extends ResourceEditorPart { }); } - + protected IMappingSchema getSchema(ReadGraph graph) throws DatabaseException { IMappingSchema schema = SchemaBuilder.getSchema(graph); return schema; @@ -516,7 +517,7 @@ public class Plant3DEditor extends ResourceEditorPart { } } - private class FitToWindow extends Action { + protected class FitToWindow extends Action { private List selected; public FitToWindow(List selected) { super("Fit to Window"); @@ -536,7 +537,7 @@ public class Plant3DEditor extends ResourceEditorPart { } protected void createFocusMenu(IMenuManager m, List selected) { - m.add(new FitToWindow(selected)); + m.add(createFitToWindowAction(selected)); if (!selected.isEmpty()) { List actors = new ArrayList<>(); @@ -548,7 +549,11 @@ public class Plant3DEditor extends ResourceEditorPart { } } } - + + protected IAction createFitToWindowAction(List selected) { + return new FitToWindow(selected); + } + private IContentOutlinePage createOutline() { if (rootNode == null || selectionProvider == null) return null; -- 2.47.1