fix remaining issues for taxon field prefill #4860
authorAndreas Müller <a.mueller@bgbm.org>
Fri, 8 May 2015 13:06:59 +0000 (13:06 +0000)
committerAndreas Müller <a.mueller@bgbm.org>
Fri, 8 May 2015 13:06:59 +0000 (13:06 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeDetailElement.java

index 79ec3ffe4e85e450526ec7c79485d4ebb3945a19..fde5720fc440b504832d806d40e3b9fb38a158eb 100644 (file)
@@ -10,6 +10,7 @@
 
 package eu.etaxonomy.taxeditor.ui.section.classification;
 
 
 package eu.etaxonomy.taxeditor.ui.section.classification;
 
+import org.apache.commons.lang.StringUtils;
 import org.eclipse.swt.widgets.Text;
 
 import eu.etaxonomy.cdm.common.CdmUtils;
 import org.eclipse.swt.widgets.Text;
 
 import eu.etaxonomy.cdm.common.CdmUtils;
@@ -130,18 +131,20 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<ITaxonTreeN
                 Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
                 if(taxon.getName()!=null && taxon.getName().isInstanceOf(NonViralName.class)){
                     NonViralName<?> name = HibernateProxyHelper.deproxy(node.getTaxon().getName(), NonViralName.class);
                 Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
                 if(taxon.getName()!=null && taxon.getName().isInstanceOf(NonViralName.class)){
                     NonViralName<?> name = HibernateProxyHelper.deproxy(node.getTaxon().getName(), NonViralName.class);
-                    if(!name.getRank().isHigher(Rank.GENUS())){
+                    if( ! name.isSupraGeneric() && name.getRank() != null){
                         String taxonName = "";
                         String taxonName = "";
-                        if(name.isGenus() || name.isInfraGeneric()){
+                        if(name.isGenus() || name.isInfraGeneric()|| name.isSpeciesAggregate() ){
                             taxonName = name.getGenusOrUninomial();
                         }
                             taxonName = name.getGenusOrUninomial();
                         }
-                        else if(name.isSpecies() || name.isInfraSpecific()){
-                            taxonName = name.getGenusOrUninomial() +" "+ name.getSpecificEpithet();
+                        else if(name.isSpecies() || name.isInfraSpecific() ){
+                            taxonName = CdmUtils.concat(" ", name.getGenusOrUninomial(),name.getSpecificEpithet());
                         }
                         }
-                        text_newTaxonName.setText(taxonName+" ");
-                        if(text_newTaxonName.getMainControl() instanceof Text){
-                            Text text = (Text)text_newTaxonName.getMainControl();
-                            text.setSelection(text_newTaxonName.getText().length());
+                        if (StringUtils.isNotBlank(taxonName)){
+                               text_newTaxonName.setText(taxonName + " ");
+                               if(text_newTaxonName.getMainControl() instanceof Text){
+                                       Text text = (Text)text_newTaxonName.getMainControl();
+                                       text.setSelection(text_newTaxonName.getText().length());
+                               }
                         }
                     }
                 }
                         }
                     }
                 }