2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.editor
.definedterm
.handler
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.IHandler
;
15 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
16 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
17 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
19 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.DefinedTermEditor
;
20 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.operation
.CreateTermVocabularyOperation
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
23 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
24 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
31 public class CreateTermVocabularyHandler
extends AbstractHandler
implements
35 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
38 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
39 IPostOperationEnabled editor
= (IPostOperationEnabled
) HandlerUtil
40 .getActiveEditor(event
);
42 if (editor
instanceof DefinedTermEditor
){
43 DefinedTermEditor dfe
= (DefinedTermEditor
) editor
;
46 String label
= event
.getCommand().getName();
47 IUndoContext undoContext
= StoreUtil
.getUndoContext();
49 AbstractPostOperation operation
=
50 new CreateTermVocabularyOperation(label
,
52 dfe
.getDefinedTermEditorInput(),
53 (DefinedTermEditor
) editor
);
54 StoreUtil
.executeOperation(operation
);
56 } catch (NotDefinedException e
) {
57 MessagingUtils
.error(getClass(), e
);