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
.model
.MessagingUtils
;
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
{
37 IWorkbenchPart part
= HandlerUtil
.getActivePart(event
);
38 IPostOperationEnabled postOperationEnabled
= (part
instanceof IPostOperationEnabled
) ?
(IPostOperationEnabled
) part
: null;
41 IEditorPart editor
= HandlerUtil
.getActiveEditor(event
);
42 IEditorInput input
= editor
.getEditorInput();
43 if (input
instanceof TaxonEditorInput
) {
44 Taxon taxon
= ((TaxonEditorInput
) input
).getTaxon();
45 AbstractPostOperation operation
;
47 // TODO use undo context specific to editor
48 operation
= new CreateTaxonDescriptionOperation(event
.getCommand().getName(),
49 EditorUtil
.getUndoContext(), taxon
, postOperationEnabled
, true);
50 EditorUtil
.executeOperation(operation
);
51 } catch (NotDefinedException e
) {
52 MessagingUtils
.warn(getClass(), "Command name not set.");