fix #5953 Save open/close states of detail view sections for specific
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / detail / DetailsViewer.java
index aa0c24e9cd28639b3058e13584f83a0752ca5548..015b385217cf88145a123c3957fe6b1570660cea 100644 (file)
@@ -18,11 +18,13 @@ 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.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
 import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
 
 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;
@@ -30,7 +32,6 @@ 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;
@@ -39,7 +40,6 @@ import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 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;
@@ -51,20 +51,20 @@ 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;
 import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
@@ -79,7 +79,6 @@ import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
 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;
@@ -92,27 +91,23 @@ 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.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.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.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.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
 import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
@@ -137,18 +132,7 @@ import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
 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);
     }
@@ -158,13 +142,6 @@ 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 TreeNode){
@@ -206,11 +183,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() {
@@ -222,7 +195,12 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         destroySections();
         if (input instanceof TaxonBase) {
-            createTaxonSections(rootElement);
+            if(((TaxonBase) input).getName()==null){
+                createEmptySection(rootElement);
+            }
+            else{
+                createTaxonSections(rootElement);
+            }
 
         } else if (input instanceof NonViralName) {
             createNameSections(rootElement);
@@ -245,16 +223,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) {
@@ -266,11 +243,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;
                 }
             }
@@ -286,34 +262,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.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 Amplification){
-            createAmplificationSection(rootElement);
-        }
         else if(input instanceof Sequence){
             createSequenceSection(rootElement);
         }
@@ -343,9 +325,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
     }
 
 
-    /**
-     * @param rootElement
-     */
     private void createEmptySection(RootElement parent) {
         destroySections();
 
@@ -354,9 +333,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(emptySection);
     }
 
-    /**
-     * @param rootElement
-     */
     private void createGroupSection(RootElement parent) {
         destroySections();
 
@@ -364,29 +340,17 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         MemberDetailSection memberDetailSection = formFactory.createMemberDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         GrantedAuthorityDetailSection grantedAuthorityDetailSection = formFactory.createGrantedAuthorityDetailSection(getConversationHolder(), parent,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(groupDetailSection);
-        addPart(memberDetailSection);
-        addPart(grantedAuthorityDetailSection);
+        addPart(groupDetailSection, true);
+        addPart(memberDetailSection, true);
+        addPart(grantedAuthorityDetailSection, true);
     }
 
-    /*
-     * (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) {
@@ -397,32 +361,36 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         }
     }
 
-    /**
-     * createTaxonSections(RootElement parent)
-     *
-     * @param parent
-     */
     private void createTaxonSections(RootElement parent) {
         destroySections();
 
-        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);
+        ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
+                ExpandableComposite.EXPANDED | ExpandableComposite.EXPANDED);
+        if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
+            TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE     | ExpandableComposite.EXPANDED);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            addPart(taxonBaseDetailSection, true);
+        }
+        NonViralNameDetailSection nonViralNameSection = formFactory
+                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
+                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
+            NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
+            addPart(nomenclaturalStatusSection, true);
+            addPart(referenceDetailSection, true);
+        }
         //TODO RL
-        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)  && !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
                ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
@@ -432,30 +400,22 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-                       addPart(protologSection);
-                       addPart(typeDesignationSection);
-                       addPart(nameRelationshipSection);
+                       addPart(protologSection, false);
+                       addPart(typeDesignationSection, false);
+                       addPart(nameRelationshipSection, false);
         }
 
-        ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.EXPANDED | ExpandableComposite.EXPANDED);
+        addPart(parsingMessagesSection, true);
+
+        addPart(nonViralNameSection, true);
 
-        addPart(taxonBaseDetailSection);
-        addPart(nonViralNameSection);
-        addPart(nomenclaturalStatusSection);
-        addPart(parsingMessagesSection);
-        addPart(referenceDetailSection);
     }
 
-    /**
-     * createNameSections
-     *
-     * @param parent
-     */
     private void createNameSections(RootElement parent) {
         destroySections();
-        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(
+                getConversationHolder(), parent, this, false, ExpandableComposite.TWISTIE
+                        | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
@@ -466,9 +426,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        addPart(nonViralNameSection);
-        addPart(nomenclaturalStatusSection);
-        addPart(referenceDetailSection);
+        addPart(nonViralNameSection, true);
+        addPart(nomenclaturalStatusSection, true);
+        addPart(referenceDetailSection, true);
 //TODO RL
         if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
                        ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
@@ -479,66 +439,41 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
                NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-               addPart(protologSection);
-               addPart(typeDesignationSection);
-               addPart(nameRelationshipSection);
+               addPart(protologSection, false);
+               addPart(typeDesignationSection, false);
+               addPart(nameRelationshipSection, false);
         }
     }
 
-    /**
-     * createReferenceSections
-     *
-     * @param parent
-     */
     private void createReferenceSections(RootElement parent) {
         destroySections();
 
         ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this,
                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(referenceDetailSection);
+        addPart(referenceDetailSection, true);
     }
 
-    /**
-     * createTeamOrPersonBaseDetailSection
-     *
-     * @param parent
-     */
     private void createTeamOrPersonBaseDetailSection(RootElement parent) {
         destroySections();
         TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(teamOrPersonBaseDetailSection);
+        addPart(teamOrPersonBaseDetailSection, true);
     }
 
-    /**
-     * createTeamDetailSection
-     *
-     * @param parent
-     */
     private void createTeamDetailSection(RootElement parent) {
         destroySections();
         TeamDetailSection teamDetailSection = formFactory.createTeamDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(teamDetailSection);
+        addPart(teamDetailSection, true);
     }
 
-    /**
-     * createPersonDetailSection
-     *
-     * @param parent
-     */
     private void createPersonDetailSection(RootElement parent) {
         destroySections();
         PersonDetailSection personDetailSection = formFactory.createPersonDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        addPart(personDetailSection);
+        addPart(personDetailSection, true);
     }
 
-    /**
-     * createDescriptionElementSection
-     *
-     * @param parent
-     */
     private void createDescriptionElementSection(RootElement parent) {
         destroySections();
 
@@ -554,16 +489,11 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        addPart(descriptionElementDetailSection);
-        addPart(descriptionElementSourceSection);
-        addPart(descriptionElementMediaSection);
+        addPart(descriptionElementDetailSection, true);
+        addPart(descriptionElementSourceSection, false);
+        addPart(descriptionElementMediaSection, false);
     }
 
-    /**
-     * createDescriptionSection
-     *
-     * @param parent
-     */
     private void createDescriptionSection(RootElement parent) {
         destroySections();
         DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
@@ -574,9 +504,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        DescribedSpecimenSection describedSpecimenSection = formFactory.createDescribedSpecimenSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+//        DescribedSpecimenSection describedSpecimenSection = formFactory.createDescribedSpecimenSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+//
+//        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         //             DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
         //                             .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
@@ -588,29 +518,19 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        addPart(descriptionDetailSection);
-        addPart(naturalLanguageSection);
-        addPart(describedSpecimenSection);
+        addPart(descriptionDetailSection, true);
+        addPart(naturalLanguageSection, true);
+//        addPart(describedSpecimenSection);
         //             addPart(descriptionSourceSection);
-        addPart(scopeSection);
+        addPart(scopeSection, false);
     }
 
-    /**
-     * createDescriptionSection
-     *
-     * @param parent
-     */
     private void createSpecimenDescriptionSection(RootElement parent) {
         destroySections();
         DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        addPart(descriptionDetailSection);
+        addPart(descriptionDetailSection, true);
     }
 
-    /**
-     * Creates the use Description section
-     *
-     * @param parent
-     */
     private void createUseDescriptionSection(RootElement parent) {
         destroySections();
         DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
@@ -621,94 +541,72 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        addPart(descriptionDetailSection);
-        addPart(descriptionSourceSection);
+        addPart(descriptionDetailSection, true);
+        addPart(descriptionSourceSection, true);
 
     }
 
-
-    /**
-     * @param rootElement
-     */
     private void createImageGallerySection(RootElement parent) {
         destroySections();
         DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(descriptionDetailSection);
+        addPart(descriptionDetailSection, true);
     }
 
-    /**
-     * createMediaElementSection
-     *
-     * @param parent
-     */
-
     private void createMediaElementSection(RootElement parent) {
         destroySections();
 
         MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(mediaDetailSection);
+        addPart(mediaDetailSection, true);
     }
 
-    /**
-     * createDerivedUnitBaseElementSection
-     *
-     * @param parent
-     */
     private void createDerivedUnitBaseElementSection(RootElement parent) {
         destroySections();
 
-        //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);
-
-            DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-            addPart(derivedUnitBaseDetailSection);
+        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, true);
 
-            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-            OriginalLabelDataSection originalLabelDataSection = formFactory.createOriginalLabelDataSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-            addPart(originalLabelDataSection);
+        DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(derivedUnitBaseDetailSection, true);
 
+        //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);
+            addPart(gatheringEventDetailSection, false);
 
             formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
             FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-            addPart(fieldUnitDetailSection);
+            addPart(fieldUnitDetailSection, false);
         }
         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);
 
+            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, true);
+            }
             formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-            DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
-            addPart(derivedUnitBaseDetailSection);
-
+            DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+            addPart(identifierDetailSection, false);
+        }
+        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);
+            addPart(determinationDetailSection, false);
         }
 
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        addPart(derivedUnitTypeDesignationSection, false);
+
     }
 
     private void createFieldUnitSection(RootElement parent) {
@@ -724,41 +622,28 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
 
-        addPart(fielUnitGeneralDetailSection);
-        addPart(gatheringEventDetailSection);
-        addPart(fieldUnitDetailSection);
+        addPart(fielUnitGeneralDetailSection, true);
+        addPart(gatheringEventDetailSection, false);
+        addPart(fieldUnitDetailSection, false);
 
         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);
+            addPart(determinationDetailSection, false);
         }
     }
 
-    private void createPreservedSpecimenSpecimenSection(RootElement parent) {
+    private void createTissueSampleSection(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);
+        TissueSampleGeneralDetailSection section = formFactory.createTissueSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        PreservedSpecimenDeterminationDetailSection determinationDetailSection = formFactory.createPreservedSpecimenDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(section);
-        addPart(derivedUnitBaseDetailSection);
-        addPart(determinationDetailSection);
-    }
-
-    private void createTissueSampleSection(RootElement parent) {
-        destroySections();
-
-        TissueSampleGeneralDetailSection section = formFactory.createTissueSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-
-        addPart(section);
+        addPart(section, true);
+        addPart(sampleDesignationDetailSection, true);
     }
 
     private void createDnaSampleSection(RootElement parent) {
@@ -768,33 +653,20 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-
-        addPart(section);
-        addPart(qualitySection);
-    }
-
-    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 | ExpandableComposite.EXPANDED);
-
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        AmplificationCloningDetailSection cloningSection = formFactory.createAmplificationCloningDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        AmplificationGelPhotoCollectionDetailSection gelPhotoSection = formFactory.createAmplificationGelPhotoCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-
+        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(generalSection);
-        addPart(primerSection);
-        addPart(cloningSection);
-        addPart(gelPhotoSection);
+        addPart(section, true);
+        addPart(preparationPreservationSection, true);
+        addPart(qualitySection, true);
+        addPart(sampleDesignationDetailSection, true);
     }
 
     private void createSequenceSection(RootElement parent) {
@@ -811,87 +683,59 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
 
-        addPart(section);
-        addPart(referenceSection);
-        addPart(contigFileSection);
+        addPart(section, true);
+        addPart(referenceSection, true);
+        addPart(contigFileSection, true);
     }
 
     private void createSingleReadSection(RootElement parent) {
         destroySections();
 
         SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(section, true);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(pherogramSection, true);
 
-        addPart(section);
-        addPart(pherogramSection);
     }
 
-    private void createSpecimenScanSection(RootElement parent) {
+    private void createMediaSpecimenSection(RootElement parent) {
         destroySections();
-        SpecimenScanGeneralDetailSection section = formFactory.createSpecimenScanGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(section);
-    }
-
-    private void createLivingPlantPhotoSection(RootElement parent) {
-        destroySections();
-        LivingPlantPhotoGeneralDetailSection section = formFactory.createLivingPlantPhotoGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        MediaSpecimenGeneralDetailSection generalSection = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(generalSection, true);
 
-        addPart(section);
-    }
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-    private void createMediaSpecimenSection(RootElement parent) {
-        destroySections();
-        MediaSpecimenGeneralDetailSection section = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+        addPart(rightsSection, false);
 
-        addPart(section);
     }
 
-
-
-    /**
-     * @param rootElement
-     */
     private void createFeatureDistributionSection(RootElement parent) {
         destroySections();
 
         FeatureDistributionDetailSection featureDistributionSection = formFactory.createFeatureDistributionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(featureDistributionSection);
+        addPart(featureDistributionSection, true);
     }
 
-    /**
-     * 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);
+        addPart(polytomousKeyDetailSection, true);
+        addPart(polytomousKeyNodeDetailSection, true);
 
     }
 
-    /**
-     * create the UseRecordSection
-     *
-     * @param parent
-     */
     private void createUseRecordSection(RootElement parent) {
         destroySections();
 
@@ -899,16 +743,11 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        addPart(descriptionUseRecordSection);
+        addPart(descriptionUseRecordSection, true);
 
 
     }
 
-    /**
-     * createUserSection
-     *
-     * @param parent
-     */
     private void createUserSection(RootElement parent) {
         destroySections();
 
@@ -916,45 +755,59 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         GroupsByUserDetailSection groupByUserDetailSection = formFactory.createGroupsByUserDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        addPart(userDetailSection);
-        addPart(groupByUserDetailSection);
+        addPart(userDetailSection, true);
+        addPart(groupByUserDetailSection, true);
     }
 
-    /**
-     * createTaxonRelationshipSection
-     *
-     * @param parent
-     */
     private void createTaxonRelationshipSection(RootElement parent) {
         destroySections();
 
         TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        addPart(taxonRelationshipDetailSection);
-        addPart(referencedEntityBaseDetailSection);
+        addPart(taxonRelationshipDetailSection, true);
+        addPart(referencedEntityBaseDetailSection, true);
     }
 
-    /**
-     * @param rootElement
-     */
     private void createTermVocabularySection(RootElement parent) {
         destroySections();
 
         TermVocabularyDetailSection termVocabularyDetailSection = formFactory.createTermVocabularyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        addPart(termVocabularyDetailSection);
+        addPart(termVocabularyDetailSection, true);
     }
 
-    /**
-     * createDefinedTermSection
-     *
-     * @param parent
-     */
     private void createDefinedTermSection(RootElement parent) {
         destroySections();
 
-        AbstractFormSection definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        addPart(definedTermDetailSection);
+        AbstractFormSection<?> definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        addPart(definedTermDetailSection, true);
+    }
+    
+       protected void addPart(AbstractFormSection section, boolean isDefaultExpanded){
+               super.addPart(section);
+               PreferencesUtil.getPreferenceStore().setDefault(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName(), isDefaultExpanded);
+               section.setExpanded(PreferencesUtil.getPreferenceStore().getBoolean(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName()));
+               section.addExpansionListener(new ExpandListener(section));
+       }
+    
+    private class ExpandListener implements IExpansionListener{
+       
+       private Section section;
+       
+               public ExpandListener(Section section) {
+                       super();
+                       this.section = section;
+               }
+
+               @Override
+               public void expansionStateChanging(ExpansionEvent e) {
+               }
+
+               @Override
+               public void expansionStateChanged(ExpansionEvent e) {
+                       PreferencesUtil.getPreferenceStore().setValue(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName(), e.getState());
+               }
+       
     }
 
 }