*/
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;
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 {
} catch (NotDefinedException e) {
MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
}
-
+
}
}
return null;