diff --git a/src/main/java/tm/modaldialog/TMModalDialog.java b/src/main/java/tm/modaldialog/TMModalDialog.java index 8aec117..0d7878a 100644 --- a/src/main/java/tm/modaldialog/TMModalDialog.java +++ b/src/main/java/tm/modaldialog/TMModalDialog.java @@ -26,14 +26,14 @@ import java.awt.event.*; /** -* -* A class providing a general framework for modal dialogs. -* It has an OK and Cancel button. Must be subclassed to -* provide the getDialogPane() method, which creates and -* returns a panel with the actual dialog components where -* input can be given by the user. -* -**/ + * + * A class providing a general framework for modal dialogs. + * It has an OK and Cancel button. Must be subclassed to + * provide the getDialogPane() method, which creates and + * returns a panel with the actual dialog components where + * input can be given by the user. + * + **/ public abstract class TMModalDialog extends JDialog { @@ -43,11 +43,11 @@ public abstract class TMModalDialog extends JDialog { private Xlator xl; private JPanel dialogPane; -/** -* -* -* -**/ + /** + * + * + * + **/ public TMModalDialog(Frame owner, String title, Xlator xl) { super(owner, xl != null ? xl.xlate(title) : title, true); @@ -56,17 +56,17 @@ public TMModalDialog(Frame owner, String title, Xlator xl) { okButton = new JButton(xlate("OK")); cancelButton = new JButton(xlate("Cancel")); okButton.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - approveInput(); - } + new ActionListener() { + public void actionPerformed(ActionEvent e) { + approveInput(); + } } ); cancelButton.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - cancelInput(); - } + new ActionListener() { + public void actionPerformed(ActionEvent e) { + cancelInput(); + } } ); JPanel buttonPane = new JPanel(); @@ -92,7 +92,7 @@ public Insets getInsets() { return new Insets(10,10,10,10); } }; - buttonPane.setBorder(new EmptyBorder(10, 0, 0, 0)); + buttonPane.setBorder(new EmptyBorder(10, 0, 0, 0)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout()); contentPane.add(buttonPane, BorderLayout.SOUTH); @@ -102,11 +102,11 @@ public Insets getInsets() { } -/** -* -* Shows the dialog. -* -**/ + /** + * + * Shows the dialog. + * + **/ public int showDialog() { // center the dialog @@ -114,48 +114,48 @@ public int showDialog() { int insetx = (screenSize.width - getWidth()) / 2; int insety = (screenSize.height - getHeight()) / 2; setBounds(insetx, insety, - getWidth(), getHeight()); + getWidth(), getHeight()); result = JOptionPane.CANCEL_OPTION; setVisible(true); return result; } -/** -* -* -* -**/ + /** + * + * + * + **/ protected void approveInput() { result = JOptionPane.OK_OPTION; setVisible(false); } -/** -* -* -* -**/ + /** + * + * + * + **/ protected void cancelInput() { result = JOptionPane.CANCEL_OPTION; setVisible(false); } -/** -* -* Method that provides the real content pane of the dialog. -* -**/ + /** + * + * Method that provides the real content pane of the dialog. + * + **/ protected abstract JPanel getDialogPane(); -/** -* -* -* -**/ + /** + * + * + * + **/ protected static void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { gbc.gridx = gx; @@ -166,13 +166,13 @@ protected static void buildConstraints(GridBagConstraints gbc, int gx, int gy, i gbc.weighty = wy; } -/** -* -* Sets enabled state of OK button. -* Subclasses can use this to keep the user from OK'ing the input when it -* isn't valid/completed. -* -**/ + /** + * + * Sets enabled state of OK button. + * Subclasses can use this to keep the user from OK'ing the input when it + * isn't valid/completed. + * + **/ public void maybeEnableOKButton() { okButton.setEnabled(inputOK()); @@ -192,14 +192,8 @@ public void removeUpdate(DocumentEvent e) { } } - public String xlate(String key) { - try { - String value = xl.xlate(key); - return value; - } - catch (Exception e) { - return key; - } + protected String xlate(String key) { + return xl.xlate(key); } } \ No newline at end of file diff --git a/src/main/java/tm/modaldialog/TMOrganizeTreeDialog.java b/src/main/java/tm/modaldialog/TMOrganizeTreeDialog.java index 39e5bfb..38fd443 100644 --- a/src/main/java/tm/modaldialog/TMOrganizeTreeDialog.java +++ b/src/main/java/tm/modaldialog/TMOrganizeTreeDialog.java @@ -285,20 +285,8 @@ public void treeNodesRemoved(TreeModelEvent e) { public void treeStructureChanged(TreeModelEvent e) { } -/** -* -* -* -**/ - - public String xlate(String key) { - try { - String value = xl.xlate(key); - return value; - } - catch (Exception e) { - return key; - } + private String xlate(String key) { + return xl.xlate(key); } /** diff --git a/src/main/java/tm/ui/TMAboutDialog.java b/src/main/java/tm/ui/TMAboutDialog.java deleted file mode 100644 index 656d763..0000000 --- a/src/main/java/tm/ui/TMAboutDialog.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -* -* Copyright (C) 2003 Kent Hansen. -* -* This file is part of Tile Molester. -* -* Tile Molester 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. -* -* Tile Molester 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. -* -*/ - -package tm.ui; - -import java.awt.*; -import javax.swing.*; - -/** -* -* Fancy about dialog. TODO. -* -**/ - -public class TMAboutDialog extends JDialog { - - public TMAboutDialog(Frame owner) { - super(owner, "About Tile Molester"); - setLayout(new BorderLayout()); - } - -} \ No newline at end of file diff --git a/src/main/java/tm/ui/TMSettings.java b/src/main/java/tm/ui/TMSettings.java index 2e6d202..34f942b 100644 --- a/src/main/java/tm/ui/TMSettings.java +++ b/src/main/java/tm/ui/TMSettings.java @@ -258,15 +258,9 @@ public String makePropertyTag(String key, String value) { * If no corresponding value is found, the key itself is returned. * **/ - - public String xlate(String key) { - try { - String value = xl.xlate(key); - return value; - } catch (Exception e) { - return key; - } - } + private String xlate(String key) { + return xl.xlate(key); + } /** diff --git a/src/main/java/tm/ui/TMUI.java b/src/main/java/tm/ui/TMUI.java index f49998f..98851d8 100644 --- a/src/main/java/tm/ui/TMUI.java +++ b/src/main/java/tm/ui/TMUI.java @@ -4550,15 +4550,9 @@ public ColorCodec[] getColorCodecs() { * If no corresponding value is found, the key itself is returned. * **/ - - public String xlate(String key) { - try { - String value = xl.xlate(key); - return value; - } catch (Exception e) { - return key; - } - } + public String xlate(String key) { + return xl.xlate(key); + } /** * diff --git a/src/main/java/tm/utils/Xlator.java b/src/main/java/tm/utils/Xlator.java index f6ea5c2..b2691b6 100644 --- a/src/main/java/tm/utils/Xlator.java +++ b/src/main/java/tm/utils/Xlator.java @@ -21,49 +21,35 @@ import java.util.ResourceBundle; import java.util.Locale; -/** -* -* -* -**/ - +/* + * This class provides a simple way to translate strings in the application. + */ public class Xlator { private ResourceBundle rb; -/** -* -* -* -**/ - public Xlator(String baseName, Locale locale) throws Exception { rb = null; try { rb = ResourceBundle.getBundle(baseName, locale); - } - catch (Exception e) { + } catch (Exception e) { throw e; } } -/** -* -* -* -**/ - + /** + * Translate a string to a different language. If the input key is not found the + * lookup key is returned. + * + * @param key input key + * @return translated string + */ public String xlate(String key) { try { String value = rb.getString(key); return value; - } - catch (Exception e) { + } catch (Exception e) { return key; } } - - public String trans(String key) { - return xlate(key); - } } \ No newline at end of file