ref #9762: handle cultivars correctly in tax editor
authorKatja Luther <k.luther@bgbm.org>
Fri, 17 Sep 2021 08:56:43 +0000 (10:56 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 17 Sep 2021 08:56:43 +0000 (10:56 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java

index a3b47b4ad0a2a564b2c3b0d08a0dc3cfa2e59a5a..b95b1e8039455e2a86eb9b44b819ec138b6abed3 100644 (file)
@@ -8,7 +8,9 @@
 */
 package eu.etaxonomy.taxeditor.ui.section.name;
 
+import java.util.ArrayList;
 import java.util.Comparator;
+import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.eclipse.swt.SWT;
@@ -56,6 +58,7 @@ public class NameDetailElement
        private TextWithLabelElement text_infraspecificEpithet;
        private CheckboxElement checkbox_anamorphic;
        private TextWithLabelElement text_cultivarName;
+       private TextWithLabelElement text_cultivarGroup;
        private TextWithLabelElement text_subGenusAuthorship;
        private TextWithLabelElement text_breed;
 
@@ -123,7 +126,7 @@ public class NameDetailElement
            for (ICdmFormElement element: this.getElements()){
                element.setBackground(getPersistentBackground());
            }
-
+           ((NameDetailSection)this.getParentElement()).layout();
            //cache relevance
         registerCacheRelevance(combo_rank);
         //TODO decide if relevant
@@ -200,7 +203,9 @@ public class NameDetailElement
                 logger.warn("NonViral not yet implemented");
                 break;
             }
+
                }
+
        }
 
        private void createBacterialNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style) {
@@ -212,7 +217,19 @@ public class NameDetailElement
 
        private void createCultivarNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style) {
                ICultivarPlantName cultivarName = (ICultivarPlantName)nonViralName;
-               text_cultivarName = formFactory.createTextWithLabelElement(formElement, "Cultivar Name", cultivarName.getCultivarEpithet(), style);
+               List<Rank> cultivarRanks = new ArrayList<>();
+               cultivarRanks.add(Rank.CULTIVAR());
+               cultivarRanks.add(Rank.CULTIVARGROUP());
+               cultivarRanks.add(Rank.GREX());
+
+               combo_rank.setTerms(cultivarRanks);
+
+               if (cultivarName.getRank().equals(Rank.CULTIVAR()) || cultivarName.getRank().equals(Rank.CULTIVARGROUP())){
+                   text_cultivarName = formFactory.createTextWithLabelElement(formElement, "Cultivar Name", cultivarName.getCultivarEpithet(), style);
+               }
+               if(cultivarName.getRank().equals(Rank.CULTIVARGROUP())){
+                   text_cultivarGroup = formFactory.createTextWithLabelElement(formElement, "Cultivar Group", cultivarName.getCultivarGroupEpithet(), style);
+               }
        }
 
        private void createBotanicalNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){
@@ -273,9 +290,9 @@ public class NameDetailElement
                        clearCheckRankWarnings();
                        updateContent();
 
-                       ((NameDetailSection)this.getParentElement()).layout(true, true);
+//                     ((NameDetailSection)this.getParentElement()).layout(true, true);
             //this is needed for the "new" wizards in order to redraw correctly
-//            StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
+
                }
                else if(eventSource == text_appendedPhrase){
                        getEntity().setAppendedPhrase(text_appendedPhrase.getText());
@@ -298,6 +315,8 @@ public class NameDetailElement
             ((IZoologicalName)getEntity()).setBreed(text_breed.getText());
         }else if(eventSource == this.text_cultivarName){
             ((ICultivarPlantName)getEntity()).setCultivarEpithet(text_cultivarName.getText());
+        }else if(eventSource == this.text_cultivarGroup){
+            ((ICultivarPlantName)getEntity()).setCultivarGroupEpithet(text_cultivarGroup.getText());
         }else if(eventSource == this.text_subGenusAuthorship){
             ((IBacterialName)getEntity()).setSubGenusAuthorship(text_subGenusAuthorship.getText());
         }