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 java
.util
.Iterator
;
14 import org
.eclipse
.core
.commands
.AbstractHandler
;
15 import org
.eclipse
.core
.commands
.ExecutionEvent
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
18 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
19 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
20 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
22 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
23 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.DefinedTermEditor
;
24 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.operation
.DeleteTermBaseOperation
;
25 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
26 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
33 public class DeleteTermBaseHandler
extends AbstractHandler
{
36 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
39 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
40 DefinedTermEditor editor
= (DefinedTermEditor
) HandlerUtil
41 .getActiveEditor(event
);
43 if (editor
instanceof DefinedTermEditor
){
44 DefinedTermEditor dfe
= (DefinedTermEditor
) editor
;
46 String label
= event
.getCommand().getName();
47 IUndoContext undoContext
= StoreUtil
.getUndoContext();
49 IStructuredSelection selection
= (IStructuredSelection
) HandlerUtil
50 .getCurrentSelection(event
);
52 Iterator
<TermBase
> selectionIterator
= selection
.iterator();
54 while (selectionIterator
.hasNext()){
56 TermBase term
= selectionIterator
.next();
59 AbstractPostOperation operation
=
60 new DeleteTermBaseOperation(label
,
63 dfe
.getDefinedTermEditorInput(),
65 StoreUtil
.executeOperation(operation
);
68 } catch (NotDefinedException e
) {
69 StoreUtil
.error(getClass(), e
);