3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
.operation
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
17 import org
.eclipse
.core
.runtime
.IAdaptable
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import org
.eclipse
.core
.runtime
.IStatus
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
22 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.ITreeNode
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
26 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
27 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
32 * <p>DeleteTreeNodeOperation class.</p>
35 * @created Jan 20, 2010
38 public class DeleteOperation
extends AbstractPersistentPostOperation
{
40 private Set
<ITreeNode
> treeNodes
;
44 * <p>Constructor for DeleteTreeNodeOperation.</p>
46 * @param label a {@link java.lang.String} object.
47 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
48 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
49 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
50 * @param treeNodes a {@link java.util.Set} object.
52 public DeleteOperation(String label
, IUndoContext undoContext
,
53 Set
<ITreeNode
> treeNodes
,
54 IPostOperationEnabled postOperationEnabled
,
55 IConversationEnabled conversationEnabled
) {
56 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
57 this.treeNodes
= treeNodes
;
62 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
66 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
67 throws ExecutionException
{
71 for (ITreeNode treeNode
: treeNodes
){
72 if(treeNode
instanceof TaxonNode
){
73 ((TaxonNode
) treeNode
).delete();
74 }else if(treeNode
instanceof Classification
){
75 Classification taxonomicTree
= (Classification
) treeNode
;
76 if(taxonomicTree
.hasChildNodes()){
77 StoreUtil
.warningDialog("Tree is not empty", this, "It is not possible to delete a Taxonomic Tree that " +
78 "is not empty. Please delete included taxa first");
80 CdmStore
.getService(IClassificationService
.class).delete(taxonomicTree
);
85 return postExecute(null);
89 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
93 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
94 throws ExecutionException
{
99 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
103 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
104 throws ExecutionException
{