4 package eu
.etaxonomy
.taxeditor
.editor
.view
.media
.handler
;
6 import org
.eclipse
.core
.commands
.AbstractHandler
;
7 import org
.eclipse
.core
.commands
.ExecutionEvent
;
8 import org
.eclipse
.core
.commands
.ExecutionException
;
9 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
10 import org
.eclipse
.jface
.viewers
.ISelection
;
11 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
12 import org
.eclipse
.ui
.IEditorInput
;
13 import org
.eclipse
.ui
.IEditorPart
;
14 import org
.eclipse
.ui
.IWorkbenchPart
;
15 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
17 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
18 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeNotSupportedException
;
19 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
20 import eu
.etaxonomy
.cdm
.model
.description
.SpecimenDescription
;
21 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
22 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
24 import eu
.etaxonomy
.taxeditor
.bulkeditor
.BulkEditor
;
25 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.OccurrenceEditorInput
;
26 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
27 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
28 import eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.operation
.CreateTaxonDescriptionOperation
;
29 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
30 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
33 * <p>AddImageGalleryHandler class.</p>
38 public class AddImageGalleryHandler
extends AbstractHandler
{
41 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
44 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
46 IWorkbenchPart part
= HandlerUtil
.getActivePart(event
);
47 IPostOperationEnabled postOperationEnabled
= (part
instanceof IPostOperationEnabled
) ?
(IPostOperationEnabled
) part
: null;
50 IEditorPart editor
= HandlerUtil
.getActiveEditor(event
);
51 IEditorInput input
= editor
.getEditorInput();
52 if (input
instanceof TaxonEditorInput
) {
53 Taxon taxon
= ((TaxonEditorInput
) input
).getTaxon();
54 AbstractPostOperation operation
;
56 // TODO use undo context specific to editor
57 operation
= new CreateTaxonDescriptionOperation(event
.getCommand().getName(),
58 EditorUtil
.getUndoContext(), taxon
, postOperationEnabled
, true);
59 EditorUtil
.executeOperation(operation
);
60 } catch (NotDefinedException e
) {
61 EditorUtil
.warn(getClass(), "Command name not set.");