1
|
package eu.etaxonomy.taxeditor.editor.name.operation;
|
2
|
|
3
|
import java.util.Iterator;
|
4
|
import java.util.Set;
|
5
|
|
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;
|
12
|
|
13
|
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
|
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;
|
23
|
|
24
|
public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
|
25
|
//private Taxon taxon;
|
26
|
private final Classification classification;
|
27
|
|
28
|
|
29
|
|
30
|
|
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);
|
34
|
this.element = taxon;
|
35
|
|
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;
|
45
|
}
|
46
|
}
|
47
|
} else{
|
48
|
//TODO
|
49
|
}
|
50
|
this.classification = classification;
|
51
|
|
52
|
}
|
53
|
|
54
|
|
55
|
|
56
|
@Override
|
57
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
58
|
throws ExecutionException {
|
59
|
|
60
|
monitor.worked(20);
|
61
|
bind();
|
62
|
|
63
|
|
64
|
ICdmApplicationConfiguration controller;
|
65
|
|
66
|
controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
|
67
|
|
68
|
ITaxonService service = controller.getTaxonService();
|
69
|
|
70
|
|
71
|
String result = service.deleteTaxon(element, new TaxonDeletionConfigurator(), classification);
|
72
|
|
73
|
|
74
|
//closeObsoleteEditor(taxon);
|
75
|
monitor.worked(40);
|
76
|
|
77
|
|
78
|
return postExecute(null);
|
79
|
}
|
80
|
|
81
|
@Override
|
82
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
83
|
throws ExecutionException {
|
84
|
// TODO Auto-generated method stub
|
85
|
return null;
|
86
|
}
|
87
|
|
88
|
@Override
|
89
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
90
|
throws ExecutionException {
|
91
|
// TODO Auto-generated method stub
|
92
|
return null;
|
93
|
}
|
94
|
|
95
|
|
96
|
}
|