fix #6748 Fix creation of description for specimens
authorPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 7 Jul 2017 09:05:18 +0000 (11:05 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 10 Jul 2017 08:47:16 +0000 (10:47 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/CreateDescriptionHandler.java

index 50620713de865e8d5d44597b05f9d834bb94f3a4..1c0c638fc5941d508a26e36ad9660d42a7bbc2b6 100644 (file)
@@ -8,24 +8,17 @@
 */
 package eu.etaxonomy.taxeditor.editor.view.descriptive.handler;
 
-import java.util.Collection;
-
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.forms.editor.FormEditor;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateSpecimenDescriptionOperation;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
@@ -51,32 +44,8 @@ public class CreateDescriptionHandler extends AbstractHandler {
     public Object execute(ExecutionEvent event) throws ExecutionException {
                IWorkbenchPart part = HandlerUtil.getActivePart(event);
                IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
-
-               IEditorPart editor = HandlerUtil.getActiveEditor(event);
-               
-               if (editor instanceof FormEditor) {
-                       editor = ((FormEditor) editor).getActiveEditor();
-               }
-               Object input;
-               if (editor == null && part instanceof DescriptiveViewPart){
-                       input =  ((DescriptiveViewPart)part).getViewer().getInput();
-               }else{
-                       input = editor.getEditorInput();
-               }
                AbstractPostOperation<?> operation;
-
-               // taxon description
-               if (input instanceof TaxonEditorInput) {
-                       Taxon taxon = ((TaxonEditorInput) input).getTaxon();
-                       try {
-                           operation = createTaxonOperation(event.getCommand().getName(), taxon, postOperationEnabled);
-                               AbstractUtility.executeOperation(operation);
-                       } catch (NotDefinedException e) {
-                               MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
-                       }
-               }
-               // specimen description
-               else if(part instanceof DescriptiveViewPart){
+               if(part instanceof DescriptiveViewPart){
                    Object viewerInput = ((DescriptiveViewPart)part).getViewer().getInput();
                    if(viewerInput instanceof SpecimenOrObservationBase<?>){
                        try {
@@ -93,7 +62,7 @@ public class CreateDescriptionHandler extends AbstractHandler {
                         } catch (NotDefinedException e) {
                                    MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
                             }
-                       
+
                    }
                }
                return null;