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
.handlers
.HandlerUtil
;
15 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
16 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
17 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
18 import eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.operation
.CreateTaxonDescriptionOperation
;
19 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
20 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
23 * <p>AddImageGalleryHandler class.</p>
28 public class AddImageGalleryHandler
extends AbstractHandler
{
31 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
34 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 IEditorInput input
= editor
.getEditorInput();
42 if (input
instanceof TaxonEditorInput
) {
43 Taxon taxon
= ((TaxonEditorInput
) input
).getTaxon();
44 AbstractPostOperation operation
;
46 // TODO use undo context specific to editor
47 operation
= new CreateTaxonDescriptionOperation(event
.getCommand().getName(),
48 EditorUtil
.getUndoContext(), taxon
, postOperationEnabled
, true);
49 EditorUtil
.executeOperation(operation
);
50 } catch (NotDefinedException e
) {
51 EditorUtil
.warn(getClass(), "Command name not set.");