+package eu.etaxonomy.taxeditor.view.userecords;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.SelectionChangedEvent;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.forms.widgets.Section;\r
+\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.cdm.model.reference.Reference;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.taxeditor.ui.forms.RootElement;\r
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;\r
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;\r
+import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;\r
+import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;\r
+import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;\r
+import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;\r
+\r
+\r
+\r
+\r
+\r
+public class UseRecordsViewer extends AbstractCdmDataViewer {\r
+ private enum VIEW_PART {\r
+ TAXON,\r
+ ECO_REGION,\r
+ COUNTRY,\r
+ PLANT_PART,\r
+ USE_CATEGORY,\r
+ USE_SUBCATEGORY,\r
+ ETHNIC_GROUP,\r
+ HUMAN_GROUP,\r
+ DESCRIPTION, \r
+ DESCRIPTION_ELEMENT,\r
+ REFEERENCE, \r
+ TEAM, \r
+ PERSON, \r
+ TEAM_OR_PERSON_BASE,\r
+ EMPTY,\r
+ IMAGE_GALLERY\r
+ }\r
+\r
+ private VIEW_PART currentViewPart;\r
+\r
+ private ISelection selection;\r
+ \r
+ public UseRecordsViewer(Composite parent, AbstractCdmViewPart viewPart) {\r
+ super(parent, viewPart);\r
+ }\r
+ @Override\r
+ protected void showParts() {\r
+ if (getInput() instanceof TaxonBase) {\r
+ if (currentViewPart != VIEW_PART.TAXON) {\r
+ createTaxonSections(rootElement);\r
+ currentViewPart = VIEW_PART.TAXON;\r
+ }\r
+ } else if (getInput() instanceof Reference) {\r
+ if (currentViewPart != VIEW_PART.REFEERENCE) {\r
+ createReferenceSections(rootElement);\r
+ currentViewPart = VIEW_PART.REFEERENCE;\r
+ }\r
+ } else if (getInput() instanceof DescriptionBase) {\r
+ if (((DescriptionBase) getInput()).isImageGallery()) {\r
+ if (currentViewPart != VIEW_PART.IMAGE_GALLERY) {\r
+ createImageGallerySection(rootElement);\r
+ currentViewPart = VIEW_PART.IMAGE_GALLERY;\r
+ }\r
+ } else {\r
+ if (currentViewPart != VIEW_PART.DESCRIPTION) {\r
+ createDescriptionSection(rootElement);\r
+ currentViewPart = VIEW_PART.DESCRIPTION;\r
+ }\r
+ }\r
+ } else if (getInput() instanceof DescriptionElementBase) {\r
+ if (currentViewPart != VIEW_PART.DESCRIPTION_ELEMENT) {\r
+ createDescriptionElementSection(rootElement);\r
+ currentViewPart = VIEW_PART.DESCRIPTION_ELEMENT;\r
+ }\r
+ } else {\r
+ destroySections();\r
+ currentViewPart = VIEW_PART.EMPTY;\r
+ }\r
+ layout();\r
+ \r
+ }\r
+ private void createTaxonSections(RootElement parent) {\r
+ destroySections();\r
+\r
+ TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory\r
+ .createCdmDetailSection(DetailType.TAXONBASE,\r
+ getConversationHolder(), parent, this, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory\r
+ .createCdmDetailSection(DetailType.NONVIRALNAME,\r
+ getConversationHolder(), parent, this, Section.TWISTIE\r
+ | Section.EXPANDED);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory\r
+ .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE,\r
+ getConversationHolder(), parent, this, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory\r
+ .createEntityDetailSection(\r
+ EntityDetailType.NOMENCLATURALSTATUS,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ ProtologueSection protologSection = (ProtologueSection) formFactory\r
+ .createEntityDetailSection(EntityDetailType.PROTOLOG,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory\r
+ .createEntityDetailSection(EntityDetailType.TYPEDESIGNATION,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory\r
+ .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory\r
+ .createCdmDetailSection(DetailType.PARSINGMESSAGE,\r
+ getConversationHolder(), parent, this, Section.EXPANDED);\r
+\r
+ addPart(taxonBaseDetailSection);\r
+ addPart(nonViralNameSection);\r
+ addPart(nomenclaturalStatusSection);\r
+ addPart(protologSection);\r
+ addPart(referenceDetailSection);\r
+ addPart(typeDesignationSection);\r
+ addPart(nameRelationshipSection);\r
+ addPart(parsingMessagesSection);\r
+ }\r
+ private void createDescriptionElementSection(RootElement parent) {\r
+ destroySections();\r
+\r
+ DescriptionElementDetailSection descriptionElementDetailSection = (DescriptionElementDetailSection) formFactory\r
+ .createCdmDetailSection(DetailType.DESCRIPTIONELEMENT,\r
+ getConversationHolder(), parent, this, Section.TWISTIE\r
+ | Section.EXPANDED);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ DescriptionElementSourceSection descriptionElementSourceSection = (DescriptionElementSourceSection) formFactory\r
+ .createEntityDetailSection(\r
+ EntityDetailType.DESCRIPTIONELEMENTSOURCE,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ DescriptionElementMediaSection descriptionElementMediaSection = (DescriptionElementMediaSection) formFactory\r
+ .createEntityDetailSection(\r
+ EntityDetailType.DESCRIPTIONELEMENTMEDIA,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ addPart(descriptionElementDetailSection);\r
+ addPart(descriptionElementSourceSection);\r
+ addPart(descriptionElementMediaSection);\r
+ }\r
+ \r
+ private void createDescriptionSection(RootElement parent) {\r
+ destroySections();\r
+ DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory\r
+ .createCdmDetailSection(DetailType.DESCRIPTION,\r
+ getConversationHolder(), parent, this, Section.TWISTIE\r
+ | Section.EXPANDED);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory\r
+ .createCdmDetailSection(DetailType.NATURAL_LANGUAGE,\r
+ getConversationHolder(), parent, this, Section.TWISTIE\r
+ | Section.EXPANDED);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory\r
+ .createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory\r
+ .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ ScopeSection scopeSection = (ScopeSection) formFactory\r
+ .createEntityDetailSection(EntityDetailType.SCOPE,\r
+ getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+ addPart(descriptionDetailSection);\r
+ addPart(naturalLanguageSection);\r
+ addPart(describedSpecimenSection);\r
+ addPart(descriptionSourceSection);\r
+ addPart(scopeSection);\r
+ }\r
+ \r
+ private void createImageGallerySection(RootElement parent) {\r
+ destroySections();\r
+ DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory\r
+ .createCdmDetailSection(DetailType.DESCRIPTION,\r
+ getConversationHolder(), parent, this, Section.TWISTIE\r
+ | Section.EXPANDED);\r
+\r
+ addPart(descriptionDetailSection);\r
+ }\r
+ \r
+ private void createReferenceSections(RootElement parent) {\r
+ destroySections();\r
+\r
+ ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory\r
+ .createCdmDetailSection(DetailType.REFERENCEBASE,\r
+ getConversationHolder(), parent, this, Section.TWISTIE\r
+ | Section.EXPANDED);\r
+\r
+ addPart(referenceDetailSection);\r
+ \r
+ }\r
+ @Override\r
+ public ISelection getSelection() {\r
+ return selection;\r
+ }\r
+ @Override\r
+ public void setSelection(ISelection selection, boolean reveal) {\r
+ this.selection = selection;\r
+ SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(\r
+ this, selection);\r
+ fireSelectionChanged(selectionChangedEvent);\r
+ }\r
+\r
+}\r