3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.editor
.definedterm
.handler
;
12 import org
.eclipse
.core
.commands
.AbstractHandler
;
13 import org
.eclipse
.core
.commands
.ExecutionEvent
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.IHandler
;
16 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
20 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
21 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.DefinedTermEditor
;
22 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.operation
.CreateDefinedTermOperation
;
23 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
24 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
25 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
32 public class CreateDefinedTermHandler
extends AbstractHandler
implements IHandler
{
38 * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
42 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
43 IPostOperationEnabled editor
= (IPostOperationEnabled
) HandlerUtil
44 .getActiveEditor(event
);
46 IStructuredSelection selection
= (IStructuredSelection
) HandlerUtil
47 .getCurrentSelection(event
);
49 TermBase selectedElement
= (TermBase
) selection
.getFirstElement();
52 AbstractPostOperation operation
= new CreateDefinedTermOperation(
53 event
.getCommand().getName(), StoreUtil
.getUndoContext(),
54 selectedElement
, editor
);
55 StoreUtil
.executeOperation(operation
);
57 } catch (NotDefinedException e
) {
58 StoreUtil
.error(getClass(), e
);