1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.view.detail;
|
12
|
|
13
|
import org.eclipse.jface.viewers.ISelection;
|
14
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
15
|
import org.eclipse.jface.viewers.Viewer;
|
16
|
import org.eclipse.swt.widgets.Composite;
|
17
|
import org.eclipse.ui.IEditorPart;
|
18
|
import org.eclipse.ui.IWorkbenchPart;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
21
|
import eu.etaxonomy.cdm.model.description.Feature;
|
22
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
23
|
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
|
24
|
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
|
25
|
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
|
26
|
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
|
27
|
|
28
|
/**
|
29
|
* <p>DetailsViewPart class.</p>
|
30
|
*
|
31
|
* @author n.hoffmann
|
32
|
* @created Jun 10, 2010
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartContentHasSupplementalData{
|
36
|
|
37
|
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.forms.det"{trunked}</code> */
|
38
|
public static String ID = "eu.etaxonomy.taxeditor.view.detail";
|
39
|
|
40
|
private DetailsViewer viewer;
|
41
|
|
42
|
/** {@inheritDoc} */
|
43
|
@Override
|
44
|
public void createViewer(Composite parent) {
|
45
|
//selectionService.addPostSelectionListener(this);
|
46
|
|
47
|
viewer = new DetailsViewer(parent, this);
|
48
|
getSite().setSelectionProvider(viewer);
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
protected void internal_selectionChanged(IWorkbenchPart part, ISelection selection){
|
53
|
if(AbstractUtility.getActiveEditor() == null){
|
54
|
showEmptyPage();
|
55
|
return;
|
56
|
}
|
57
|
|
58
|
if(part == this){
|
59
|
return;
|
60
|
}
|
61
|
|
62
|
if(!(selection instanceof IStructuredSelection)){
|
63
|
return;
|
64
|
}
|
65
|
|
66
|
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
|
67
|
|
68
|
if((part instanceof IEditorPart) || (part instanceof IPartContentHasDetails)) {
|
69
|
if(structuredSelection.size() != 1){
|
70
|
showEmptyPage();
|
71
|
return;
|
72
|
}
|
73
|
|
74
|
// do not show details for feature nodes TODO really?
|
75
|
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
|
76
|
// do show the map for distributions
|
77
|
Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();
|
78
|
if(!feature.equals(Feature.DISTRIBUTION())){
|
79
|
showEmptyPage();
|
80
|
return;
|
81
|
}
|
82
|
}
|
83
|
|
84
|
showViewer(part, structuredSelection);
|
85
|
}else{
|
86
|
showEmptyPage();
|
87
|
}
|
88
|
}
|
89
|
|
90
|
/* (non-Javadoc)
|
91
|
* @see eu.etaxonomy.taxeditor.view.AbstractCdmViewPart#showEmptyPage()
|
92
|
*/
|
93
|
@Override
|
94
|
public void showEmptyPage() {
|
95
|
viewer.setSelection(null);
|
96
|
super.showEmptyPage();
|
97
|
}
|
98
|
|
99
|
/** {@inheritDoc} */
|
100
|
@Override
|
101
|
public boolean postOperation(CdmBase objectAffectedByOperation) {
|
102
|
|
103
|
viewer.setInput(objectAffectedByOperation);
|
104
|
|
105
|
return super.postOperation(objectAffectedByOperation);
|
106
|
}
|
107
|
|
108
|
|
109
|
/** {@inheritDoc} */
|
110
|
@Override
|
111
|
public Viewer getViewer() {
|
112
|
return viewer;
|
113
|
}
|
114
|
|
115
|
|
116
|
/** {@inheritDoc} */
|
117
|
@Override
|
118
|
public void dispose() {
|
119
|
super.dispose();
|
120
|
selectionService.removePostSelectionListener(this);
|
121
|
}
|
122
|
|
123
|
/**
|
124
|
* <p>onComplete</p>
|
125
|
*
|
126
|
* @return a boolean.
|
127
|
*/
|
128
|
@Override
|
129
|
public boolean onComplete() {
|
130
|
return true;
|
131
|
}
|
132
|
}
|