Do not expand type designation section automatically
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / detail / DetailsViewer.java
index 66df6fabd6f7ba657044335d7a1e783d92a2a9e5..aa63bfbf3d72737b1f8391c9cc22ac56d375d9a4 100644 (file)
@@ -15,30 +15,28 @@ 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;
 
 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;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.cdm.model.common.Marker;
-import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.common.TermVocabulary;
 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;
@@ -50,13 +48,14 @@ 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.IDerivedUnitFacadePart;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 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.store.UsageTermCollection;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.RootElement;
 import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
@@ -76,9 +75,9 @@ import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSectio
 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
 import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
 import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
@@ -91,21 +90,22 @@ 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.derivedUnit.PreservedSpecimenDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenDeterminationDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenGeneralDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AmplificationCloningDetailSection;
-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.association.DerivedUnitTypeDesignationSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
+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.DnaSamplePreparationPreservationSection;
+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.LivingPlantPhotoGeneralDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.occurrence.media.SpecimenScanGeneralDetailSection;
 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;
@@ -131,17 +131,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     private ISelection selection;
 
-    /**
-     * <p>
-     * Constructor for DetailsViewer.
-     * </p>
-     *
-     * @param parent
-     *            a {@link org.eclipse.swt.widgets.Composite} object.
-     * @param viewPart
-     *            a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart}
-     *            object.
-     */
     public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
         super(parent, viewPart);
     }
@@ -151,24 +140,21 @@ public class DetailsViewer extends AbstractCdmDataViewer {
     // editor
     // and not derived unit facade objects,
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * eu.etaxonomy.taxeditor.editor.view.AbstractCdmDataViewer#setInput(java
-     * .lang.Object)
-     */
     @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;
-            if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.BULK_EDITOR_AVOID_FACADE)){
-                try {
-                    input = DerivedUnitFacade.NewInstance(derivedUnit,
-                            PreferencesUtil.getDerivedUnitConfigurator());
-                } catch (DerivedUnitFacadeNotSupportedException e) {
-                    AbstractUtility.error(getClass(), e);
-                }
+            try {
+                input = DerivedUnitFacade.NewInstance(derivedUnit,
+                        PreferencesUtil.getDerivedUnitConfigurator());
+            } catch (DerivedUnitFacadeNotSupportedException 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){
@@ -195,11 +181,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     // END HACK TO MAKE THE DERIVED UNIT FACADE WORK
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.eclipse.jface.viewers.Viewer#refresh()
-     */
+
     /** {@inheritDoc} */
     @Override
     protected void showParts() {
@@ -211,7 +193,12 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         destroySections();
         if (input instanceof TaxonBase) {
-            createTaxonSections(rootElement, (TaxonBase) input);
+            if(((TaxonBase) input).getName()==null){
+                createEmptySection(rootElement);
+            }
+            else{
+                createTaxonSections(rootElement);
+            }
 
         } else if (input instanceof NonViralName) {
             createNameSections(rootElement);
@@ -234,16 +221,15 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                 createSpecimenDescriptionSection(rootElement);
             }
             else{
-                Set<Marker> descriptionMarkers = ((DescriptionBase) input).getMarkers();
-                MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
-                        UsageTermCollection.uuidUseMarkerType);
+                Set<Marker> descriptionMarkers = ((DescriptionBase<?>) input).getMarkers();
+
                 Boolean isUseDescription = false;
                 for (Marker marker : descriptionMarkers) {
-                    if (marker.getMarkerType().equals(useMarkertype)) {
+                    if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
                         isUseDescription = true;
                     }
                 }
-                if (((DescriptionBase) input).isImageGallery()) {
+                if (((DescriptionBase<?>) input).isImageGallery()) {
                     createImageGallerySection(rootElement);
 
                 } else if (isUseDescription) {
@@ -255,11 +241,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
             }
         } else if (input instanceof DescriptionElementBase) {
             Set<Marker> descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers();
-            MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
-                    UsageTermCollection.uuidUseMarkerType);
+
             Boolean isUseDescription = false;
             for (Marker marker : descriptionMarkers) {
-                if (marker.getMarkerType().equals(useMarkertype)) {
+                if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
                     isUseDescription = true;
                 }
             }
@@ -275,53 +260,40 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         } else if (input instanceof DerivedUnitFacade) {
             if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.FieldUnit){
-                createFieldUnitSection(rootElement);
+                if(((DerivedUnitFacade) input).innerFieldUnit()==null){
+                    MessagingUtils.error(DetailsViewer.class, "FieldUnit of facade is null", null);
+                }
+                else{
+                    createFieldUnitSection(rootElement);
+                }
             }
             else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.PreservedSpecimen){
-                createDerivedUnitBaseElementSection(rootElement);
+                if(((DerivedUnitFacade) input).innerDerivedUnit()==null){
+                    MessagingUtils.error(DetailsViewer.class, "DerivedUnit of facade is null", null);
+                }
+                else{
+                    createDerivedUnitBaseElementSection(rootElement);
+                }
             }
             else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.TissueSample){
-                createTissueSampleSection(rootElement);
-            }
-            //            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.DnaSample){
-            //                createDnaSampleSection(rootElement);
-            //            }
-            //FIXME: change to specific SpecimenOrObservationType
-            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.StillImage){
-                createSpecimenScanSection(rootElement);
-            }
-            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.StillImage){
-                createLivingPlantPhotoSection(rootElement);
-            }
-            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.StillImage){
-                createMediaSpecimenSection(rootElement);
+                //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){
-            createDnaSampleSection(rootElement);
+            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 SpecimenOrObservationBase){
-//            SpecimenOrObservationType recordBasis = ((SpecimenOrObservationBase<?>) input).getRecordBasis();
-//            if(recordBasis==SpecimenOrObservationType.PreservedSpecimen){
-//                createPreservedSpecimenSpecimenSection(rootElement);
-//            }
-//            else if(recordBasis==SpecimenOrObservationType.FieldUnit){
-//                createFieldUnitSection(rootElement);
-//            }
-//            else if(recordBasis==SpecimenOrObservationType.DnaSample){
-//                createDnaSampleSection(rootElement);
-//            }
-//            else if(recordBasis.isKindOf(SpecimenOrObservationType.Media)){
-//                createMediaSpecimenSection(rootElement);
-//            }
-//        }
-        else if(input instanceof Amplification){
-            createAmplificationSection(rootElement);
-        }
         else if(input instanceof Sequence){
             createSequenceSection(rootElement);
         }
@@ -331,10 +303,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         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);
@@ -347,16 +316,13 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         } else if (input instanceof DefinedTermBase) {
             createDefinedTermSection(rootElement);
         }
-        if(managedForm.getParts().length==0) {
+        else {
             createEmptySection(rootElement);
         }
         layout();
     }
 
 
-    /**
-     * @param rootElement
-     */
     private void createEmptySection(RootElement parent) {
         destroySections();
 
@@ -365,9 +331,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(emptySection);
     }
 
-    /**
-     * @param rootElement
-     */
     private void createGroupSection(RootElement parent) {
         destroySections();
 
@@ -380,148 +343,109 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(grantedAuthorityDetailSection);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.eclipse.jface.viewers.Viewer#getSelection()
-     */
     /** {@inheritDoc} */
     @Override
     public ISelection getSelection() {
         return selection;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers
-     * .ISelection, boolean)
-     */
     /** {@inheritDoc} */
     @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);
+        }
     }
 
-    /**
-     * createTaxonSections(RootElement parent)
-     *
-     * @param parent
-     */
-    private void createTaxonSections(RootElement parent, TaxonBase taxonBase) {
+    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);
-
+        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);
-
+        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,ExpandableComposite.TWISTIE);
-
+        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        ProtologueSection protologSection = formFactory.createProtologueSection(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);
+               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);
-
-//        SynonymRelationshipDetailSection synonymRelationshipSection = null;
-//        if(taxonBase instanceof Synonym){
-//            synonymRelationshipSection = formFactory.createSynonymRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-//
-//            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-//        }
-
-        ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this, ExpandableComposite.EXPANDED);
+                       addPart(protologSection);
+                       addPart(typeDesignationSection);
+                       addPart(nameRelationshipSection);
+        }
 
+        addPart(parsingMessagesSection);
         addPart(taxonBaseDetailSection);
         addPart(nonViralNameSection);
         addPart(nomenclaturalStatusSection);
-        addPart(protologSection);
         addPart(referenceDetailSection);
-        addPart(typeDesignationSection);
-        addPart(nameRelationshipSection);
-//        if(synonymRelationshipSection!=null){
-//            addPart(synonymRelationshipSection);
-//        }
-        addPart(parsingMessagesSection);
     }
 
-    /**
-     * createNameSections
-     *
-     * @param parent
-     */
     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);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
+        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
+        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         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);
+        }
     }
 
-    /**
-     * createReferenceSections
-     *
-     * @param parent
-     */
     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);
     }
 
-    /**
-     * createTeamOrPersonBaseDetailSection
-     *
-     * @param parent
-     */
     private void createTeamOrPersonBaseDetailSection(RootElement parent) {
         destroySections();
         TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
@@ -529,11 +453,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(teamOrPersonBaseDetailSection);
     }
 
-    /**
-     * createTeamDetailSection
-     *
-     * @param parent
-     */
     private void createTeamDetailSection(RootElement parent) {
         destroySections();
         TeamDetailSection teamDetailSection = formFactory.createTeamDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
@@ -541,22 +460,12 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(teamDetailSection);
     }
 
-    /**
-     * createPersonDetailSection
-     *
-     * @param parent
-     */
     private void createPersonDetailSection(RootElement parent) {
         destroySections();
         PersonDetailSection personDetailSection = formFactory.createPersonDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         addPart(personDetailSection);
     }
 
-    /**
-     * createDescriptionElementSection
-     *
-     * @param parent
-     */
     private void createDescriptionElementSection(RootElement parent) {
         destroySections();
 
@@ -577,11 +486,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(descriptionElementMediaSection);
     }
 
-    /**
-     * createDescriptionSection
-     *
-     * @param parent
-     */
     private void createDescriptionSection(RootElement parent) {
         destroySections();
         DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
@@ -613,22 +517,12 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         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
-     *
-     * @param parent
-     */
     private void createUseDescriptionSection(RootElement parent) {
         destroySections();
         DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
@@ -644,10 +538,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     }
 
-
-    /**
-     * @param rootElement
-     */
     private void createImageGallerySection(RootElement parent) {
         destroySections();
         DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
@@ -655,12 +545,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(descriptionDetailSection);
     }
 
-    /**
-     * createMediaElementSection
-     *
-     * @param parent
-     */
-
     private void createMediaElementSection(RootElement parent) {
         destroySections();
 
@@ -669,37 +553,51 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(mediaDetailSection);
     }
 
-    /**
-     * createDerivedUnitBaseElementSection
-     *
-     * @param parent
-     */
     private void createDerivedUnitBaseElementSection(RootElement parent) {
         destroySections();
 
         DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
+        if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
+            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
+        }
+        addPart(derivedUnitGeneralDetailSection);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(derivedUnitBaseDetailSection);
 
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        //for editors working with facades
+        if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            addPart(gatheringEventDetailSection);
 
-        FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            addPart(fieldUnitDetailSection);
+        }
+        else{
 
-        DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+            if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS)){
+                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+                TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+                addPart(taxonAssociationDetailSection);
+            }
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            IdentifierDetailSection identifierDetailSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+            addPart(identifierDetailSection);
+        }
+        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);
+        }
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-
-        addPart(derivedUnitGeneralDetailSection);
-        addPart(gatheringEventDetailSection);
-        addPart(fieldUnitDetailSection);
-        addPart(derivedUnitBaseDetailSection);
-        addPart(determinationDetailSection);
+        DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        addPart(derivedUnitTypeDesignationSection);
 
     }
 
@@ -719,24 +617,12 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(fielUnitGeneralDetailSection);
         addPart(gatheringEventDetailSection);
         addPart(fieldUnitDetailSection);
-    }
-
-    private void createPreservedSpecimenSpecimenSection(RootElement parent) {
-        destroySections();
-
-        PreservedSpecimenGeneralDetailSection section = formFactory.createPreservedSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        PreservedSpecimenDetailSection derivedUnitBaseDetailSection = formFactory.createPreservedSpecimenDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        PreservedSpecimenDeterminationDetailSection determinationDetailSection = formFactory.createPreservedSpecimenDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-
-        addPart(section);
-        addPart(derivedUnitBaseDetailSection);
-        addPart(determinationDetailSection);
+        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);
+        }
     }
 
     private void createTissueSampleSection(RootElement parent) {
@@ -744,74 +630,82 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         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);
 
-        addPart(section);
-    }
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-    private void createAmplificationSection(RootElement parent) {
-        destroySections();
-        AmplificationGeneralDetailSection generalSection = formFactory.createAmplificationGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        DnaSamplePreparationPreservationSection preparationPreservationSection = formFactory.createDnaSamplePreparationPreservationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        AmplificationPrimerDetailSection primerSection = formFactory.createAmplificationPrimerDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        AmplificationCloningDetailSection cloningSection = formFactory.createAmplificationCloningDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-
-        addPart(generalSection);
-        addPart(primerSection);
-        addPart(cloningSection);
+        addPart(section);
+        addPart(preparationPreservationSection);
+        addPart(qualitySection);
+        addPart(sampleDesignationDetailSection);
     }
 
     private void createSequenceSection(RootElement parent) {
         destroySections();
+
         SequenceGeneralDetailSection section = formFactory.createSequenceGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(section);
-    }
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-    private void createSingleReadSection(RootElement parent) {
-        destroySections();
-        SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        SequenceReferenceCollectionDetailSection referenceSection = formFactory.createSequenceReferenceCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(section);
-    }
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-    private void createSpecimenScanSection(RootElement parent) {
-        destroySections();
-        SpecimenScanGeneralDetailSection section = formFactory.createSpecimenScanGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         addPart(section);
+        addPart(referenceSection);
+        addPart(contigFileSection);
     }
 
-    private void createLivingPlantPhotoSection(RootElement parent) {
+    private void createSingleReadSection(RootElement parent) {
         destroySections();
-        LivingPlantPhotoGeneralDetailSection section = formFactory.createLivingPlantPhotoGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
+        SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         addPart(section);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(pherogramSection);
+
     }
 
     private void createMediaSpecimenSection(RootElement parent) {
         destroySections();
-        MediaSpecimenGeneralDetailSection section = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(section);
-    }
+        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
-     */
     private void createFeatureDistributionSection(RootElement parent) {
         destroySections();
 
@@ -820,35 +714,20 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(featureDistributionSection);
     }
 
-    /**
-     * createPolytomousKeyNodeSection
-     *
-     * @param parent
-     */
     private void createPolytomousKeyNodeSection(RootElement parent) {
         destroySections();
 
-        PolytomousKeyDetailSection polytomousKeyDetailSection = formFactory.createPolytomousKeyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT);
+        PolytomousKeyDetailSection polytomousKeyDetailSection = formFactory.createPolytomousKeyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        TaxonomicScopeSection taxonomicScopeSection = formFactory.createTaxonomicScopeSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT);
-
         addPart(polytomousKeyDetailSection);
         addPart(polytomousKeyNodeDetailSection);
-        addPart(taxonomicScopeSection);
 
     }
 
-    /**
-     * create the UseRecordSection
-     *
-     * @param parent
-     */
     private void createUseRecordSection(RootElement parent) {
         destroySections();
 
@@ -861,11 +740,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     }
 
-    /**
-     * createUserSection
-     *
-     * @param parent
-     */
     private void createUserSection(RootElement parent) {
         destroySections();
 
@@ -877,11 +751,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(groupByUserDetailSection);
     }
 
-    /**
-     * createTaxonRelationshipSection
-     *
-     * @param parent
-     */
     private void createTaxonRelationshipSection(RootElement parent) {
         destroySections();
 
@@ -892,9 +761,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(referencedEntityBaseDetailSection);
     }
 
-    /**
-     * @param rootElement
-     */
     private void createTermVocabularySection(RootElement parent) {
         destroySections();
 
@@ -902,15 +768,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(termVocabularyDetailSection);
     }
 
-    /**
-     * createDefinedTermSection
-     *
-     * @param parent
-     */
     private void createDefinedTermSection(RootElement parent) {
         destroySections();
 
-        AbstractFormSection definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        AbstractFormSection<?> definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         addPart(definedTermDetailSection);
     }