code cleaning and fix potential null pointer
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / model / NomenclaturalCodeHelper.java
index 2ee64bba9f709b1167d1abcbb6b396533a0a2034..1cf9d3f80e9d6ebe23d8faa91629cfac5f52d10b 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -14,6 +14,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 
 /**
  * <p>NomenclaturalCodeHelper class.</p>
@@ -23,7 +24,7 @@ import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
  * @version 1.0
  */
 public class NomenclaturalCodeHelper {
-               
+
        /**
         * <p>getAllCodes</p>
         *
@@ -41,14 +42,19 @@ public class NomenclaturalCodeHelper {
         */
        public static List<NomenclaturalCode> getSupportedCodes() {
                List<NomenclaturalCode> supportedCodes = new ArrayList<NomenclaturalCode>();
+               NomenclaturalCode nomenclaturalCode =PreferencesUtil.getPreferredNomenclaturalCode();
                for (NomenclaturalCode code : getAllCodes()) {
                        if (isSupported(code)) {
-                               supportedCodes.add(code);
+                           if (nomenclaturalCode != null && nomenclaturalCode.equals(code)){
+                               supportedCodes.add(0, code);
+                           }else{
+                               supportedCodes.add(code);
+                           }
                        }
                }
                return supportedCodes;
        }
-       
+
        /**
         * @param code
         * @return
@@ -80,13 +86,13 @@ public class NomenclaturalCodeHelper {
                }
                if (code.equals(NomenclaturalCode.ICZN)) {
                        return "International Code of Zoological Nomenclature (ICZN)";
-               }               
+               }
                if (code.equals(NomenclaturalCode.ICVCN)) {
                        return "International Code for Virus Classification and Nomenclature (ICVCN)";
-               } 
+               }
                return code.name();
        }
-       
+
        /**
         * <p>getDefaultCode</p>
         *