1 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
3 import java
.util
.Iterator
;
6 import org
.eclipse
.core
.commands
.ExecutionException
;
7 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
8 import org
.eclipse
.core
.runtime
.IAdaptable
;
9 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
10 import org
.eclipse
.core
.runtime
.IStatus
;
11 import org
.eclipse
.ui
.IWorkbenchPage
;
13 import eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
14 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
15 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
16 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
17 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
20 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
21 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
24 public class DeleteTaxonOperation
extends DeleteTaxonBaseOperation
{
26 private final Classification classification
;
28 public DeleteTaxonOperation(String label
,
29 IUndoContext undoContext
,
31 TaxonDeletionConfigurator configurator
,
32 Classification classification
,
33 IWorkbenchPage activePage
,
34 IPostOperationEnabled postOperationEnabled
,
35 IConversationEnabled conversationEnabled
,
36 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
37 super(label
, undoContext
, configurator
, activePage
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
40 Set
<TaxonNode
> nodes
= taxon
.getTaxonNodes();
41 if (nodes
.size() == 1 && classification
== null){
42 this.taxonNode
= nodes
.iterator().next();
43 } else if (classification
!= null){
44 Iterator
<TaxonNode
> iterator
= nodes
.iterator();
45 while (iterator
.hasNext()){
46 TaxonNode node
= iterator
.next();
47 if (node
.getClassification().equals(classification
)){
48 this.taxonNode
= node
;
54 this.classification
= classification
;
59 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
60 throws ExecutionException
{
66 ICdmRepository controller
;
68 controller
= CdmStore
.getCurrentApplicationConfiguration();
70 ITaxonService service
= controller
.getTaxonService();
72 result
= service
.deleteTaxon(element
.getUuid(), (TaxonDeletionConfigurator
)configurator
, classification
.getUuid());
79 return postExecute(null);
83 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
84 throws ExecutionException
{
85 // TODO Auto-generated method stub
90 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
92 // TODO Auto-generated method stub