ref #6925 Open bulk editor in editor area
authorPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 27 Oct 2017 11:15:28 +0000 (13:15 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 27 Oct 2017 11:15:28 +0000 (13:15 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorUtil.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/OpenBulkEditorHandlerE4.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForIdentifiableEntityE4.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForTaxonNodeHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/handler/OpenRelatedConceptInBulkEditorHandlerE4.java
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchUtility.java

index d39dfb3fff6d6ceb5868e83a3740f72cff1e6a26..b1d8f21f9116471bb7241889f768f3c4b94c215b 100644 (file)
@@ -11,9 +11,18 @@ package eu.etaxonomy.taxeditor.bulkeditor;
 
 import org.eclipse.core.commands.operations.IOperationHistory;
 import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
+import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
 
+import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
+import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
 import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
 
 /**
  * <p>BulkEditorUtil class.</p>
@@ -34,6 +43,18 @@ public class BulkEditorUtil extends AbstractUtility{
                return TaxeditorBulkeditorPlugin.PLUGIN_ID;
        }
 
+       public static void openBulkEditor(AbstractBulkEditorInput<?> input,
+               EModelService modelService, EPartService partService, MApplication application){
+           MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR);
+        MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
+        if(editorAreaPartStack!=null){
+            editorAreaPartStack.getChildren().add(part);
+        }
+        part = partService.showPart(part, PartState.ACTIVATE);
+        BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject();
+        bulkEditor.init(input);
+       }
+
        /**
         * <p>getUndoContext</p>
         *
index 41d4c019f83f353be2fa9f4581818dfc2a9fff11..0cf9b162b2da6e19f4b4ee8496985711bed6db16 100644 (file)
@@ -9,13 +9,12 @@
 package eu.etaxonomy.taxeditor.bulkeditor.e4.handler;
 import org.eclipse.core.commands.ParameterizedCommand;
 import org.eclipse.e4.core.di.annotations.Execute;
-import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
-import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
 
-import eu.etaxonomy.taxeditor.bulkeditor.AppModelId;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
-import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
 import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
 
@@ -28,13 +27,10 @@ import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
 public class OpenBulkEditorHandlerE4 {
 
        @Execute
-       public void execute(ParameterizedCommand command, EPartService partService) {
+       public void execute(ParameterizedCommand command, EPartService partService, MApplication application, EModelService modelService) {
            String inputTypeId = (String) command.getParameterMap().get(IBulkEditorConstants.INPUT_TYPE_PARAMETER_ID);
                BulkEditorInputType inputType = BulkEditorInputType.getById(inputTypeId);
-
-               MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR);
-        part = partService.showPart(part, PartState.ACTIVATE);
-        BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject();
-        bulkEditor.init(AbstractBulkEditorInput.NewInstance(inputType));
+               AbstractBulkEditorInput input = AbstractBulkEditorInput.NewInstance(inputType);
+               BulkEditorUtil.openBulkEditor(input, modelService, partService, application);
        }
 }
index deaff6c8bdf51b58a616958959f42f59d582ba1f..4d492c32182b86787607512d270af5f7786c2ead 100644 (file)
@@ -2,9 +2,7 @@ package eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler;
 
 import java.util.UUID;
 
-import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
-import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
 import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.model.agent.AgentBase;
@@ -14,8 +12,7 @@ import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.taxeditor.bulkeditor.AppModelId;
-import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
 import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -35,10 +32,8 @@ public class OpenBulkEditorForIdentifiableEntityE4 extends DefaultOpenHandlerBas
      */
     @Override
     protected void open(IdentifiableEntity entity, Shell shell, EPartService partService) {
-        MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR);
-        part = partService.showPart(part, PartState.ACTIVATE);
-        BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject();
-        bulkEditor.init(AbstractBulkEditorInput.NewInstance(entity));
+        AbstractBulkEditorInput input = AbstractBulkEditorInput.NewInstance(entity);
+        BulkEditorUtil.openBulkEditor(input, modelService, partService, application);
     }
 
     /**
index ea32da8080fb1a84dea8093daa9d7b0ae30e0147..8b9975b410e486d1da8d3f972f66175cff3beac9 100644 (file)
@@ -2,15 +2,12 @@ package eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler;
 
 import java.util.UUID;
 
-import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
-import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
 import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.bulkeditor.AppModelId;
-import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
 import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -24,10 +21,8 @@ public class OpenBulkEditorForTaxonNodeHandler extends DefaultOpenHandlerBaseE4<
 
     @Override
     protected void open(TaxonNode entity, Shell shell, EPartService partService) {
-        MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR);
-        part = partService.showPart(part, PartState.ACTIVATE);
-        BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject();
-        bulkEditor.init(AbstractBulkEditorInput.NewInstance(entity.getTaxon()));
+        AbstractBulkEditorInput input = AbstractBulkEditorInput.NewInstance(entity.getTaxon());
+        BulkEditorUtil.openBulkEditor(input, modelService, partService, application);
     }
 
     /**
index ea5224ca52550cc45335b2f70510f9758c8bd2ec..20543e0a24a7b6543137fb78a7d1991d380d4850 100644 (file)
 package eu.etaxonomy.taxeditor.editor;
 
 import java.util.Collection;
-import java.util.List;
 import java.util.UUID;
 
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.operations.IOperationHistory;
 import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.e4.ui.model.application.MApplication;
-import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
-import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
 import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
 import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
@@ -45,6 +42,7 @@ import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
 
 /**
  * Utility for the editor package
@@ -122,7 +120,7 @@ public class EditorUtil extends AbstractUtility {
         if(part==null){
             part = partService.createPart(NAME_EDITOR_ID);
 
-            MPartStack editorAreaPartStack = getEditorAreaPartStack(application, modelService);
+            MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
             if(editorAreaPartStack!=null){
                 editorAreaPartStack.getChildren().add(part);
             }
@@ -136,23 +134,6 @@ public class EditorUtil extends AbstractUtility {
         }
     }
 
-    public static MPartStack getEditorAreaPartStack(MApplication application, EModelService modelService){
-        //FIXME E4 hack for opening in e3 editor area
-        if(application!=null){
-            //FIXME E4 hack for opening in e3 editor area
-            List<MArea> elements = modelService.findElements(application, "org.eclipse.ui.editorss", MArea.class, null);
-            for (MArea mArea : elements) {
-                List<MPartSashContainerElement> children = mArea.getChildren();
-                for (MPartSashContainerElement mPartSashContainerElement : children) {
-                    if(mPartSashContainerElement instanceof MPartStack){
-                        return (MPartStack) mPartSashContainerElement;
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
        /**
         * An uninitialized taxon is one that hasn't been saved yet. As such, it
         * should appear in neither the list of recent names nor in the taxonomic
index 254ecedc6795788cbd46082e41e071207c00b727..76ef1b04264a2a5e4967bb4e88c267c2368ee1a2 100644 (file)
@@ -1,14 +1,11 @@
 package eu.etaxonomy.taxeditor.editor.view.concept.e4.handler;
 
 import org.eclipse.e4.ui.model.application.MApplication;
-import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
-import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
 
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.taxeditor.bulkeditor.AppModelId;
-import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
 
 public class OpenRelatedConceptInBulkEditorHandlerE4 extends OpenRelatedConceptHandlerE4{
@@ -18,9 +15,6 @@ public class OpenRelatedConceptInBulkEditorHandlerE4 extends OpenRelatedConceptH
     @Override
     protected void openConcept(TaxonBase<?> relatedTaxon, EModelService modelService, EPartService partService, MApplication application) {
         AbstractBulkEditorInput<?> input = AbstractBulkEditorInput.NewInstance(relatedTaxon);
-        MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR);
-        part = partService.showPart(part, PartState.ACTIVATE);
-        BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject();
-        bulkEditor.init(input);
+        BulkEditorUtil.openBulkEditor(input, modelService, partService, application);
     }
 }
index ca0892894ffc059a980c1f49f69e4445b0eb3548..fc1910858c65f2faf47fc3f5d649ef8e5068b88d 100644 (file)
@@ -8,7 +8,14 @@
 */
 package eu.etaxonomy.taxeditor.workbench;
 
+import java.util.List;
+
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
 
 import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
 import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
@@ -48,4 +55,21 @@ public class WorkbenchUtility {
         }
         return null;
     }
+
+    public static MPartStack getEditorAreaPartStack(MApplication application, EModelService modelService){
+        //FIXME E4 hack for opening in e3 editor area
+        if(application!=null){
+            //FIXME E4 hack for opening in e3 editor area
+            List<MArea> elements = modelService.findElements(application, "org.eclipse.ui.editorss", MArea.class, null);
+            for (MArea mArea : elements) {
+                List<MPartSashContainerElement> children = mArea.getChildren();
+                for (MPartSashContainerElement mPartSashContainerElement : children) {
+                    if(mPartSashContainerElement instanceof MPartStack){
+                        return (MPartStack) mPartSashContainerElement;
+                    }
+                }
+            }
+        }
+        return null;
+    }
 }