[vassalengine-svn-trunk] [vassalengine-svn] SF.net SVN: vassalengine: [2256] VASSAL-src/trunk/VASSA
Brought to you by:
rodneykinney,
uckelman
From: <rod...@us...> - 2007-06-27 04:38:07
|
Revision: 2256 http://svn.sourceforge.net/vassalengine/?rev=2256&view=rev Author: rodneykinney Date: 2007-06-26 21:38:05 -0700 (Tue, 26 Jun 2007) Log Message: ----------- Add Language preference to prefs window. Modified Paths: -------------- VASSAL-src/trunk/VASSAL/i18n/Resources.java VASSAL-src/trunk/VASSAL/preferences/Prefs.java VASSAL-src/trunk/VASSAL/preferences/PrefsEditor.java Modified: VASSAL-src/trunk/VASSAL/i18n/Resources.java =================================================================== --- VASSAL-src/trunk/VASSAL/i18n/Resources.java 2007-06-27 04:05:12 UTC (rev 2255) +++ VASSAL-src/trunk/VASSAL/i18n/Resources.java 2007-06-27 04:38:05 UTC (rev 2256) @@ -18,19 +18,26 @@ */ package VASSAL.i18n; +import java.awt.Component; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Date; import java.util.Enumeration; +import java.util.List; import java.util.Locale; import java.util.ResourceBundle; +import javax.swing.Action; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; import javax.swing.UIManager; import VASSAL.Info; -import VASSAL.configure.StringConfigurer; +import VASSAL.build.module.gamepieceimage.StringEnumConfigurer; import VASSAL.preferences.Prefs; public class Resources { @@ -58,14 +65,38 @@ protected static Locale locale = Locale.getDefault(); static { - StringConfigurer localeConfig = new StringConfigurer(Resources.LOCALE_PREF_KEY, null, Resources.getLocale().getLanguage()); - Prefs.getGlobalPrefs().addOption(null, localeConfig); + List<String> languages = new ArrayList<String>(); + for (Locale l : getSupportedLocales()) { + languages.add(l.getLanguage()); + } + StringEnumConfigurer localeConfig = new StringEnumConfigurer(Resources.LOCALE_PREF_KEY, Resources.getString("Prefs.language"), languages.toArray(new String[languages.size()])) { + public Component getControls() { + if (box == null) { + Component c = super.getControls(); + box.setRenderer(new DefaultListCellRenderer() { + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + JLabel l = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + l.setText(new Locale((String)value).getDisplayLanguage()); + return l; + } + }); + return c; + } + else { + return super.getControls(); + } + } + }; + localeConfig.setValue(Resources.getLocale().getLanguage()); + Prefs.getGlobalPrefs().addOption(localeConfig); Locale l = new Locale(localeConfig.getValueString()); if (!Resources.getSupportedLocales().contains(l)) { l = Locale.ENGLISH; localeConfig.setValue(l.toString()); } Resources.setLocale(l); + // Because the global prefs editor was initialized before the locale, we have to localize the "Edit Preferences" action by hand + Prefs.getGlobalPrefs().getEditor().getEditAction().putValue(Action.NAME, getString("Prefs.edit_preferences")); } public static Collection<Locale> getSupportedLocales() { Modified: VASSAL-src/trunk/VASSAL/preferences/Prefs.java =================================================================== --- VASSAL-src/trunk/VASSAL/preferences/Prefs.java 2007-06-27 04:05:12 UTC (rev 2255) +++ VASSAL-src/trunk/VASSAL/preferences/Prefs.java 2007-06-27 04:38:05 UTC (rev 2256) @@ -170,7 +170,7 @@ globalPrefs = new Prefs(new PrefsEditor(new ArchiveWriter(prefsFile.getPath())), "VASSAL"); //$NON-NLS-1$ DirectoryConfigurer c = new DirectoryConfigurer(MODULES_DIR_KEY, null); c.setValue(new File(System.getProperty("user.home"))); - globalPrefs.addOption(c); + globalPrefs.addOption(null,c); } return globalPrefs; } Modified: VASSAL-src/trunk/VASSAL/preferences/PrefsEditor.java =================================================================== --- VASSAL-src/trunk/VASSAL/preferences/PrefsEditor.java 2007-06-27 04:05:12 UTC (rev 2255) +++ VASSAL-src/trunk/VASSAL/preferences/PrefsEditor.java 2007-06-27 04:38:05 UTC (rev 2256) @@ -96,6 +96,9 @@ buttonPanel.add(save); buttonPanel.add(cancel); optionsTab = new JTabbedPane(); + JPanel pan = new JPanel(); + pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS)); + optionsTab.addTab(Resources.getString("Prefs.general_tab"), pan); } public void initDialog(Frame parent) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ vassalengine-svn mailing list vas...@li... https://lists.sourceforge.net/lists/listinfo/vassalengine-svn |