Project

General

Profile

Download (3.52 KB) Statistics
| Branch: | Tag: | Revision:
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.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;
21

    
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.AbstractPostOperation;
33
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
34
import eu.etaxonomy.taxeditor.store.CdmStore;
35

    
36
public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
37
	//private Taxon taxon;
38
	private Classification classification;
39
	
40
	
41
	
42
	
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);
46
		this.taxon = taxon;
47
		
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;
57
				}
58
			}
59
		} else{
60
			//TODO
61
		}
62
		this.classification = classification;
63
		
64
	}
65

    
66
	
67

    
68
	@Override
69
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
70
			throws ExecutionException {
71
				
72
				monitor.worked(20);
73
				bind();
74
				
75
				
76
				CdmApplicationController controller;
77
				
78
				controller = (CdmApplicationController) CdmStore.getCurrentApplicationConfiguration();
79
				
80
				ITaxonService service = controller.getTaxonService();
81
				try {
82
					
83
					service.deleteTaxon(taxon, new TaxonDeletionConfigurator(), classification);
84
					
85
				} catch (DataChangeNoRollbackException e) {
86
					// TODO Auto-generated catch block
87
					e.printStackTrace();
88
					
89
				}
90
				
91
				//closeObsoleteEditor(taxon);
92
				monitor.worked(40);
93
				
94
				
95
				return postExecute(null);
96
	}
97

    
98
	@Override
99
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
100
			throws ExecutionException {
101
		// TODO Auto-generated method stub
102
		return null;
103
	}
104

    
105
	@Override
106
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
107
			throws ExecutionException {
108
		// TODO Auto-generated method stub
109
		return null;
110
	}
111
	
112
	
113
}
(17-17/19)