commit c050c60b3181d6f4aba95e0bc21c76adfa12724b
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Tue May 23 18:03:23 2017 +0200

    ref #6566 Fix open handler for specimen editor

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
index b61dc0eda..a368fc48d 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
@@ -44,14 +44,6 @@ import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
 import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput;
-//import eu.etaxonomy.taxeditor.store.view.dataimport.BioCaseEditorInput;
-//import eu.etaxonomy.taxeditor.view.dataimport.DataImportEditor;
-//import eu.etaxonomy.taxeditor.view.dataimport.DataImportEditorInput;
-//import eu.etaxonomy.taxeditor.view.dataimport.GbifImportEditor;
-//import eu.etaxonomy.taxeditor.view.dataimport.GbifImportEditorInput;
-//import eu.etaxonomy.taxeditor.view.dataimport.SpecimenImportEditor;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -111,17 +103,6 @@ public class EditorUtil extends AbstractUtility {
 		open(input, CdmAuthorityEditor.ID);
 	}
 
-	/**
-	 * Opens a new DerivateView for the given input
-	 * @param input a {@link DerivateViewEditorInput} representing the selected derivate
-	 * @throws PartInitException
-	 */
-	public static void open(DerivateViewEditorInput input)
-	        throws PartInitException {
-	    open(input, DerivateView.ID);
-	}
-
-
 	/**
 	 * Opens a new ChecklistView for the given input
 	 * @param input a {@link ChecklistEditorInput} representing the selected checklist
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java
index 04101f6cd..646f4160b 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java
@@ -3,22 +3,23 @@ package eu.etaxonomy.taxeditor.editor.handler;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.PartInitException;
+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 eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.editor.AppModelId;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 public class OpenDerivateViewHandler extends AbstractHandler {
 
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
-        try {
-            EditorUtil.open(new DerivateViewEditorInput());
-        } catch (PartInitException e) {
-            MessagingUtils.error(OpenDerivateViewHandler.class, Messages.OpenDerivateViewHandler_COULD_NOT_OPEN, e);
-        }
+        MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
+                AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
+        DerivateView derivateView = (DerivateView) part.getObject();
+        derivateView.init(new DerivateViewEditorInput());
         return null;
     }
 
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenSpecimenEditorForTypeSpecimenHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenSpecimenEditorForTypeSpecimenHandler.java
index 9c186819c..1c9fa15c9 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenSpecimenEditorForTypeSpecimenHandler.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenSpecimenEditorForTypeSpecimenHandler.java
@@ -2,15 +2,17 @@ package eu.etaxonomy.taxeditor.editor.handler.defaultHandler;
 import java.util.UUID;
 
 import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.ui.PartInitException;
+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 eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.editor.AppModelId;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
 import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 
 public class DefaultOpenSpecimenEditorForTypeSpecimenHandler extends
@@ -23,11 +25,11 @@ public class DefaultOpenSpecimenEditorForTypeSpecimenHandler extends
 
 	@Override
 	protected void open(ExecutionEvent event, SpecimenTypeDesignation entity) {
-        try {
-            EditorUtil.open(new DerivateViewEditorInput(entity.getUuid()));
-        } catch (PartInitException e) {
-            MessagingUtils.error(DefaultOpenSpecimenEditorForTypeSpecimenHandler.class, Messages.DefaultOpenSpecimenEditorForTypeSpecimenHandler_COULD_NOT_OPEN, e);
-        }		
+	    DerivateViewEditorInput input = new DerivateViewEditorInput(entity.getUuid());
+	    MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
+	            AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
+	    DerivateView derivateView = (DerivateView) part.getObject();
+	    derivateView.init(input);
 	}
 
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForDescriptionElement.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForDescriptionElement.java
index c779955fd..8440fada5 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForDescriptionElement.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForDescriptionElement.java
@@ -3,6 +3,11 @@ package eu.etaxonomy.taxeditor.editor.view.derivate.handler;
 import java.util.Collections;
 import java.util.UUID;
 
+import org.eclipse.core.commands.ExecutionEvent;
+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 eu.etaxonomy.cdm.api.service.IDescriptionService;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
@@ -11,11 +16,12 @@ import eu.etaxonomy.taxeditor.editor.AppModelId;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
-import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBaseE4;
+import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
-public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandlerBaseE4<IndividualsAssociation, DerivateView> {
+public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandlerBase<IndividualsAssociation> {
 
     @Override
     protected IndividualsAssociation getEntity(UUID uuid) {
@@ -27,21 +33,21 @@ public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandle
     }
 
     @Override
-    protected void initPart(IndividualsAssociation entity, DerivateView part) {
-        if(entity==null || entity.getAssociatedSpecimenOrObservation()==null){
-            MessagingUtils.messageDialog(Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS, this, Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS_MESSAGE);
-            return;
-        }
+    protected void open(ExecutionEvent event, IndividualsAssociation entity) {
+    	if(entity==null || entity.getAssociatedSpecimenOrObservation()==null){
+    		MessagingUtils.messageDialog(Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS, this, Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS_MESSAGE);
+    		return;
+    	}
         SpecimenOrObservationBase associatedSpecimenOrObservation = entity.getAssociatedSpecimenOrObservation();
         if(associatedSpecimenOrObservation!=null){
             UUID specimenUuid = associatedSpecimenOrObservation.getUuid();
-            part.init(new DerivateViewEditorInput(Collections.singletonList(specimenUuid)));
+            DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singletonList(specimenUuid));
+            MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
+                    AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
+            DerivateView derivateView = (DerivateView) part.getObject();
+            derivateView.init(input);
         }
-    }
 
-    @Override
-    protected String getPartId() {
-        return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
     }
 
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForSpecimenOrOBservationBase.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForSpecimenOrOBservationBase.java
index c241e290b..bbab719ba 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForSpecimenOrOBservationBase.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForSpecimenOrOBservationBase.java
@@ -2,16 +2,22 @@ package eu.etaxonomy.taxeditor.editor.view.derivate.handler;
 
 import java.util.UUID;
 
+import org.eclipse.core.commands.ExecutionEvent;
+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 eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.editor.AppModelId;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
-import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBaseE4;
+import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
-public class OpenDerivativeEditorForSpecimenOrOBservationBase extends DefaultOpenHandlerBaseE4<SpecimenOrObservationBase<?>, DerivateView>{
+public class OpenDerivativeEditorForSpecimenOrOBservationBase extends DefaultOpenHandlerBase<SpecimenOrObservationBase<?>>{
 
     protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN = Messages.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN;
 
@@ -24,15 +30,12 @@ public class OpenDerivativeEditorForSpecimenOrOBservationBase extends DefaultOpe
     }
 
     @Override
-    protected void initPart(SpecimenOrObservationBase<?> entity, DerivateView part) {
-        part.init(new DerivateViewEditorInput(entity.getUuid()));
-    }
-
-    @Override
-    protected String getPartId() {
-        return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
+    protected void open(ExecutionEvent event, SpecimenOrObservationBase<?> entity) {
+        DerivateViewEditorInput input = new DerivateViewEditorInput(entity.getUuid());
+        MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
+                AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
+        DerivateView derivateView = (DerivateView) part.getObject();
+        derivateView.init(input);
     }
 
-
-
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForTaxonNode.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForTaxonNode.java
index b4b1b2374..329ca8d43 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForTaxonNode.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForTaxonNode.java
@@ -5,6 +5,11 @@ import java.util.Collection;
 import java.util.List;
 import java.util.UUID;
 
+import org.eclipse.core.commands.ExecutionEvent;
+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 eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator;
@@ -14,10 +19,11 @@ import eu.etaxonomy.taxeditor.editor.AppModelId;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
-import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBaseE4;
+import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
-public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBaseE4<TaxonNode, DerivateView> {
+public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBase<TaxonNode> {
 
     protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN = Messages.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN;
 
@@ -27,7 +33,7 @@ public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBaseE4<T
     }
 
     @Override
-    protected void initPart(TaxonNode entity, DerivateView part) {
+    protected void open(ExecutionEvent event, TaxonNode entity) {
         FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
         UUID taxonUuid = entity.getTaxon().getUuid();
         config.setAssociatedTaxonUuid(taxonUuid);
@@ -36,12 +42,11 @@ public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBaseE4<T
         for (SpecimenOrObservationBase specimenOrObservationBase : specimens) {
             specimenUuids.add(specimenOrObservationBase.getUuid());
         }
-        part.init(new DerivateViewEditorInput(specimenUuids, taxonUuid));
-    }
-
-    @Override
-    protected String getPartId() {
-        return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
+        DerivateViewEditorInput input = new DerivateViewEditorInput(specimenUuids, taxonUuid);
+        MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
+                AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
+        DerivateView derivateView = (DerivateView) part.getObject();
+        derivateView.init(input);
     }
 
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java
index 04fe5cf4a..2162f0c49 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java
@@ -66,7 +66,7 @@ public class CdmViewerUtil {
                         String viewerName = configElement.getAttribute("viewerName"); //$NON-NLS-1$
                         Class<?> selectionClass = Class.forName(configElement.getAttribute("selection")); //$NON-NLS-1$
                         if(selectionClass.isAssignableFrom(input.getClass())){
-                            ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
+                            ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
                             Command command = commandService.getCommand(commandId);
                             if(command.isEnabled()){
                                 commandViewerNameMap.put(command, viewerName);
