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.supplementaldata;
|
12
|
|
13
|
import org.eclipse.jface.viewers.ISelection;
|
14
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
15
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
16
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
17
|
import org.eclipse.swt.SWT;
|
18
|
import org.eclipse.swt.widgets.Composite;
|
19
|
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
22
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
23
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
24
|
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
|
25
|
import eu.etaxonomy.taxeditor.model.IElementHasDetails;
|
26
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
27
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
28
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
29
|
import eu.etaxonomy.taxeditor.ui.element.RootElement;
|
30
|
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
|
31
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
|
32
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
|
33
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
|
34
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
|
35
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
|
36
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
|
37
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
|
38
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
|
39
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
|
40
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
|
41
|
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
|
42
|
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
|
43
|
import eu.etaxonomy.taxeditor.view.detail.DetailsViewer;
|
44
|
|
45
|
/**
|
46
|
* <p>SupplementalDataViewer class.</p>
|
47
|
*
|
48
|
* @author n.hoffmann
|
49
|
* @created Feb 12, 2010
|
50
|
* @version 1.0
|
51
|
*/
|
52
|
public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISelectionChangedListener {
|
53
|
|
54
|
private boolean showDebug;
|
55
|
|
56
|
|
57
|
/**
|
58
|
* <p>Constructor for SupplementalDataViewer.</p>
|
59
|
*
|
60
|
* @param parent a {@link org.eclipse.swt.widgets.Composite} object.
|
61
|
* @param viewPart a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} object.
|
62
|
*/
|
63
|
public SupplementalDataViewer(Composite parent, AbstractCdmViewPart viewPart) {
|
64
|
super(parent, viewPart);
|
65
|
}
|
66
|
|
67
|
|
68
|
/* (non-Javadoc)
|
69
|
* @see org.eclipse.jface.viewers.Viewer#getSelection()
|
70
|
*/
|
71
|
/** {@inheritDoc} */
|
72
|
@Override
|
73
|
public ISelection getSelection() {
|
74
|
return null;
|
75
|
}
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
|
79
|
*/
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
public void setSelection(ISelection selection, boolean reveal) {
|
83
|
|
84
|
}
|
85
|
|
86
|
/* (non-Javadoc)
|
87
|
* @see eu.etaxonomy.taxeditor.editor.view.AbstractDetailsViewer#showParts(eu.etaxonomy.cdm.model.common.AnnotatableEntity)
|
88
|
*/
|
89
|
/** {@inheritDoc} */
|
90
|
@Override
|
91
|
protected void showParts() {
|
92
|
|
93
|
showDebug = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_DEBUG_INFORMATION);
|
94
|
|
95
|
Object input;
|
96
|
|
97
|
if(getInput() instanceof IElementHasDetails){
|
98
|
input = ((IElementHasDetails) getInput()).getData();
|
99
|
}else{
|
100
|
input = getInput();
|
101
|
}
|
102
|
|
103
|
destroySections();
|
104
|
//1. Headline
|
105
|
createHeadlineSection(rootElement);
|
106
|
//2. Annotatable entitiy
|
107
|
if(input instanceof AnnotatableEntity){
|
108
|
createAnnotationSections(rootElement);
|
109
|
}
|
110
|
//3. Identifiable entity
|
111
|
if(input instanceof IdentifiableEntity){
|
112
|
createIdentifiableSections(rootElement);
|
113
|
}
|
114
|
//4. Identifiable media entity
|
115
|
if(input instanceof IdentifiableMediaEntity){
|
116
|
createIdentifiableMediaSections(rootElement);
|
117
|
}
|
118
|
//5. Versionable
|
119
|
if(input instanceof VersionableEntity){
|
120
|
createVersionSection(rootElement);
|
121
|
}
|
122
|
//6. CdmBase
|
123
|
if(showDebug){
|
124
|
createCdmBaseSection(rootElement);
|
125
|
}
|
126
|
|
127
|
layout();
|
128
|
}
|
129
|
|
130
|
|
131
|
|
132
|
private void createHeadlineSection(RootElement parent){
|
133
|
HeadlineSection headlineSection = formFactory.createHeadlineSection(parent);
|
134
|
addPart(headlineSection, false);
|
135
|
}
|
136
|
|
137
|
private void createAnnotationSections(RootElement parent) {
|
138
|
AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
139
|
|
140
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
141
|
|
142
|
MarkerSection markerSection = formFactory.createMarkerSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
143
|
|
144
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
145
|
|
146
|
addPart(annotationSection, false);
|
147
|
addPart(markerSection, false);
|
148
|
}
|
149
|
|
150
|
private void createIdentifiableSections(RootElement parent) {
|
151
|
CreditSection creditSection = formFactory.createCreditSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
152
|
|
153
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
154
|
|
155
|
ExtensionSection extensionSection = formFactory.createExtensionSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
156
|
|
157
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
158
|
|
159
|
RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
160
|
|
161
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
162
|
|
163
|
SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
164
|
|
165
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
166
|
|
167
|
IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
168
|
|
169
|
addPart(creditSection, false);
|
170
|
addPart(extensionSection, false);
|
171
|
addPart(rightsSection, false);
|
172
|
addPart(sourceSection, false);
|
173
|
addPart(identifierSection, false);
|
174
|
|
175
|
}
|
176
|
|
177
|
private void createIdentifiableMediaSections(RootElement parent) {
|
178
|
MediaSection mediaSection = formFactory.createMediaSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
179
|
|
180
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
181
|
|
182
|
addPart(mediaSection, false);
|
183
|
}
|
184
|
|
185
|
private void createVersionSection(RootElement parent){
|
186
|
VersionSection versionSection = formFactory.createVersionSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
|
187
|
addPart(versionSection, true);
|
188
|
}
|
189
|
|
190
|
/**
|
191
|
* @param rootElement
|
192
|
*/
|
193
|
private void createCdmBaseSection(RootElement parent) {
|
194
|
|
195
|
CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
|
196
|
addPart(cdmBaseSection, true);
|
197
|
}
|
198
|
|
199
|
/*
|
200
|
* (non-Javadoc)
|
201
|
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
|
202
|
*/
|
203
|
/** {@inheritDoc} */
|
204
|
@Override
|
205
|
public void selectionChanged(SelectionChangedEvent event) {
|
206
|
if(event.getSource() instanceof DetailsViewer){
|
207
|
if(event.getSelection() == CdmFormFactory.EMPTY_SELECTION){
|
208
|
setInput(null);
|
209
|
return;
|
210
|
}
|
211
|
|
212
|
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
|
213
|
setInput(selection.getFirstElement());
|
214
|
}
|
215
|
}
|
216
|
}
|