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
.ui
.IEditorInput
;
11 import org
.eclipse
.ui
.IEditorPart
;
12 import org
.eclipse
.ui
.IWorkbenchPart
;
13 import org
.eclipse
.ui
.forms
.editor
.FormEditor
;
14 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
16 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
17 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
18 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
19 import eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.operation
.CreateTaxonDescriptionOperation
;
20 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
21 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
24 * <p>AddImageGalleryHandler class.</p>
29 public class AddImageGalleryHandler
extends AbstractHandler
{
32 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
35 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
36 IWorkbenchPart part
= HandlerUtil
.getActivePart(event
);
37 IPostOperationEnabled postOperationEnabled
= (part
instanceof IPostOperationEnabled
) ?
(IPostOperationEnabled
) part
: null;
40 IEditorPart editor
= HandlerUtil
.getActiveEditor(event
);
41 if (editor
instanceof FormEditor
) {
42 editor
= ((FormEditor
) editor
).getActiveEditor();
44 IEditorInput input
= editor
.getEditorInput();
45 if (input
instanceof TaxonEditorInput
) {
46 Taxon taxon
= ((TaxonEditorInput
) input
).getTaxon();
47 AbstractPostOperation operation
;
49 // TODO use undo context specific to editor
50 operation
= new CreateTaxonDescriptionOperation(event
.getCommand().getName(),
51 EditorUtil
.getUndoContext(), taxon
, postOperationEnabled
, true);
52 EditorUtil
.executeOperation(operation
);
53 } catch (NotDefinedException e
) {
54 EditorUtil
.warn(getClass(), "Command name not set.");