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
.operations
;
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
.model
.taxon
.Classification
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.ITreeNode
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
29 * <p>DeleteTreeNodeOperation class.</p>
32 * @created Jan 20, 2010
35 public class DeleteTreeNodeOperation
extends AbstractPersistentPostOperation
{
37 private Set
<ITreeNode
> treeNodes
;
41 * <p>Constructor for DeleteTreeNodeOperation.</p>
43 * @param label a {@link java.lang.String} object.
44 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
45 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
46 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
47 * @param treeNodes a {@link java.util.Set} object.
49 public DeleteTreeNodeOperation(String label
, IUndoContext undoContext
,
50 Set
<ITreeNode
> treeNodes
,
51 IPostOperationEnabled postOperationEnabled
,
52 IConversationEnabled conversationEnabled
) {
53 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
54 this.treeNodes
= treeNodes
;
59 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
63 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
64 throws ExecutionException
{
68 for (ITreeNode treeNode
: treeNodes
){
69 if(treeNode
instanceof TaxonNode
){
70 ((TaxonNode
) treeNode
).delete();
71 }else if(treeNode
instanceof Classification
){
72 Classification taxonomicTree
= (Classification
) treeNode
;
73 if(taxonomicTree
.hasChildNodes()){
74 StoreUtil
.warningDialog("Tree is not empty", this, "It is not possible to delete a Taxonomic Tree that " +
75 "is not empty. Please delete included taxa first");
77 CdmStore
.getClassificationService().delete(taxonomicTree
);
82 return postExecute(null);
86 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
90 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
92 // TODO Auto-generated method stub
97 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
101 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
102 throws ExecutionException
{
103 // TODO Auto-generated method stub