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
.CdmApplicationController
;
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
.api
.service
.exception
.DataChangeNoRollbackException
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
21 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
24 public class DeleteTaxonOperation
extends DeleteTaxonBaseOperation
{
25 //private Taxon taxon;
26 private final Classification classification
;
31 public DeleteTaxonOperation(String label
, IUndoContext undoContext
,
32 Taxon taxon
, Classification classification
, IWorkbenchPage activePage
, IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
) {
33 super(label
, undoContext
, taxon
, activePage
, postOperationEnabled
, conversationEnabled
);
36 Set
<TaxonNode
> nodes
= taxon
.getTaxonNodes();
37 if (nodes
.size() == 1 && classification
== null){
38 this.taxonNode
= nodes
.iterator().next();
39 } else if (classification
!= null){
40 Iterator
<TaxonNode
> iterator
= nodes
.iterator();
41 while (iterator
.hasNext()){
42 TaxonNode node
= iterator
.next();
43 if (node
.getClassification().equals(classification
)){
44 this.taxonNode
= node
;
50 this.classification
= classification
;
57 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
58 throws ExecutionException
{
64 CdmApplicationController controller
;
66 controller
= (CdmApplicationController
) CdmStore
.getCurrentApplicationConfiguration();
68 ITaxonService service
= controller
.getTaxonService();
71 service
.deleteTaxon(element
, new TaxonDeletionConfigurator(), classification
);
73 } catch (DataChangeNoRollbackException e
) {
74 // TODO Auto-generated catch block
79 //closeObsoleteEditor(taxon);
83 return postExecute(null);
87 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
88 throws ExecutionException
{
89 // TODO Auto-generated method stub
94 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
95 throws ExecutionException
{
96 // TODO Auto-generated method stub