3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.editor
.view
.detail
;
13 import org
.eclipse
.jface
.viewers
.ISelection
;
14 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.ui
.forms
.widgets
.Section
;
19 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
20 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
21 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
22 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
23 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
24 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
25 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
26 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
29 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
30 import eu
.etaxonomy
.taxeditor
.editor
.MultiPageTaxonEditor
;
31 import eu
.etaxonomy
.taxeditor
.editor
.Page
;
32 import eu
.etaxonomy
.taxeditor
.editor
.name
.AbstractGroupedContainer
;
33 import eu
.etaxonomy
.taxeditor
.editor
.name
.TaxonNameEditor
;
34 import eu
.etaxonomy
.taxeditor
.editor
.view
.AbstractCdmDataViewer
;
35 import eu
.etaxonomy
.taxeditor
.forms
.AbstractFormSection
;
36 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
.DetailType
;
37 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
.EntityDetailType
;
38 import eu
.etaxonomy
.taxeditor
.forms
.RootElement
;
39 import eu
.etaxonomy
.taxeditor
.model
.AbstractCdmViewPart
;
40 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
43 * <p>DetailsViewer class.</p>
46 * @created Feb 12, 2010
49 public class DetailsViewer
extends AbstractCdmDataViewer
{
51 private enum VIEW_PART
{
67 private VIEW_PART currentViewPart
;
69 private ISelection selection
;
71 private AbstractGroupedContainer sourceContainer
;
74 * <p>Constructor for DetailsViewer.</p>
76 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
77 * @param viewPart a {@link eu.etaxonomy.taxeditor.model.AbstractCdmViewPart} object.
79 public DetailsViewer(Composite parent
, AbstractCdmViewPart viewPart
) {
80 super(parent
, viewPart
);
84 * @see org.eclipse.jface.viewers.Viewer#refresh()
88 protected void showParts() {
89 if(getInput() instanceof TaxonBase
){
90 if(currentViewPart
!= VIEW_PART
.TAXON
){
91 createTaxonSections(rootElement
);
92 currentViewPart
= VIEW_PART
.TAXON
;
94 // preserve a pointer to the AbstractNameComposite
95 MultiPageTaxonEditor editor
= EditorUtil
.getActiveMultiPageTaxonEditor();
97 TaxonNameEditor page
= (TaxonNameEditor
) editor
.getPage(Page
.NAME
);
98 for(AbstractGroupedContainer container
: page
.getGroupedContainers()){
99 if(container
.getData() == getInput()){
100 sourceContainer
= container
;
105 }else if(getInput() instanceof NonViralName
){
106 if(currentViewPart
!= VIEW_PART
.NAME
){
107 createNameSections(rootElement
);
108 currentViewPart
= VIEW_PART
.NAME
;
110 }else if(getInput() instanceof Reference
){
111 if(currentViewPart
!= VIEW_PART
.REFEERENCE
){
112 createReferenceSections(rootElement
);
113 currentViewPart
= VIEW_PART
.REFEERENCE
;
115 }else if(getInput() instanceof Team
){
116 if(currentViewPart
!= VIEW_PART
.TEAM
){
117 createTeamDetailSection(rootElement
);
118 currentViewPart
= VIEW_PART
.TEAM
;
120 }else if(getInput() instanceof Person
){
121 if(currentViewPart
!= VIEW_PART
.PERSON
){
122 createPersonDetailSection(rootElement
);
123 currentViewPart
= VIEW_PART
.PERSON
;
125 }else if(getInput() instanceof TeamOrPersonBase
){
127 if(currentViewPart
!= VIEW_PART
.TEAM_OR_PERSON_BASE
){
128 createTeamOrPersonBaseDetailSection(rootElement
);
129 currentViewPart
= VIEW_PART
.TEAM_OR_PERSON_BASE
;
131 }else if(getInput() instanceof DescriptionBase
){
132 if(currentViewPart
!= VIEW_PART
.DESCRIPTION
){
133 createDescriptionSection(rootElement
);
134 currentViewPart
= VIEW_PART
.DESCRIPTION
;
136 }else if(getInput() instanceof DescriptionElementBase
){
137 if(currentViewPart
!= VIEW_PART
.DESCRIPTION_ELEMENT
){
138 createDescriptionElementSection(rootElement
);
139 currentViewPart
= VIEW_PART
.DESCRIPTION_ELEMENT
;
141 }else if(getInput() instanceof Media
){
142 if(currentViewPart
!= VIEW_PART
.MEDIA
){
143 createMediaElementSection(rootElement
);
144 currentViewPart
= VIEW_PART
.MEDIA
;
146 }else if(getInput() instanceof DerivedUnitBase
){
147 if(currentViewPart
!= VIEW_PART
.DERIVED_UNIT_BASE
){
148 createDerivedUnitBaseElementSection(rootElement
);
149 currentViewPart
= VIEW_PART
.DERIVED_UNIT_BASE
;
151 }else if(getInput() instanceof DerivedUnitBase
){
152 if(currentViewPart
!= VIEW_PART
.FIELD_OBSERVATION
){
153 createFieldObservationElementSection(rootElement
);
154 currentViewPart
= VIEW_PART
.FIELD_OBSERVATION
;
156 }else if(getInput() instanceof FeatureNodeContainer
) {
157 if(currentViewPart
!= VIEW_PART
.FEATURE_DISTRIBUTION
){
158 createFeatureDistributionSection(rootElement
);
159 currentViewPart
= VIEW_PART
.FEATURE_DISTRIBUTION
;
163 currentViewPart
= VIEW_PART
.EMPTY
;
171 * @see org.eclipse.jface.viewers.Viewer#getSelection()
175 public ISelection
getSelection() {
180 * @see org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
184 public void setSelection(ISelection selection
, boolean reveal
) {
185 this.selection
= selection
;
186 SelectionChangedEvent selectionChangedEvent
= new SelectionChangedEvent(this, selection
);
187 fireSelectionChanged(selectionChangedEvent
);
191 private void createTaxonSections(RootElement parent
) {
194 AbstractFormSection taxonBaseDetailSection
=
195 formFactory
.createCdmDetailSection(DetailType
.TAXONBASE
, getConversationHolder(), parent
, this, Section
.TWISTIE
);
197 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
199 AbstractFormSection nonViralNameSection
=
200 formFactory
.createCdmDetailSection(DetailType
.NONVIRALNAME
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
202 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
204 AbstractFormSection referenceBaseDetailSection
=
205 formFactory
.createCdmDetailSection(DetailType
.NOMENCLATURALREFERENCE
, getConversationHolder(), parent
, this, Section
.TWISTIE
);
207 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
209 AbstractFormSection nomenclaturalStatusSection
=
210 formFactory
.createEntityDetailSection(EntityDetailType
.NOMENCLATURALSTATUS
, getConversationHolder(), parent
, Section
.TWISTIE
);
212 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
214 AbstractFormSection protologSection
=
215 formFactory
.createEntityDetailSection(EntityDetailType
.PROTOLOG
, getConversationHolder(), parent
, Section
.TWISTIE
);
217 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
219 AbstractFormSection typeDesignationSection
=
220 formFactory
.createEntityDetailSection(EntityDetailType
.TYPEDESIGNATION
, getConversationHolder(), parent
, Section
.TWISTIE
);
222 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
224 AbstractFormSection nameRelationshipSection
=
225 formFactory
.createEntityDetailSection(EntityDetailType
.NAME_RELATIONSHIP
, getConversationHolder(), parent
, Section
.TWISTIE
);
227 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
229 AbstractFormSection parsingMessagesSection
=
230 formFactory
.createCdmDetailSection(DetailType
.PARSINGMESSAGE
, getConversationHolder(), parent
, this, Section
.EXPANDED
);
234 addPart(taxonBaseDetailSection
);
235 addPart(nonViralNameSection
);
236 addPart(nomenclaturalStatusSection
);
237 addPart(protologSection
);
238 addPart(referenceBaseDetailSection
);
239 addPart(typeDesignationSection
);
240 addPart(parsingMessagesSection
);
241 addPart(nameRelationshipSection
);
244 private void createNameSections(RootElement parent
) {
246 AbstractFormSection nonViralNameSection
=
247 formFactory
.createCdmDetailSection(DetailType
.NONVIRALNAME
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
249 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
251 AbstractFormSection referenceBaseDetailSection
=
252 formFactory
.createCdmDetailSection(DetailType
.NOMENCLATURALREFERENCE
, getConversationHolder(), parent
, this, Section
.TWISTIE
);
254 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
256 AbstractFormSection nomenclaturalStatusSection
=
257 formFactory
.createEntityDetailSection(EntityDetailType
.NOMENCLATURALSTATUS
, getConversationHolder(), parent
, Section
.TWISTIE
);
259 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
261 AbstractFormSection protologSection
=
262 formFactory
.createEntityDetailSection(EntityDetailType
.PROTOLOG
, getConversationHolder(), parent
, Section
.TWISTIE
);
264 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
266 AbstractFormSection typeDesignationSection
=
267 formFactory
.createEntityDetailSection(EntityDetailType
.TYPEDESIGNATION
, getConversationHolder(), parent
, Section
.TWISTIE
);
269 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
271 AbstractFormSection nameRelationshipSection
=
272 formFactory
.createEntityDetailSection(EntityDetailType
.NAME_RELATIONSHIP
, getConversationHolder(), parent
, Section
.TWISTIE
);
274 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
276 addPart(nonViralNameSection
);
277 addPart(nomenclaturalStatusSection
);
278 addPart(protologSection
);
279 addPart(referenceBaseDetailSection
);
280 addPart(typeDesignationSection
);
281 addPart(nameRelationshipSection
);
284 private void createReferenceSections(RootElement parent
) {
286 AbstractFormSection referenceBaseDetailSection
=
287 formFactory
.createCdmDetailSection(DetailType
.REFERENCEBASE
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
288 addPart(referenceBaseDetailSection
);
291 private void createTeamOrPersonBaseDetailSection(RootElement parent
) {
293 AbstractFormSection teamOrPersonBaseDetailSection
=
294 formFactory
.createCdmDetailSection(DetailType
.TEAMORPERSONBASE
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
296 addPart(teamOrPersonBaseDetailSection
);
299 private void createTeamDetailSection(RootElement parent
){
301 AbstractFormSection teamDetailSection
=
302 formFactory
.createCdmDetailSection(DetailType
.TEAM
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
304 addPart(teamDetailSection
);
308 private void createPersonDetailSection(RootElement parent
) {
310 AbstractFormSection personDetailSection
=
311 formFactory
.createCdmDetailSection(DetailType
.PERSON
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
312 addPart(personDetailSection
);
315 private void createDescriptionElementSection(RootElement parent
) {
318 AbstractFormSection descriptionElementDetailSection
=
319 formFactory
.createCdmDetailSection(DetailType
.DESCRIPTIONELEMENT
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
321 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
323 AbstractFormSection descriptionElementSourceSection
=
324 formFactory
.createEntityDetailSection(EntityDetailType
.DESCRIPTIONELEMENTSOURCE
, getConversationHolder(), parent
, Section
.TWISTIE
);
326 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
328 AbstractFormSection descriptionElementMediaSection
=
329 formFactory
.createEntityDetailSection(EntityDetailType
.DESCRIPTIONELEMENTMEDIA
, getConversationHolder(), parent
, Section
.TWISTIE
);
331 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
333 addPart(descriptionElementDetailSection
);
334 addPart(descriptionElementSourceSection
);
335 addPart(descriptionElementMediaSection
);
338 private void createDescriptionSection(RootElement parent
) {
340 AbstractFormSection descriptionDetailSection
=
341 formFactory
.createCdmDetailSection(DetailType
.DESCRIPTION
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
343 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
345 AbstractFormSection naturalLanguageSection
=
346 formFactory
.createCdmDetailSection(DetailType
.NATURAL_LANGUAGE
, getConversationHolder(), parent
, this,Section
.TWISTIE
| Section
.EXPANDED
);
348 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
350 AbstractFormSection describedSpecimenSection
=
351 formFactory
.createEntityDetailSection(EntityDetailType
.DESCRIBED_SPECIMEN
, getConversationHolder(), parent
, Section
.TWISTIE
);
353 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
355 AbstractFormSection descriptionSourceSection
=
356 formFactory
.createEntityDetailSection(EntityDetailType
.DESCRIPTIONSOURCE
, getConversationHolder(), parent
, Section
.TWISTIE
);
358 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
360 AbstractFormSection scopeSection
=
361 formFactory
.createEntityDetailSection(EntityDetailType
.SCOPE
, getConversationHolder(), parent
, Section
.TWISTIE
);
363 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
365 addPart(descriptionDetailSection
);
366 addPart(naturalLanguageSection
);
367 addPart(describedSpecimenSection
);
368 addPart(descriptionSourceSection
);
369 addPart(scopeSection
);
373 private void createMediaElementSection(RootElement parent
) {
375 AbstractFormSection mediaDetailSection
= formFactory
.createCdmDetailSection(DetailType
.MEDIA
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
377 addPart(mediaDetailSection
);
380 private void createDerivedUnitBaseElementSection(RootElement parent
){
383 AbstractFormSection derivedUnitBaseElementSection
= formFactory
.createCdmDetailSection(DetailType
.DERIVED_UNIT_FACADE
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
385 addPart(derivedUnitBaseElementSection
);
388 private void createFieldObservationElementSection(RootElement parent
){
391 AbstractFormSection fieldObservationElementSection
= formFactory
.createCdmDetailSection(DetailType
.FIELD_OBSERVATION
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
393 addPart(fieldObservationElementSection
);
399 private void createFeatureDistributionSection(RootElement parent
) {
402 AbstractFormSection featureDistributionSection
=formFactory
.createCdmDetailSection(DetailType
.FEATURE_DISTRIBUTION
, getConversationHolder(), parent
, this, Section
.TWISTIE
| Section
.EXPANDED
);
404 addPart(featureDistributionSection
);