fix #6050: add the possibility to configure which fields should be displayed in name...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / detail / DetailsViewer.java
index 479adcaac20bca6e62c4c7d0820b2fd6959703e7..48e0899021f0a6ba30c69c8ad7b9e6e5cc139f2c 100644 (file)
@@ -48,6 +48,7 @@ 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.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
 import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
@@ -62,7 +63,6 @@ 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;
@@ -75,7 +75,6 @@ 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.name.NameRelationshipDetailSection;
@@ -90,6 +89,7 @@ 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.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;
@@ -105,6 +105,7 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDe
 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;
@@ -129,7 +130,7 @@ import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
 public class DetailsViewer extends AbstractCdmDataViewer {
 
     private ISelection selection;
-
+    
     public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
         super(parent, viewPart);
     }
@@ -363,50 +364,70 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
                 ExpandableComposite.EXPANDED | ExpandableComposite.EXPANDED);
-
-        TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE     | ExpandableComposite.EXPANDED);
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
-                       ExpandableComposite.TWISTIE | 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);
+               addPart(taxonBaseDetailSection);
+        }else{
+               if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON)){
+                   TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
+                               ExpandableComposite.TWISTIE     | ExpandableComposite.EXPANDED);
+                   formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+       
+                   addPart(taxonBaseDetailSection);
+               }
+        }
+        NonViralNameDetailSection nonViralNameSection = formFactory
+                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
+                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE)){
+            NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            addPart(referenceDetailSection);
+        }
+        if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS)){
+            NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
+            addPart(nomenclaturalStatusSection);
+            
+        }
         //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);
+        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)  ){
+               if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE)){
+                       ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+                       formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+                       addPart(protologSection);
+               }
+               
+               if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION)){
+                       TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+                       formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+                       addPart(typeDesignationSection);
+               }
+               
+               if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP)){
+                       NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+                       formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+                       addPart(nameRelationshipSection);
+               }
         }
 
         addPart(parsingMessagesSection);
-        addPart(taxonBaseDetailSection);
+
         addPart(nonViralNameSection);
-        addPart(nomenclaturalStatusSection);
-        addPart(referenceDetailSection);
+
     }
 
     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,
@@ -495,9 +516,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,
@@ -511,7 +532,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         addPart(descriptionDetailSection);
         addPart(naturalLanguageSection);
-        addPart(describedSpecimenSection);
+//        addPart(describedSpecimenSection);
         //             addPart(descriptionSourceSection);
         addPart(scopeSection);
     }
@@ -577,21 +598,26 @@ public class DetailsViewer extends AbstractCdmDataViewer {
             FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
             addPart(fieldUnitDetailSection);
         }
+        else{
 
+            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);
+            DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(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);
         }
-        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);
+        DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        addPart(derivedUnitTypeDesignationSection);
 
     }
 
@@ -711,7 +737,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
     private void createPolytomousKeyNodeSection(RootElement parent) {
         destroySections();
 
-        PolytomousKeyDetailSection polytomousKeyDetailSection = formFactory.createPolytomousKeyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        PolytomousKeyDetailSection polytomousKeyDetailSection = formFactory.createPolytomousKeyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
@@ -769,4 +795,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(definedTermDetailSection);
     }
 
+       @Override
+       public void update(CdmDataChangeMap arg0) {
+               
+       }
+
 }