latest changes from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / detail / DetailsViewer.java
index 07cbf2884107c3a41b2fc8984836046285b2ddcb..a03175185795dc9df7af384fb35f90209afaa8ac 100644 (file)
@@ -1,3 +1,4 @@
+
 // $Id$
 /**
  * Copyright (C) 2011 EDIT
@@ -14,6 +15,7 @@ import java.util.Set;
 
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.forms.widgets.ExpandableComposite;
@@ -21,6 +23,7 @@ import org.eclipse.ui.forms.widgets.ExpandableComposite;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
 import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
 import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.agent.Team;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
@@ -33,28 +36,27 @@ import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.description.CategoricalData;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
-import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;
 import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.cdm.model.molecular.Amplification;
+import eu.etaxonomy.cdm.model.molecular.DnaSample;
+import eu.etaxonomy.cdm.model.molecular.Sequence;
+import eu.etaxonomy.cdm.model.molecular.SingleRead;
 import eu.etaxonomy.cdm.model.name.NonViralName;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
+import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
 import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.ui.campanula.detailViews.fieldObservation.FieldObservationDetailsSection;
-import eu.etaxonomy.taxeditor.ui.campanula.detailViews.fieldObservation.FieldObservationGeneralSection;
-import eu.etaxonomy.taxeditor.ui.campanula.detailViews.fieldObservation.GatheringEventSection;
-import eu.etaxonomy.taxeditor.ui.campanula.detailViews.specimen.DerivedUnitDetailsSection;
-import eu.etaxonomy.taxeditor.ui.campanula.detailViews.specimen.SpecimenDetailsSection;
-import eu.etaxonomy.taxeditor.ui.campanula.detailViews.specimen.SpecimenGeneralSection;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.RootElement;
 import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
@@ -82,8 +84,31 @@ import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
 import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
 import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGelPhotoCollectionDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationGeneralDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationPrimerDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
 import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
@@ -138,34 +163,41 @@ public class DetailsViewer extends AbstractCdmDataViewer {
      */
     @Override
     public void setInput(Object input) {
-               if (input instanceof DerivedUnit) {
+        if(input instanceof TreeNode){
+            input = ((TreeNode) input).getValue();
+        }
+        if(input instanceof GbifResponse){
+            input = ((GbifResponse) input).getDerivedUnitFacade();
+        }
+        if (input.getClass().equals(DerivedUnit.class)) {
+            DerivedUnit derivedUnit = (DerivedUnit)input;
             try {
-                               input = DerivedUnitFacade.NewInstance((DerivedUnit) input,PreferencesUtil.getDerivedUnitConfigurator());
+                input = DerivedUnitFacade.NewInstance(derivedUnit,
+                        PreferencesUtil.getDerivedUnitConfigurator());
             } catch (DerivedUnitFacadeNotSupportedException e) {
-                AbstractUtility.error(getClass(), e);
+//                MessagingUtils.error(getClass(), e); //nothing should happen, later on the Details View will show an according information that it is not possible to open this data
             }
         }
-               else if(input instanceof FieldUnit){
-                   input = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit) input,PreferencesUtil.getDerivedUnitConfigurator());
-               }
+        else if(input instanceof FieldUnit){
+            input = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit) input);
+        }
         super.setInput(input);
     }
 
     @Override
     protected void markViewPartDirty() {
         if (getInput() instanceof DerivedUnitFacade) {
-            DerivedUnitFacade derivedUnitFacade = (DerivedUnitFacade) getInput();
-            DerivedUnit innerDerivedUnit = derivedUnitFacade.innerDerivedUnit();
-            FieldUnit innerFieldUnit = derivedUnitFacade.innerFieldUnit();
-            if(innerDerivedUnit!=null){
-                getViewPart().changed(innerDerivedUnit);
+            DerivedUnitFacade facade = (DerivedUnitFacade) getInput();
+            if(facade.innerDerivedUnit()!=null){
+                getViewPart().changed(facade.innerDerivedUnit());
             }
-            else if(innerFieldUnit!=null){
-                getViewPart().changed(innerFieldUnit);
+            else if(facade.innerFieldUnit()!=null){
+                getViewPart().changed(facade.innerFieldUnit());
             }
         }
-
-        super.markViewPartDirty();
+        else{
+            super.markViewPartDirty();
+        }
     }
 
     // END HACK TO MAKE THE DERIVED UNIT FACADE WORK
@@ -183,6 +215,8 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         // Need to build in a mechanism where navigators / editors are 'aware'
         // of the corresponding detail viewer.
         Object input = getInput();
+
+        destroySections();
         if (input instanceof TaxonBase) {
             createTaxonSections(rootElement);
 
@@ -202,23 +236,29 @@ public class DetailsViewer extends AbstractCdmDataViewer {
             createTeamOrPersonBaseDetailSection(rootElement);
 
         } else if (input instanceof DescriptionBase) {
-            Set<Marker> descriptionMarkers = ((DescriptionBase) input).getMarkers();
-            MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
-                    UsageTermCollection.uuidUseMarkerType);
-            Boolean isUseDescription = false;
-            for (Marker marker : descriptionMarkers) {
-                if (marker.getMarkerType().equals(useMarkertype)) {
-                    isUseDescription = true;
-                }
+            if(input instanceof SpecimenDescription){
+                //TODO: add more sections to DetailsView for SpecimenDescription
+                createSpecimenDescriptionSection(rootElement);
             }
-            if (((DescriptionBase) input).isImageGallery()) {
-                createImageGallerySection(rootElement);
+            else{
+                Set<Marker> descriptionMarkers = ((DescriptionBase) input).getMarkers();
+                MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
+                        UsageTermCollection.uuidUseMarkerType);
+                Boolean isUseDescription = false;
+                for (Marker marker : descriptionMarkers) {
+                    if (marker.getMarkerType().equals(useMarkertype)) {
+                        isUseDescription = true;
+                    }
+                }
+                if (((DescriptionBase) input).isImageGallery()) {
+                    createImageGallerySection(rootElement);
 
-            } else if (isUseDescription) {
-                createUseDescriptionSection(rootElement);
-            } else {
-                createDescriptionSection(rootElement);
+                } else if (isUseDescription) {
+                    createUseDescriptionSection(rootElement);
+                } else {
+                    createDescriptionSection(rootElement);
 
+                }
             }
         } else if (input instanceof DescriptionElementBase) {
             Set<Marker> descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers();
@@ -241,20 +281,44 @@ public class DetailsViewer extends AbstractCdmDataViewer {
             createMediaElementSection(rootElement);
 
         } else if (input instanceof DerivedUnitFacade) {
-            DerivedUnitFacade derivedUnitFacade = (DerivedUnitFacade)input;
-
-            if(derivedUnitFacade.getType()==SpecimenOrObservationType.FieldUnit){
-                createFieldObservationDetailsView(rootElement);
-            } else{
-                createSpecimenDetailsView(rootElement);
+            if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.FieldUnit){
+                createFieldUnitSection(rootElement);
+            }
+            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.PreservedSpecimen){
+                createDerivedUnitBaseElementSection(rootElement);
             }
-        } else if (input instanceof FeatureNodeContainer) {
+            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.TissueSample){
+                //TissueSample should only be created by using it's own class
+                //in future using only one class with different SpecimenOrObservationTypes is desired
+//                createTissueSampleSection(rootElement);
+            }
+            else{
+                createDerivedUnitBaseElementSection(rootElement);
+            }
+        } else if (input instanceof DnaSample){
+            DnaSample dnaSample = (DnaSample)input;
+            if(dnaSample.getRecordBasis()==SpecimenOrObservationType.TissueSample){
+                createTissueSampleSection(rootElement);
+            }
+            else if(dnaSample.getRecordBasis()==SpecimenOrObservationType.DnaSample){
+                createDnaSampleSection(rootElement);
+            }
+        } else if (input instanceof MediaSpecimen){
+            createMediaSpecimenSection(rootElement);
+        }
+        else if(input instanceof Amplification){
+            createAmplificationSection(rootElement);
+        }
+        else if(input instanceof Sequence){
+            createSequenceSection(rootElement);
+        }
+        else if(input instanceof SingleRead){
+            createSingleReadSection(rootElement);
+        }
+        else if (input instanceof FeatureNodeContainer) {
             createFeatureDistributionSection(rootElement);
 
-        } else if (input instanceof PolytomousKey) {
-            // createPolytomousKeySection(rootElement);
-
-        } else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) {
+        }else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) {
             createPolytomousKeyNodeSection(rootElement);
         } else if (input instanceof User) {
             createUserSection(rootElement);
@@ -266,12 +330,25 @@ public class DetailsViewer extends AbstractCdmDataViewer {
             createTermVocabularySection(rootElement);
         } else if (input instanceof DefinedTermBase) {
             createDefinedTermSection(rootElement);
-        } else {
-            destroySections();
+        }
+        else {
+            createEmptySection(rootElement);
         }
         layout();
     }
 
+
+    /**
+     * @param rootElement
+     */
+    private void createEmptySection(RootElement parent) {
+        destroySections();
+
+        EmptySection emptySection = formFactory.createEmptySection(formFactory, parent, SWT.NONE);
+
+        addPart(emptySection);
+    }
+
     /**
      * @param rootElement
      */
@@ -309,8 +386,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
     @Override
     public void setSelection(ISelection selection, boolean reveal) {
         this.selection = selection;
-        SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
-        fireSelectionChanged(selectionChangedEvent);
+        if(this.selection!=null){
+            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
+            fireSelectionChanged(selectionChangedEvent);
+        }
     }
 
     /**
@@ -321,45 +400,47 @@ public class DetailsViewer extends AbstractCdmDataViewer {
     private void createTaxonSections(RootElement parent) {
         destroySections();
 
-        TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
+                ExpandableComposite.EXPANDED | ExpandableComposite.EXPANDED);
 
+        TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE     | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
-                        | ExpandableComposite.EXPANDED);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-
+        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,ExpandableComposite.TWISTIE);
-
+        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
+        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+        //TODO RL
+        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+               ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+               TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+               NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+                       addPart(protologSection);
+                       addPart(typeDesignationSection);
+                       addPart(nameRelationshipSection);
+        }
 
-        ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this, ExpandableComposite.EXPANDED);
 
+        addPart(parsingMessagesSection);
         addPart(taxonBaseDetailSection);
         addPart(nonViralNameSection);
         addPart(nomenclaturalStatusSection);
-        addPart(protologSection);
         addPart(referenceDetailSection);
-        addPart(typeDesignationSection);
-        addPart(nameRelationshipSection);
-        addPart(parsingMessagesSection);
     }
 
     /**
@@ -369,36 +450,35 @@ public class DetailsViewer extends AbstractCdmDataViewer {
      */
     private void createNameSections(RootElement parent) {
         destroySections();
-        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-
+        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
+        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
+        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         addPart(nonViralNameSection);
         addPart(nomenclaturalStatusSection);
-        addPart(protologSection);
         addPart(referenceDetailSection);
-        addPart(typeDesignationSection);
-        addPart(nameRelationshipSection);
+//TODO RL
+        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+                       ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+               TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+               NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+               addPart(protologSection);
+               addPart(typeDesignationSection);
+               addPart(nameRelationshipSection);
+        }
     }
 
     /**
@@ -409,7 +489,8 @@ public class DetailsViewer extends AbstractCdmDataViewer {
     private void createReferenceSections(RootElement parent) {
         destroySections();
 
-        ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         addPart(referenceDetailSection);
     }
@@ -493,9 +574,11 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-//        DescriptionSourceSection descriptionSourceSection = formFactory.createDescriptionSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-//
-//        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        //             DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
+        //                             .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
+        //                                             getConversationHolder(), parent, Section.TWISTIE);
+        //
+        //             formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         ScopeSection scopeSection = formFactory.createScopeSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
 
@@ -504,10 +587,21 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(descriptionDetailSection);
         addPart(naturalLanguageSection);
         addPart(describedSpecimenSection);
-//        addPart(descriptionSourceSection);
+        //             addPart(descriptionSourceSection);
         addPart(scopeSection);
     }
 
+    /**
+     * createDescriptionSection
+     *
+     * @param parent
+     */
+    private void createSpecimenDescriptionSection(RootElement parent) {
+        destroySections();
+        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(descriptionDetailSection);
+    }
+
     /**
      * Creates the use Description section
      *
@@ -528,6 +622,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     }
 
+
     /**
      * @param rootElement
      */
@@ -546,6 +641,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     private void createMediaElementSection(RootElement parent) {
         destroySections();
+
         MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         addPart(mediaDetailSection);
@@ -556,57 +652,177 @@ public class DetailsViewer extends AbstractCdmDataViewer {
      *
      * @param parent
      */
-    private void createFieldObservationDetailsView(RootElement parent) {
+    private void createDerivedUnitBaseElementSection(RootElement parent) {
         destroySections();
 
-        FieldObservationGeneralSection fieldObservationSection = formFactory.createFieldObservationGeneralSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        //different order of sections (Specimen Details as second section and expanded)
+        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
+            DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            addPart(derivedUnitGeneralDetailSection);
 
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+            OriginalLabelDataSection originalLabelDataSection = formFactory.createOriginalLabelDataSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            addPart(originalLabelDataSection);
 
-        GatheringEventSection gatheringEventDetailSection = formFactory.createGatheringEventSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+            DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            addPart(derivedUnitBaseDetailSection);
+
+        }
+        else{
+            DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            addPart(derivedUnitGeneralDetailSection);
+
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            addPart(gatheringEventDetailSection);
+
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+            FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            addPart(fieldUnitDetailSection);
+
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+            DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            addPart(derivedUnitBaseDetailSection);
+
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            addPart(determinationDetailSection);
+        }
+
+    }
+
+    private void createFieldUnitSection(RootElement parent) {
+        destroySections();
+
+        FieldUnitGeneralDetailSection fielUnitGeneralDetailSection = formFactory.createFieldUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        FieldObservationDetailsSection fieldObservationDetailSection = formFactory.createFieldObservationDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-//        DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-//
-//        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-//
-//        DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
 
-        addPart(fieldObservationSection);
+        addPart(fielUnitGeneralDetailSection);
         addPart(gatheringEventDetailSection);
-        addPart(fieldObservationDetailSection);
-//        addPart(derivedUnitBaseDetailSection);
-//        addPart(determinationDetailSection);
+        addPart(fieldUnitDetailSection);
+
+        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            addPart(determinationDetailSection);
+        }
     }
 
-    /**
-     * createDerivedUnitBaseElementSection
-     *
-     * @param parent
-     */
-    private void createSpecimenDetailsView(RootElement parent) {
+    private void createTissueSampleSection(RootElement parent) {
+        destroySections();
+
+        TissueSampleGeneralDetailSection section = formFactory.createTissueSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        addPart(section);
+        addPart(sampleDesignationDetailSection);
+    }
+
+    private void createDnaSampleSection(RootElement parent) {
+        destroySections();
+
+        DnaSampleGeneralDetailSection section = formFactory.createDnaSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        addPart(section);
+        addPart(qualitySection);
+        addPart(sampleDesignationDetailSection);
+    }
+
+    private void createAmplificationSection(RootElement parent) {
+        destroySections();
+        AmplificationGeneralDetailSection generalSection = formFactory.createAmplificationGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        AmplificationPrimerDetailSection primerSection = formFactory.createAmplificationPrimerDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        AmplificationCloningDetailSection cloningSection = formFactory.createAmplificationCloningDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        AmplificationGelPhotoCollectionDetailSection gelPhotoSection = formFactory.createAmplificationGelPhotoCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+
+        addPart(generalSection);
+        addPart(primerSection);
+        addPart(cloningSection);
+        addPart(gelPhotoSection);
+    }
+
+    private void createSequenceSection(RootElement parent) {
         destroySections();
 
-        SpecimenGeneralSection specimenSection = formFactory.createSpecimenSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        SequenceGeneralDetailSection section = formFactory.createSequenceGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        SpecimenDetailsSection specimenDetailsSection = formFactory.createSpecimenDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        SequenceReferenceCollectionDetailSection referenceSection = formFactory.createSequenceReferenceCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        DerivedUnitDetailsSection derivedUnitDetailsSection = formFactory.createDerivedUnitDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(specimenSection);
-        addPart(specimenDetailsSection);
-        addPart(derivedUnitDetailsSection);
+
+        addPart(section);
+        addPart(referenceSection);
+        addPart(contigFileSection);
     }
 
+    private void createSingleReadSection(RootElement parent) {
+        destroySections();
+
+        SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        addPart(section);
+        addPart(pherogramSection);
+    }
+
+    private void createMediaSpecimenSection(RootElement parent) {
+        destroySections();
+
+        MediaSpecimenGeneralDetailSection generalSection = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(generalSection);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+        addPart(rightsSection);
+
+    }
+
+
+
     /**
      * @param rootElement
      */
@@ -656,6 +872,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         addPart(descriptionUseRecordSection);
 
+
     }
 
     /**
@@ -710,4 +927,5 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         AbstractFormSection definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         addPart(definedTermDetailSection);
     }
+
 }