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
.application
.CdmApplicationController
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
23 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
24 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
25 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
26 import eu
.etaxonomy
.cdm
.api
.service
.exception
.DataChangeNoRollbackException
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
30 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
31 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
32 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
36 * <p>DeleteTreeNodeOperation class.</p>
39 * @created Jan 20, 2010
42 public class DeleteOperation
extends AbstractPersistentPostOperation
{
44 private Set
<ITaxonTreeNode
> treeNodes
;
48 * <p>Constructor for DeleteTreeNodeOperation.</p>
50 * @param label a {@link java.lang.String} object.
51 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
52 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
53 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
54 * @param treeNodes a {@link java.util.Set} object.
56 public DeleteOperation(String label
, IUndoContext undoContext
,
57 Set
<ITaxonTreeNode
> treeNodes
,
58 IPostOperationEnabled postOperationEnabled
,
59 IConversationEnabled conversationEnabled
) {
60 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
61 this.treeNodes
= treeNodes
;
66 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
70 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
71 throws ExecutionException
{
75 for (ITaxonTreeNode treeNode
: treeNodes
){
76 if(treeNode
instanceof TaxonNode
){
77 //((TaxonNode) treeNode).delete();
78 CdmApplicationController controller
;
79 taxon
= ((TaxonNode
) treeNode
).getTaxon();
80 controller
= (CdmApplicationController
) CdmStore
.getCurrentApplicationConfiguration();
82 ITaxonService service
= controller
.getTaxonService();
85 service
.deleteTaxon(taxon
, new TaxonDeletionConfigurator(), ((TaxonNode
) treeNode
).getClassification());
87 } catch (DataChangeNoRollbackException e
) {
88 // TODO Auto-generated catch block
93 }else if(treeNode
instanceof Classification
){
94 Classification taxonomicTree
= (Classification
) treeNode
;
95 if(taxonomicTree
.hasChildNodes()){
96 StoreUtil
.warningDialog("Tree is not empty", this, "It is not possible to delete a Taxonomic Tree that " +
97 "is not empty. Please delete included taxa first");
99 CdmStore
.getService(IClassificationService
.class).delete(taxonomicTree
);
104 return postExecute(null);
108 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
112 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
113 throws ExecutionException
{
118 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
122 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
123 throws ExecutionException
{