]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Minor improvement for Plant3DEditor extensibility 09/4109/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 8 Apr 2020 06:29:39 +0000 (09:29 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 8 Apr 2020 06:29:39 +0000 (09:29 +0300)
* 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

org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java
org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/FocusAction.java
org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java

index bc7c35528fde4a33f07cc0c5755ecf27e781f1de..0df8367fd9964982a0734818817892d67a01a370 100644 (file)
@@ -315,11 +315,14 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> 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");
index 97d5abf0306c96e641b4aed039ba0c994dbc9862..e7aa816d9dc6b7e9bfc708acbb4dc10a6d16f66c 100644 (file)
@@ -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;
index 72f2c2066e4329bcac5c306786805ce4146eff01..af7a67f5f96f8e21221c8197c81179fb6b4b0a5e 100644 (file)
@@ -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<Resource, INode> getSchema(ReadGraph graph) throws DatabaseException {
                IMappingSchema<Resource,INode> 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<INode> selected;
                public FitToWindow(List<INode> selected) {
                        super("Fit to Window");
@@ -536,7 +537,7 @@ public class Plant3DEditor extends ResourceEditorPart {
        }
 
        protected void createFocusMenu(IMenuManager m, List<INode> selected) {
-               m.add(new FitToWindow(selected));
+               m.add(createFitToWindowAction(selected));
 
                if (!selected.isEmpty()) {
                        List<vtkProp3D> actors = new ArrayList<>();
@@ -548,7 +549,11 @@ public class Plant3DEditor extends ResourceEditorPart {
                        }
                }
        }
-       
+
+       protected IAction createFitToWindowAction(List<INode> selected) {
+               return new FitToWindow(selected);
+       }
+
        private IContentOutlinePage createOutline() {
                if (rootNode == null || selectionProvider == null)
                        return null;