Avoid exception loop when taxon name is null (#4996)
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 1 Sep 2015 09:15:17 +0000 (11:15 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 1 Sep 2015 09:17:01 +0000 (11:17 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java

index cdea34cae093fc32a2205a60e9fabb70c006ce4d..1213418a592094bbbe9977831a7c19553513e8a0 100644 (file)
@@ -46,39 +46,32 @@ public class NonViralNameDetailElement extends
        /** {@inheritDoc} */
        @Override
     protected void createControls(ICdmFormElement formElement, final NonViralName entity, int style) {
        /** {@inheritDoc} */
        @Override
     protected void createControls(ICdmFormElement formElement, final NonViralName entity, int style) {
-           //name can be null in rare cases. Temporary solution for #4221. May be obsolete when
-           //#4393 (Make changing name of a taxon possible in details view) is implemented.
-           if(entity==null){
-               formFactory.createEmptyElement(formElement, "No name associated with this taxon.");
+           toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
+
+           combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
+           combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
+
+           //TODO RL
+           if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+               toggleable_cache.setVisible(false);
+               combo_nomenclaturalCode.setVisible(false);
            }
            }
-           else {
-               toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
-
-               combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
-               combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
-
-               //TODO RL
-               if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
-                   toggleable_cache.setVisible(false);
-                   combo_nomenclaturalCode.setVisible(false);
-               }
-
-               section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-               section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-               addControl(section_name);
-               addElement(section_name);
-               section_author = formFactory.createAuthorshipDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-               section_author.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-               addControl(section_author);
-               addElement(section_author);
-
-               //TODO RL
-               if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
-                   section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
-                   section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-                   addControl(section_hybrid);
-                   addElement(section_hybrid);
-               }
+
+           section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+           section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+           addControl(section_name);
+           addElement(section_name);
+           section_author = formFactory.createAuthorshipDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+           section_author.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+           addControl(section_author);
+           addElement(section_author);
+
+           //TODO RL
+           if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+               section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
+               section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+               addControl(section_hybrid);
+               addElement(section_hybrid);
            }
     }
 
            }
     }
 
index 04bb9207f815a4499f01a543ce4c244d61ee157c..4856e3ff7f3ef99b55c64f1914f782c6273d5368 100644 (file)
@@ -204,7 +204,12 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         destroySections();
         if (input instanceof TaxonBase) {
 
         destroySections();
         if (input instanceof TaxonBase) {
-            createTaxonSections(rootElement);
+            if(((TaxonBase) input).getName()==null){
+                createEmptySection(rootElement);
+            }
+            else{
+                createTaxonSections(rootElement);
+            }
 
         } else if (input instanceof NonViralName) {
             createNameSections(rootElement);
 
         } else if (input instanceof NonViralName) {
             createNameSections(rootElement);