Index: lutinutil/src/java/org/codelutin/i18n/LocaleEditor.java diff -u /dev/null lutinutil/src/java/org/codelutin/i18n/LocaleEditor.java:1.1 --- /dev/null Sun Mar 23 22:13:49 2008 +++ lutinutil/src/java/org/codelutin/i18n/LocaleEditor.java Sun Mar 23 22:13:44 2008 @@ -0,0 +1,57 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package org.codelutin.i18n; + +import org.codelutin.i18n.I18n; + +import javax.swing.*; +import java.util.Locale; + +/** + * A {@link Locale} editor. + * + * use the static method to have an instance of editor {@link #newEditor(java.util.Locale[])} + * + * If no locale is given to this method, it will go and seek via + * {@link org.codelutin.i18n.bundle.I18nBundleManager#getLocales()} all loaded locales in i18n system + * + * @author chemit + */ +public class LocaleEditor extends JComboBox { + + protected Locale[] type; + + public static LocaleEditor newEditor(Locale... type) { + return new LocaleEditor(type); + } + + public LocaleEditor(Locale... type) { + super(buildModel(type)); + } + + protected static Locale[] buildModel(Locale... type) { + if (type.length > 0) { + return type; + } + // get availables locales registred in I18n system + type = I18n.getBundleManager().getLocales(); + return type; + } + +} \ No newline at end of file