Revision 61e0ca66
Added by Lorna Morris about 12 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java | ||
---|---|---|
19 | 19 |
import org.eclipse.ui.forms.widgets.Section; |
20 | 20 |
|
21 | 21 |
import eu.etaxonomy.cdm.model.common.AnnotatableEntity; |
22 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
22 | 23 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
23 | 24 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
24 | 25 |
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity; |
25 | 26 |
import eu.etaxonomy.taxeditor.model.IElementHasDetails; |
27 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
26 | 28 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
27 | 29 |
import eu.etaxonomy.taxeditor.ui.element.RootElement; |
28 | 30 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType; |
29 | 31 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection; |
30 | 32 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection; |
33 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection; |
|
31 | 34 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection; |
32 | 35 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection; |
33 | 36 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection; |
... | ... | |
48 | 51 |
*/ |
49 | 52 |
public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISelectionChangedListener { |
50 | 53 |
|
51 |
private enum VIEW_PART{ |
|
52 |
VersionableEntity, |
|
53 |
AnnotatableEntity, |
|
54 |
IdentifiableEntity, |
|
55 |
IdentifiableMediaEntity, |
|
56 |
EMPTY; |
|
57 |
} |
|
58 |
|
|
59 |
private VIEW_PART currentViewPart; |
|
54 |
private boolean showDebug; |
|
60 | 55 |
|
61 | 56 |
|
62 | 57 |
/** |
... | ... | |
95 | 90 |
@Override |
96 | 91 |
protected void showParts() { |
97 | 92 |
|
93 |
showDebug = PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.SHOW_DEBUG_INFORMATION); |
|
94 |
|
|
98 | 95 |
Object input; |
99 | 96 |
|
100 | 97 |
if(getInput() instanceof IElementHasDetails){ |
... | ... | |
103 | 100 |
input = getInput(); |
104 | 101 |
} |
105 | 102 |
|
106 |
if(input instanceof IdentifiableMediaEntity){ |
|
107 |
if(currentViewPart != VIEW_PART.IdentifiableMediaEntity){ |
|
108 |
currentViewPart = VIEW_PART.IdentifiableMediaEntity; |
|
109 |
createIdentifiableMediaSections(rootElement); |
|
110 |
} |
|
111 |
}else if(input instanceof IdentifiableEntity){ |
|
112 |
if(currentViewPart != VIEW_PART.IdentifiableEntity){ |
|
113 |
currentViewPart = VIEW_PART.IdentifiableEntity; |
|
114 |
createIdentifiableSections(rootElement); |
|
115 |
} |
|
116 |
}else if(input instanceof AnnotatableEntity){ |
|
117 |
if(currentViewPart != VIEW_PART.AnnotatableEntity){ |
|
118 |
currentViewPart = VIEW_PART.AnnotatableEntity; |
|
103 |
destroySections(); |
|
104 |
//1. Headline |
|
105 |
createHeadlineSection(rootElement); |
|
106 |
//2. Annotatable entitiy |
|
107 |
if(input instanceof AnnotatableEntity){ |
|
119 | 108 |
createAnnotationSections(rootElement); |
120 |
} |
|
121 |
}else if(input instanceof VersionableEntity){ |
|
122 |
if(currentViewPart != VIEW_PART.VersionableEntity){ |
|
123 |
currentViewPart = VIEW_PART.VersionableEntity; |
|
124 |
createHeadlineSection(rootElement); |
|
125 |
} |
|
126 |
}else{ |
|
127 |
currentViewPart = VIEW_PART.EMPTY; |
|
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); |
|
128 | 125 |
} |
129 | 126 |
|
130 | 127 |
layout(); |
131 | 128 |
} |
132 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
133 | 132 |
private void createHeadlineSection(RootElement parent){ |
134 |
destroySections(); |
|
135 | 133 |
HeadlineSection headlineSection = formFactory.createHeadlineSection(parent); |
136 | 134 |
addPart(headlineSection); |
137 |
|
|
138 |
if(currentViewPart == VIEW_PART.VersionableEntity){ |
|
139 |
createVersionSection(parent); |
|
140 |
} |
|
141 | 135 |
} |
142 | 136 |
|
143 | 137 |
private void createAnnotationSections(RootElement parent){ |
144 |
createHeadlineSection(parent); |
|
145 | 138 |
AnnotationSection annotationSection = (AnnotationSection) |
146 | 139 |
formFactory.createEntityDetailSection(EntityDetailType.ANNOTATION, getConversationHolder(), parent, Section.TWISTIE); |
147 | 140 |
|
... | ... | |
154 | 147 |
|
155 | 148 |
addPart(annotationSection); |
156 | 149 |
addPart(markerSection); |
157 |
|
|
158 |
if(currentViewPart == VIEW_PART.AnnotatableEntity){ |
|
159 |
createVersionSection(parent); |
|
160 |
} |
|
161 | 150 |
} |
162 | 151 |
|
163 |
private void createIdentifiableSections(RootElement parent){ |
|
164 |
createAnnotationSections(parent); |
|
152 |
private void createIdentifiableSections(RootElement parent){ |
|
165 | 153 |
CreditSection creditSection = (CreditSection) |
166 | 154 |
formFactory.createEntityDetailSection(EntityDetailType.CREDIT, getConversationHolder(), parent, Section.TWISTIE); |
167 | 155 |
|
... | ... | |
187 | 175 |
addPart(rightsSection); |
188 | 176 |
addPart(sourceSection); |
189 | 177 |
|
190 |
if(currentViewPart == VIEW_PART.IdentifiableEntity){ |
|
191 |
createVersionSection(parent); |
|
192 |
} |
|
193 | 178 |
} |
194 | 179 |
|
195 | 180 |
private void createIdentifiableMediaSections(RootElement parent){ |
196 |
createIdentifiableSections(parent); |
|
197 | 181 |
MediaSection mediaSection = (MediaSection) |
198 | 182 |
formFactory.createEntityDetailSection(EntityDetailType.MEDIA, getConversationHolder(), parent, Section.TWISTIE); |
199 | 183 |
|
200 | 184 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
201 | 185 |
|
202 | 186 |
addPart(mediaSection); |
203 |
|
|
204 |
if(currentViewPart == VIEW_PART.IdentifiableMediaEntity){ |
|
205 |
createVersionSection(parent); |
|
206 |
} |
|
207 | 187 |
} |
208 | 188 |
|
209 | 189 |
private void createVersionSection(RootElement parent){ |
... | ... | |
211 | 191 |
addPart(versionSection); |
212 | 192 |
} |
213 | 193 |
|
194 |
/** |
|
195 |
* @param rootElement |
|
196 |
*/ |
|
197 |
private void createCdmBaseSection(RootElement parent) { |
|
198 |
|
|
199 |
CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, Section.NO_TITLE | Section.EXPANDED); |
|
200 |
addPart(cdmBaseSection); |
|
201 |
} |
|
202 |
|
|
214 | 203 |
/* |
215 | 204 |
* (non-Javadoc) |
216 | 205 |
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) |
... | ... | |
220 | 209 |
if(event.getSource() instanceof DetailsViewer){ |
221 | 210 |
if(event.getSelection() == CdmFormFactory.EMPTY_SELECTION){ |
222 | 211 |
setInput(null); |
223 |
currentViewPart = VIEW_PART.EMPTY; |
|
224 | 212 |
return; |
225 | 213 |
} |
226 | 214 |
|
Also available in: Unified diff
Fixes #2572. Fixes #2574. Also simplified SupplementalDataViewer so that everytime the viewer is refreshed the sections are recreated.