Project

General

Profile

« Previous | Next » 

Revision 5daadc6e

Added by Patrick Plitzner over 6 years ago

fix #6748 Fix creation of description for specimens

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/CreateDescriptionHandler.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.editor.view.descriptive.handler;
10 10

  
11
import java.util.Collection;
12

  
13 11
import org.eclipse.core.commands.AbstractHandler;
14 12
import org.eclipse.core.commands.ExecutionEvent;
15 13
import org.eclipse.core.commands.ExecutionException;
16 14
import org.eclipse.core.commands.common.NotDefinedException;
17
import org.eclipse.core.expressions.EvaluationContext;
18
import org.eclipse.ui.IEditorInput;
19
import org.eclipse.ui.IEditorPart;
20 15
import org.eclipse.ui.IWorkbenchPart;
21
import org.eclipse.ui.forms.editor.FormEditor;
22 16
import org.eclipse.ui.handlers.HandlerUtil;
23 17

  
24 18
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
25 19
import eu.etaxonomy.cdm.model.taxon.Taxon;
26 20
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
27 21
import eu.etaxonomy.taxeditor.editor.EditorUtil;
28
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
29 22
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
30 23
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateSpecimenDescriptionOperation;
31 24
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
......
51 44
    public Object execute(ExecutionEvent event) throws ExecutionException {
52 45
		IWorkbenchPart part = HandlerUtil.getActivePart(event);
53 46
		IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
54

  
55
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
56
		
57
		if (editor instanceof FormEditor) {
58
			editor = ((FormEditor) editor).getActiveEditor();
59
		}
60
		Object input;
61
		if (editor == null && part instanceof DescriptiveViewPart){
62
			input =  ((DescriptiveViewPart)part).getViewer().getInput();
63
		}else{
64
			input = editor.getEditorInput();
65
		}
66 47
		AbstractPostOperation<?> operation;
67

  
68
		// taxon description
69
		if (input instanceof TaxonEditorInput) {
70
			Taxon taxon = ((TaxonEditorInput) input).getTaxon();
71
			try {
72
			    operation = createTaxonOperation(event.getCommand().getName(), taxon, postOperationEnabled);
73
				AbstractUtility.executeOperation(operation);
74
			} catch (NotDefinedException e) {
75
				MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
76
			}
77
		}
78
		// specimen description
79
		else if(part instanceof DescriptiveViewPart){
48
		if(part instanceof DescriptiveViewPart){
80 49
		    Object viewerInput = ((DescriptiveViewPart)part).getViewer().getInput();
81 50
		    if(viewerInput instanceof SpecimenOrObservationBase<?>){
82 51
		        try {
......
93 62
		    	 } catch (NotDefinedException e) {
94 63
			            MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
95 64
			     }
96
		        
65

  
97 66
		    }
98 67
		}
99 68
		return null;

Also available in: Unified diff