1
|
package eu.etaxonomy.taxeditor.editor.name.operation;
|
2
|
|
3
|
import org.eclipse.core.commands.ExecutionException;
|
4
|
import org.eclipse.core.commands.operations.IUndoContext;
|
5
|
import org.eclipse.core.runtime.IAdaptable;
|
6
|
import org.eclipse.core.runtime.IProgressMonitor;
|
7
|
import org.eclipse.core.runtime.IStatus;
|
8
|
import org.eclipse.ui.IEditorInput;
|
9
|
import org.eclipse.ui.IEditorReference;
|
10
|
import org.eclipse.ui.IPerspectiveDescriptor;
|
11
|
import org.eclipse.ui.IViewPart;
|
12
|
import org.eclipse.ui.IWorkbenchPage;
|
13
|
import org.eclipse.ui.PartInitException;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
16
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
17
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
18
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
19
|
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
|
20
|
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
|
21
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
22
|
|
23
|
public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation {
|
24
|
|
25
|
private IWorkbenchPage activePage;
|
26
|
|
27
|
public DeleteTaxonBaseOperation(String label, IUndoContext undoContext,
|
28
|
Taxon taxon, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
|
29
|
super(label, undoContext, postOperationEnabled,
|
30
|
conversationEnabled);
|
31
|
this.activePage = activePage;
|
32
|
|
33
|
}
|
34
|
|
35
|
@Override
|
36
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
37
|
throws ExecutionException {
|
38
|
// TODO Auto-generated method stub
|
39
|
return null;
|
40
|
}
|
41
|
|
42
|
@Override
|
43
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
44
|
throws ExecutionException {
|
45
|
// TODO Auto-generated method stub
|
46
|
return null;
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
51
|
throws ExecutionException {
|
52
|
// TODO Auto-generated method stub
|
53
|
return null;
|
54
|
}
|
55
|
|
56
|
protected void closeObsoleteEditor(Taxon taxon){
|
57
|
for (IEditorReference ref : activePage.getEditorReferences()) {
|
58
|
|
59
|
IViewPart view = activePage.findView("eu.etaxonomy.taxeditor.navigation.navigator");
|
60
|
|
61
|
try {
|
62
|
IEditorInput input = ref.getEditorInput();
|
63
|
if (input instanceof TaxonEditorInput) {
|
64
|
TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
|
65
|
if (taxonNode.equals(node)) {
|
66
|
activePage.closeEditor(ref.getEditor(false), false);
|
67
|
}
|
68
|
}
|
69
|
} catch (PartInitException e) {
|
70
|
continue;
|
71
|
}
|
72
|
}
|
73
|
}
|
74
|
}
|
75
|
|
76
|
|