1
|
package eu.etaxonomy.taxeditor.view.userecords;
|
2
|
|
3
|
import org.eclipse.jface.viewers.ISelection;
|
4
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
5
|
import org.eclipse.jface.viewers.Viewer;
|
6
|
import org.eclipse.swt.widgets.Composite;
|
7
|
import org.eclipse.ui.IEditorPart;
|
8
|
import org.eclipse.ui.IWorkbenchPart;
|
9
|
|
10
|
import eu.etaxonomy.cdm.model.description.Feature;
|
11
|
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
|
12
|
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
|
13
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
14
|
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
|
15
|
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
|
16
|
|
17
|
/**
|
18
|
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners.
|
19
|
*
|
20
|
* @author a.theys
|
21
|
* @created mar 13, 2012
|
22
|
* @version 1.0
|
23
|
*/
|
24
|
public class UseRecordsViewPart extends AbstractCdmEditorViewPart implements IPartContentHasSupplementalData{
|
25
|
|
26
|
public static String ID = "eu.etaxonomy.taxeditor.view.userecords";
|
27
|
private UseRecordsViewer viewer;
|
28
|
|
29
|
@Override
|
30
|
public void createViewer(Composite parent) {
|
31
|
viewer = new UseRecordsViewer(parent, this);
|
32
|
getSite().setSelectionProvider(viewer);
|
33
|
|
34
|
}
|
35
|
|
36
|
@Override
|
37
|
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
|
38
|
if(StoreUtil.getActiveEditor() == null){
|
39
|
showEmptyPage();
|
40
|
return;
|
41
|
}
|
42
|
|
43
|
if(part == this){
|
44
|
return;
|
45
|
}
|
46
|
|
47
|
if(!(selection instanceof IStructuredSelection)){
|
48
|
return;
|
49
|
}
|
50
|
|
51
|
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
|
52
|
|
53
|
if((part instanceof IEditorPart) || (part instanceof AbstractCdmViewPart)) {
|
54
|
if(structuredSelection.size() != 1){
|
55
|
showEmptyPage();
|
56
|
return;
|
57
|
}
|
58
|
|
59
|
// do not show details for feature nodes TODO really?
|
60
|
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
|
61
|
// do show the map for distributions
|
62
|
Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();
|
63
|
if(!feature.equals(Feature.DISTRIBUTION())){
|
64
|
showEmptyPage();
|
65
|
return;
|
66
|
}
|
67
|
}
|
68
|
|
69
|
showViewer(part, structuredSelection);
|
70
|
}else{
|
71
|
showEmptyPage();
|
72
|
}
|
73
|
|
74
|
}
|
75
|
|
76
|
@Override
|
77
|
public Viewer getViewer() {
|
78
|
return viewer;
|
79
|
}
|
80
|
|
81
|
/** {@inheritDoc} */
|
82
|
@Override
|
83
|
public void dispose() {
|
84
|
super.dispose();
|
85
|
selectionService.removePostSelectionListener(this);
|
86
|
}
|
87
|
|
88
|
/**
|
89
|
* <p>onComplete</p>
|
90
|
*
|
91
|
* @return a boolean.
|
92
|
*/
|
93
|
public boolean onComplete() {
|
94
|
return true;
|
95
|
}
|
96
|
|
97
|
|
98
|
|
99
|
|
100
|
|
101
|
|
102
|
}
|