1 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
3 import java
.util
.Iterator
;
6 import org
.eclipse
.core
.commands
.ExecutionEvent
;
7 import org
.eclipse
.core
.commands
.ExecutionException
;
8 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
9 import org
.eclipse
.core
.runtime
.IAdaptable
;
10 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
11 import org
.eclipse
.core
.runtime
.IStatus
;
12 import org
.eclipse
.core
.runtime
.Status
;
13 import org
.eclipse
.ui
.IEditorInput
;
14 import org
.eclipse
.ui
.IEditorReference
;
15 import org
.eclipse
.ui
.IPerspectiveDescriptor
;
16 import org
.eclipse
.ui
.IViewPart
;
17 import org
.eclipse
.ui
.IViewReference
;
18 import org
.eclipse
.ui
.IWorkbenchPage
;
19 import org
.eclipse
.ui
.PartInitException
;
20 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
22 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
23 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
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
.Synonym
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
31 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
32 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
33 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
34 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
36 public class DeleteTaxonOperation
extends DeleteTaxonBaseOperation
{
37 //private Taxon taxon;
38 private Classification classification
;
43 public DeleteTaxonOperation(String label
, IUndoContext undoContext
,
44 Taxon taxon
, Classification classification
, IWorkbenchPage activePage
, IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
) {
45 super(label
, undoContext
, taxon
, activePage
, postOperationEnabled
, conversationEnabled
);
48 Set
<TaxonNode
> nodes
= taxon
.getTaxonNodes();
49 if (nodes
.size() == 1 && classification
== null){
50 this.taxonNode
= nodes
.iterator().next();
51 } else if (classification
!= null){
52 Iterator
<TaxonNode
> iterator
= nodes
.iterator();
53 while (iterator
.hasNext()){
54 TaxonNode node
= iterator
.next();
55 if (node
.getClassification().equals(classification
)){
56 this.taxonNode
= node
;
62 this.classification
= classification
;
69 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
70 throws ExecutionException
{
76 CdmApplicationController controller
;
78 controller
= (CdmApplicationController
) CdmStore
.getCurrentApplicationConfiguration();
80 ITaxonService service
= controller
.getTaxonService();
83 service
.deleteTaxon(taxon
, new TaxonDeletionConfigurator(), classification
);
85 } catch (DataChangeNoRollbackException e
) {
86 // TODO Auto-generated catch block
91 //closeObsoleteEditor(taxon);
95 return postExecute(null);
99 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
100 throws ExecutionException
{
101 // TODO Auto-generated method stub
106 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
107 throws ExecutionException
{
108 // TODO Auto-generated method stub