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
.jface
.dialogs
.MessageDialog
;
12 import org
.eclipse
.ui
.IWorkbenchPage
;
14 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
15 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
16 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
17 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
18 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
22 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
23 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
24 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 public class DeleteTaxonOperation
extends DeleteTaxonBaseOperation
{
29 private final Classification classification
;
31 public DeleteTaxonOperation(String label
,
32 IUndoContext undoContext
,
34 TaxonDeletionConfigurator configurator
,
35 Classification classification
,
36 IWorkbenchPage activePage
,
37 IPostOperationEnabled postOperationEnabled
,
38 IConversationEnabled conversationEnabled
,
39 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
40 super(label
, undoContext
, configurator
, activePage
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
43 Set
<TaxonNode
> nodes
= taxon
.getTaxonNodes();
44 if (nodes
.size() == 1 && classification
== null){
45 this.taxonNode
= nodes
.iterator().next();
46 } else if (classification
!= null){
47 Iterator
<TaxonNode
> iterator
= nodes
.iterator();
48 while (iterator
.hasNext()){
49 TaxonNode node
= iterator
.next();
50 if (node
.getClassification().equals(classification
)){
51 this.taxonNode
= node
;
57 this.classification
= classification
;
62 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
63 throws ExecutionException
{
69 ICdmApplicationConfiguration controller
;
71 controller
= CdmStore
.getCurrentApplicationConfiguration();
73 ITaxonService service
= controller
.getTaxonService();
75 DeleteResult result
= service
.deleteTaxon(element
.getUuid(), configurator
, classification
.getUuid());
77 if (result
.isError()){
78 MessageDialog
.openError(null, "Delete failed", result
.toString());
79 } else if (!result
.getUpdatedObjects().isEmpty()){
80 MessagingUtils
.informationDialog("Delete successfull", result
.toString());
86 return postExecute(null);
90 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
92 // TODO Auto-generated method stub
97 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
98 throws ExecutionException
{
99 // TODO Auto-generated method stub