[vassalengine-svn-trunk] [vassalengine-svn] SF.net SVN: vassalengine: [2094] VASSAL-src/trunk/VASSA
Brought to you by:
rodneykinney,
uckelman
From: <rod...@us...> - 2007-05-26 04:26:35
|
Revision: 2094 http://svn.sourceforge.net/vassalengine/?rev=2094&view=rev Author: rodneykinney Date: 2007-05-25 21:26:27 -0700 (Fri, 25 May 2007) Log Message: ----------- Fix null userId Add Help button to TranslateWindow Modified Paths: -------------- VASSAL-src/trunk/VASSAL/build/module/PlayerRoster.java VASSAL-src/trunk/VASSAL/i18n/TranslateVassalWindow.java VASSAL-src/trunk/VASSAL/i18n/TranslateWindow.java VASSAL-src/trunk/VASSAL/i18n/VassalTranslation.java VASSAL-src/trunk/VASSAL/launch/BasicModule.java Modified: VASSAL-src/trunk/VASSAL/build/module/PlayerRoster.java =================================================================== --- VASSAL-src/trunk/VASSAL/build/module/PlayerRoster.java 2007-05-25 22:33:34 UTC (rev 2093) +++ VASSAL-src/trunk/VASSAL/build/module/PlayerRoster.java 2007-05-26 04:26:27 UTC (rev 2094) @@ -370,6 +370,9 @@ private String side; public PlayerInfo(String id, String name, String side) { + if (id == null) { + throw new NullPointerException("Player id cannot be null"); + } playerId = id; playerName = name; this.side = side; Modified: VASSAL-src/trunk/VASSAL/i18n/TranslateVassalWindow.java =================================================================== --- VASSAL-src/trunk/VASSAL/i18n/TranslateVassalWindow.java 2007-05-25 22:33:34 UTC (rev 2093) +++ VASSAL-src/trunk/VASSAL/i18n/TranslateVassalWindow.java 2007-05-26 04:26:27 UTC (rev 2094) @@ -10,27 +10,27 @@ import java.util.Collections; import java.util.Enumeration; import java.util.Locale; - import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.JPanel; - +import javax.swing.JSplitPane; import VASSAL.Info; import VASSAL.build.GameModule; +import VASSAL.build.module.documentation.HelpFile; import VASSAL.build.module.documentation.HelpWindow; import VASSAL.configure.ConfigureTree; +import VASSAL.configure.ShowHelpAction; import VASSAL.tools.ExtensionFileFilter; import VASSAL.tools.FileChooser; public class TranslateVassalWindow extends TranslateWindow { + private static final long serialVersionUID = 1L; + protected LocaleConfigurer localeConfig; - private static final long serialVersionUID = 1L; - protected LocaleConfigurer localeConfig; - public TranslateVassalWindow(Frame owner, boolean modal, Translatable target, HelpWindow helpWindow, ConfigureTree tree) { super(owner, modal, target, helpWindow, tree); } - + public TranslateVassalWindow(Frame owner) { super(owner, false, new VassalTranslation(), null, null); currentTranslation = (Translation) target; @@ -38,25 +38,30 @@ newTranslation(); } + protected Component buildMainPanel() { + JSplitPane pane = (JSplitPane) super.buildMainPanel(); + return pane.getBottomComponent(); + } + protected Component getHeaderPanel() { JPanel headPanel = new JPanel(); localeConfig = new LocaleConfigurer(null, "", new Locale(Locale.getDefault().getLanguage())); headPanel.add(localeConfig.getControls()); - return headPanel; } - + protected Component getButtonPanel() { JPanel buttonBox = new JPanel(); - + JButton helpButton = new JButton(Resources.getString(Resources.HELP)); + helpButton.addActionListener(new ShowHelpAction(null,HelpFile.getReferenceManualPage("Translations.htm"),null));; JButton loadButton = new JButton(Resources.getString(Resources.LOAD)); loadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadTranslation(); - }}); + } + }); + buttonBox.add(helpButton); buttonBox.add(loadButton); - - JButton okButton = new JButton(Resources.getString(Resources.SAVE)); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -78,10 +83,9 @@ buttonBox.add(cancelButton); return buttonBox; } - + protected void newTranslation() { ((VassalTranslation) target).clearProperties(); - ArrayList keyList = new ArrayList(); for (Enumeration e = Resources.getVassalKeys(); e.hasMoreElements(); keyList.add(e.nextElement())) { ; @@ -91,8 +95,7 @@ copyButtons = new CopyButton[keys.length]; ((MyTableModel) keyTable.getModel()).update(); } - - + protected void loadTranslation() { if (currentTranslation.isDirty()) { try { @@ -106,24 +109,23 @@ } } FileChooser fc = GameModule.getGameModule().getFileChooser(); - fc.setFileFilter(new ExtensionFileFilter("Property Files", new String[] {".properties"})); + fc.setFileFilter(new ExtensionFileFilter("Property Files", new String[]{".properties"})); if (fc.showOpenDialog(this) != FileChooser.APPROVE_OPTION) return; File file = fc.getSelectedFile(); - if (! file.getName().endsWith(".properties")) { + if (!file.getName().endsWith(".properties")) { loadError("Module Properties files must end in '.properties'."); return; } else { - String language = file.getName().substring(7,9); + String language = file.getName().substring(7, 9); String country = ""; if (file.getName().charAt(9) == '_') { - country = file.getName().substring(10,12); + country = file.getName().substring(10, 12); } Locale locale = new Locale(language, country); localeConfig.setValue(locale); } - try { ((VassalTranslation) target).loadProperties(file); } @@ -135,6 +137,7 @@ } loadError(msg); } + ((MyTableModel) keyTable.getModel()).fireTableDataChanged(); } protected void loadError(String mess) { @@ -150,11 +153,9 @@ bundle += "_" + l.getCountry(); } bundle += ".properties"; - fc.setSelectedFile(new File(Info.getHomeDir(),bundle)); - + fc.setSelectedFile(new File(Info.getHomeDir(), bundle)); if (fc.showSaveDialog(this) != FileChooser.APPROVE_OPTION) return false; - File outputFile = fc.getSelectedFile(); try { ((VassalTranslation) target).saveProperties(outputFile, localeConfig.getValueLocale()); Modified: VASSAL-src/trunk/VASSAL/i18n/TranslateWindow.java =================================================================== --- VASSAL-src/trunk/VASSAL/i18n/TranslateWindow.java 2007-05-25 22:33:34 UTC (rev 2093) +++ VASSAL-src/trunk/VASSAL/i18n/TranslateWindow.java 2007-05-26 04:26:27 UTC (rev 2094) @@ -103,22 +103,17 @@ } protected void initComponents() { - setTitle("Translate " + VASSAL.configure.ConfigureTree.getConfigureName((Configurable) target)); JPanel mainPanel = new JPanel(new BorderLayout()); - /* * Place Language selector above Tree and Keys */ - JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, getHeaderPanel(), getMainPanel()); - split.setResizeWeight(0); - mainPanel.add(split, BorderLayout.CENTER); + mainPanel.add(getHeaderPanel(), BorderLayout.PAGE_START); + mainPanel.add(buildMainPanel(), BorderLayout.CENTER); mainPanel.add(getButtonPanel(), BorderLayout.PAGE_END); - getContentPane().add(mainPanel); pack(); setLocationRelativeTo(getParent()); - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { @@ -201,33 +196,9 @@ } } - protected Component getMainPanel() { - /* - * Key Panel - Table of Keys for the component currently selected in the - * Tree Panel - */ - JPanel keyPanel = new JPanel(new BorderLayout()); - keyPanel.setMinimumSize(new Dimension(800, 100)); - keyTable = new MyTable(); - keyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + protected Component buildMainPanel() { + JPanel keyPanel = buildKeyTablePanel(); - keyTable.addFocusListener(new FocusListener() { - public void focusGained(java.awt.event.FocusEvent e) { - } - public void focusLost(java.awt.event.FocusEvent e) { - commitTableEdit(); - } - }); - - keyTable.getSelectionModel().addListSelectionListener(this); - keyTable.setEnabled(currentTranslation != null); - - JScrollPane keyScroll = new JScrollPane(keyTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - keyPanel.add(keyScroll, BorderLayout.CENTER); - keyPanel.setMinimumSize(new Dimension(400, 100)); - keyPanel.setPreferredSize(new Dimension(800, 200)); - /* * Tree of all components from target component down */ @@ -253,6 +224,35 @@ return split1; } + + protected JPanel buildKeyTablePanel() { + /* + * Key Panel - Table of Keys for the component currently selected in the + * Tree Panel + */ + JPanel keyPanel = new JPanel(new BorderLayout()); + keyPanel.setMinimumSize(new Dimension(800, 100)); + keyTable = new MyTable(); + keyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + keyTable.addFocusListener(new FocusListener() { + public void focusGained(java.awt.event.FocusEvent e) { + } + public void focusLost(java.awt.event.FocusEvent e) { + commitTableEdit(); + } + }); + + keyTable.getSelectionModel().addListSelectionListener(this); + keyTable.setEnabled(currentTranslation != null); + + JScrollPane keyScroll = new JScrollPane(keyTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + keyPanel.add(keyScroll, BorderLayout.CENTER); + keyPanel.setMinimumSize(new Dimension(400, 100)); + keyPanel.setPreferredSize(new Dimension(800, 200)); + return keyPanel; + } protected Component getButtonPanel() { JPanel buttonBox = new JPanel(); @@ -637,7 +637,7 @@ case TRAN_COL: if (currentTranslation != null) { - String key = keyTarget.getI18nData().getFullPrefix() + "." + keys[row]; //$NON-NLS-1$ + String key = keyTarget.getI18nData().getFullPrefix() + keys[row]; //$NON-NLS-1$ return currentTranslation.translate(key); } } Modified: VASSAL-src/trunk/VASSAL/i18n/VassalTranslation.java =================================================================== --- VASSAL-src/trunk/VASSAL/i18n/VassalTranslation.java 2007-05-25 22:33:34 UTC (rev 2093) +++ VASSAL-src/trunk/VASSAL/i18n/VassalTranslation.java 2007-05-26 04:26:27 UTC (rev 2094) @@ -37,15 +37,26 @@ */ public class VassalTranslation extends Translation { - protected String getI18nPrefix() { - return ""; - } + protected String[] allKeys; + + protected Properties baseValues = new Properties(); - protected String[] allKeys; public VassalTranslation() { setConfigureName("VASSAL"); + try { + baseValues.load(getClass().getResourceAsStream("VASSAL.properties")); + } + catch (IOException e) { + e.printStackTrace(); + } } + + + protected String getI18nPrefix() { + return ""; + } + protected String getDescription() { return "VASSAL"; } @@ -57,7 +68,7 @@ } public String getAttributeValueString(String key) { - return Resources.getString(key); + return baseValues.getProperty(key); } public String[] getAttributeDescriptions() { Modified: VASSAL-src/trunk/VASSAL/launch/BasicModule.java =================================================================== --- VASSAL-src/trunk/VASSAL/launch/BasicModule.java 2007-05-25 22:33:34 UTC (rev 2093) +++ VASSAL-src/trunk/VASSAL/launch/BasicModule.java 2007-05-26 04:26:27 UTC (rev 2094) @@ -125,6 +125,7 @@ GameModule.getGameModule().getPrefs().addOption(Resources.getString("Prefs.personal_tab"), fullName); //$NON-NLS-1$ //$NON-NLS-2$ GameModule.getGameModule().getPrefs().addOption(Resources.getString("Prefs.personal_tab"), user); //$NON-NLS-1$ //$NON-NLS-2$ GameModule.getGameModule().getPrefs().addOption(Resources.getString("Prefs.personal_tab"), profile); //$NON-NLS-1$ + GameModule.setUserId(user.getValueString()); } protected void initServer() { 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 |