Revision b0ce5b17
Added by Patrick Plitzner over 10 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
16 | 16 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
17 | 17 |
import org.eclipse.swt.SWT; |
18 | 18 |
import org.eclipse.swt.widgets.Composite; |
19 |
import org.eclipse.ui.forms.widgets.Section;
|
|
19 |
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
|
20 | 20 |
|
21 | 21 |
import eu.etaxonomy.cdm.model.common.AnnotatableEntity; |
22 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
23 | 22 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
24 | 23 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
25 | 24 |
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity; |
26 | 25 |
import eu.etaxonomy.taxeditor.model.IElementHasDetails; |
26 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; |
|
27 | 27 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
28 | 28 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
29 | 29 |
import eu.etaxonomy.taxeditor.ui.element.RootElement; |
30 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType; |
|
31 | 30 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection; |
32 | 31 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection; |
33 | 32 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection; |
... | ... | |
53 | 52 |
|
54 | 53 |
private boolean showDebug; |
55 | 54 |
|
56 |
|
|
55 |
|
|
57 | 56 |
/** |
58 | 57 |
* <p>Constructor for SupplementalDataViewer.</p> |
59 | 58 |
* |
... | ... | |
89 | 88 |
/** {@inheritDoc} */ |
90 | 89 |
@Override |
91 | 90 |
protected void showParts() { |
92 |
|
|
93 |
showDebug = PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.SHOW_DEBUG_INFORMATION);
|
|
94 |
|
|
91 |
|
|
92 |
showDebug = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_DEBUG_INFORMATION);
|
|
93 |
|
|
95 | 94 |
Object input; |
96 |
|
|
95 |
|
|
97 | 96 |
if(getInput() instanceof IElementHasDetails){ |
98 | 97 |
input = ((IElementHasDetails) getInput()).getData(); |
99 | 98 |
}else{ |
100 | 99 |
input = getInput(); |
101 | 100 |
} |
102 |
|
|
101 |
|
|
103 | 102 |
destroySections(); |
104 | 103 |
//1. Headline |
105 | 104 |
createHeadlineSection(rootElement); |
106 | 105 |
//2. Annotatable entitiy |
107 |
if(input instanceof AnnotatableEntity){
|
|
106 |
if(input instanceof AnnotatableEntity){ |
|
108 | 107 |
createAnnotationSections(rootElement); |
109 | 108 |
} |
110 | 109 |
//3. Identifiable entity |
... | ... | |
113 | 112 |
} |
114 | 113 |
//4. Identifiable media entity |
115 | 114 |
if(input instanceof IdentifiableMediaEntity){ |
116 |
createIdentifiableMediaSections(rootElement);
|
|
115 |
createIdentifiableMediaSections(rootElement); |
|
117 | 116 |
} |
118 | 117 |
//5. Versionable |
119 | 118 |
if(input instanceof VersionableEntity){ |
120 | 119 |
createVersionSection(rootElement); |
121 |
}
|
|
120 |
} |
|
122 | 121 |
//6. CdmBase |
123 | 122 |
if(showDebug){ |
124 | 123 |
createCdmBaseSection(rootElement); |
125 | 124 |
} |
126 |
|
|
125 |
|
|
127 | 126 |
layout(); |
128 | 127 |
} |
129 | 128 |
|
... | ... | |
133 | 132 |
HeadlineSection headlineSection = formFactory.createHeadlineSection(parent); |
134 | 133 |
addPart(headlineSection); |
135 | 134 |
} |
136 |
|
|
137 |
private void createAnnotationSections(RootElement parent){ |
|
138 |
AnnotationSection annotationSection = (AnnotationSection) |
|
139 |
formFactory.createEntityDetailSection(EntityDetailType.ANNOTATION, getConversationHolder(), parent, Section.TWISTIE); |
|
140 |
|
|
141 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
|
142 |
|
|
143 |
MarkerSection markerSection = (MarkerSection) |
|
144 |
formFactory.createEntityDetailSection(EntityDetailType.MARKER, getConversationHolder(), parent, Section.TWISTIE); |
|
145 |
|
|
146 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
|
147 |
|
|
148 |
addPart(annotationSection); |
|
149 |
addPart(markerSection); |
|
150 |
} |
|
151 | 135 |
|
152 |
private void createIdentifiableSections(RootElement parent){
|
|
153 |
CreditSection creditSection = (CreditSection)
|
|
154 |
formFactory.createEntityDetailSection(EntityDetailType.CREDIT, getConversationHolder(), parent, Section.TWISTIE); |
|
155 |
|
|
156 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
|
157 |
|
|
158 |
ExtensionSection extensionSection = (ExtensionSection) |
|
159 |
formFactory.createEntityDetailSection(EntityDetailType.EXTENSION, getConversationHolder(), parent, Section.TWISTIE);
|
|
160 |
|
|
161 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
|
162 |
|
|
163 |
RightsSection rightsSection = (RightsSection)
|
|
164 |
formFactory.createEntityDetailSection(EntityDetailType.RIGHTS, getConversationHolder(), parent, Section.TWISTIE); |
|
165 |
|
|
166 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
|
167 |
|
|
168 |
SourceSection sourceSection = (SourceSection)
|
|
169 |
formFactory.createEntityDetailSection(EntityDetailType.SOURCE, getConversationHolder(), parent, Section.TWISTIE); |
|
170 |
|
|
171 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
|
172 |
|
|
173 |
addPart(creditSection); |
|
174 |
addPart(extensionSection);
|
|
175 |
addPart(rightsSection); |
|
176 |
addPart(sourceSection);
|
|
177 |
|
|
178 |
}
|
|
179 |
|
|
180 |
private void createIdentifiableMediaSections(RootElement parent){
|
|
181 |
MediaSection mediaSection = (MediaSection) |
|
182 |
formFactory.createEntityDetailSection(EntityDetailType.MEDIA, getConversationHolder(), parent, Section.TWISTIE);
|
|
183 |
|
|
184 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
|
185 |
|
|
186 |
addPart(mediaSection); |
|
136 |
private void createAnnotationSections(RootElement parent) {
|
|
137 |
AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
|
138 |
|
|
139 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
|
140 |
|
|
141 |
MarkerSection markerSection = formFactory.createMarkerSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); |
|
142 |
|
|
143 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
|
144 |
|
|
145 |
addPart(annotationSection);
|
|
146 |
addPart(markerSection); |
|
147 |
}
|
|
148 |
|
|
149 |
private void createIdentifiableSections(RootElement parent) { |
|
150 |
CreditSection creditSection = formFactory.createCreditSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
|
151 |
|
|
152 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
|
153 |
|
|
154 |
ExtensionSection extensionSection = formFactory.createExtensionSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); |
|
155 |
|
|
156 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
|
157 |
|
|
158 |
RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
|
159 |
|
|
160 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
|
161 |
|
|
162 |
SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
|
163 |
|
|
164 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
|
165 |
|
|
166 |
addPart(creditSection);
|
|
167 |
addPart(extensionSection); |
|
168 |
addPart(rightsSection);
|
|
169 |
addPart(sourceSection); |
|
170 |
|
|
187 | 171 |
} |
188 |
|
|
189 |
private void createVersionSection(RootElement parent){ |
|
190 |
VersionSection versionSection = formFactory.createVersionSection(parent, Section.NO_TITLE | Section.EXPANDED); |
|
172 |
|
|
173 |
private void createIdentifiableMediaSections(RootElement parent) { |
|
174 |
MediaSection mediaSection = formFactory.createMediaSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); |
|
175 |
|
|
176 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
|
177 |
|
|
178 |
addPart(mediaSection); |
|
179 |
} |
|
180 |
|
|
181 |
private void createVersionSection(RootElement parent){ |
|
182 |
VersionSection versionSection = formFactory.createVersionSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED); |
|
191 | 183 |
addPart(versionSection); |
192 | 184 |
} |
193 |
|
|
185 |
|
|
194 | 186 |
/** |
195 | 187 |
* @param rootElement |
196 | 188 |
*/ |
197 | 189 |
private void createCdmBaseSection(RootElement parent) { |
198 |
|
|
199 |
CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, Section.NO_TITLE | Section.EXPANDED);
|
|
190 |
|
|
191 |
CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
|
|
200 | 192 |
addPart(cdmBaseSection); |
201 | 193 |
} |
202 |
|
|
194 |
|
|
203 | 195 |
/* |
204 | 196 |
* (non-Javadoc) |
205 | 197 |
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) |
206 | 198 |
*/ |
207 | 199 |
/** {@inheritDoc} */ |
208 |
public void selectionChanged(SelectionChangedEvent event) { |
|
200 |
@Override |
|
201 |
public void selectionChanged(SelectionChangedEvent event) { |
|
209 | 202 |
if(event.getSource() instanceof DetailsViewer){ |
210 | 203 |
if(event.getSelection() == CdmFormFactory.EMPTY_SELECTION){ |
211 | 204 |
setInput(null); |
212 | 205 |
return; |
213 | 206 |
} |
214 |
|
|
215 |
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
|
|
207 |
|
|
208 |
IStructuredSelection selection = (IStructuredSelection) event.getSelection(); |
|
216 | 209 |
setInput(selection.getFirstElement()); |
217 | 210 |
} |
218 | 211 |
} |
Also available in: Unified diff
merged trunk into branch