Add flag for displaying choose action in name details view #5260
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / detail / DetailsViewer.java
index f8950d456bd55fc2905bb272dc4440ed738b7e90..9924ad799fe36168848e16e77d37eb339ecadcf0 100644 (file)
@@ -22,7 +22,6 @@ 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;
@@ -30,7 +29,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;
@@ -50,7 +48,6 @@ 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;
@@ -58,7 +55,7 @@ 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;
@@ -78,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;
@@ -93,10 +90,10 @@ 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.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;
@@ -133,17 +130,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);
     }
@@ -153,13 +139,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){
@@ -201,11 +180,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() {
@@ -217,7 +192,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);
@@ -241,11 +221,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
             }
             else{
                 Set<Marker> descriptionMarkers = ((DescriptionBase<?>) input).getMarkers();
-                MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
-                        UsageTermCollection.uuidUseMarkerType);
+
                 Boolean isUseDescription = false;
                 for (Marker marker : descriptionMarkers) {
-                    if (marker.getMarkerType().equals(useMarkertype)) {
+                    if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
                         isUseDescription = true;
                     }
                 }
@@ -261,11 +240,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;
                 }
             }
@@ -344,9 +322,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
     }
 
 
-    /**
-     * @param rootElement
-     */
     private void createEmptySection(RootElement parent) {
         destroySections();
 
@@ -355,9 +330,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(emptySection);
     }
 
-    /**
-     * @param rootElement
-     */
     private void createGroupSection(RootElement parent) {
         destroySections();
 
@@ -370,24 +342,12 @@ 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) {
@@ -398,11 +358,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         }
     }
 
-    /**
-     * createTaxonSections(RootElement parent)
-     *
-     * @param parent
-     */
     private void createTaxonSections(RootElement parent) {
         destroySections();
 
@@ -413,8 +368,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                        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, true,
+                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
@@ -441,7 +397,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                        addPart(nameRelationshipSection);
         }
 
-
         addPart(parsingMessagesSection);
         addPart(taxonBaseDetailSection);
         addPart(nonViralNameSection);
@@ -449,15 +404,11 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         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,
@@ -487,11 +438,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         }
     }
 
-    /**
-     * createReferenceSections
-     *
-     * @param parent
-     */
     private void createReferenceSections(RootElement parent) {
         destroySections();
 
@@ -501,11 +447,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(referenceDetailSection);
     }
 
-    /**
-     * createTeamOrPersonBaseDetailSection
-     *
-     * @param parent
-     */
     private void createTeamOrPersonBaseDetailSection(RootElement parent) {
         destroySections();
         TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
@@ -513,11 +454,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);
@@ -525,22 +461,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();
 
@@ -561,11 +487,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);
@@ -597,22 +518,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);
@@ -628,10 +539,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);
@@ -639,12 +546,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(descriptionDetailSection);
     }
 
-    /**
-     * createMediaElementSection
-     *
-     * @param parent
-     */
-
     private void createMediaElementSection(RootElement parent) {
         destroySections();
 
@@ -653,11 +554,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(mediaDetailSection);
     }
 
-    /**
-     * createDerivedUnitBaseElementSection
-     *
-     * @param parent
-     */
     private void createDerivedUnitBaseElementSection(RootElement parent) {
         destroySections();
 
@@ -673,11 +569,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         addPart(derivedUnitBaseDetailSection);
 
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        OriginalLabelDataSection originalLabelDataSection = formFactory.createOriginalLabelDataSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        addPart(originalLabelDataSection);
-
         //for editors working with facades
         if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
             formFactory.createHorizontalSeparator(parent, SWT.BORDER);
@@ -688,17 +579,22 @@ 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);
+            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);
         }
-        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);
-        }
 
     }
 
@@ -746,6 +642,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
+        DnaSamplePreparationPreservationSection preparationPreservationSection = formFactory.createDnaSamplePreparationPreservationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
         DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
@@ -753,6 +653,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
         addPart(section);
+        addPart(preparationPreservationSection);
         addPart(qualitySection);
         addPart(sampleDesignationDetailSection);
     }
@@ -802,11 +703,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     }
 
-
-
-    /**
-     * @param rootElement
-     */
     private void createFeatureDistributionSection(RootElement parent) {
         destroySections();
 
@@ -815,35 +711,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();
 
@@ -856,11 +737,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     }
 
-    /**
-     * createUserSection
-     *
-     * @param parent
-     */
     private void createUserSection(RootElement parent) {
         destroySections();
 
@@ -872,11 +748,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(groupByUserDetailSection);
     }
 
-    /**
-     * createTaxonRelationshipSection
-     *
-     * @param parent
-     */
     private void createTaxonRelationshipSection(RootElement parent) {
         destroySections();
 
@@ -887,9 +758,6 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         addPart(referencedEntityBaseDetailSection);
     }
 
-    /**
-     * @param rootElement
-     */
     private void createTermVocabularySection(RootElement parent) {
         destroySections();
 
@@ -897,15 +765,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);
     }