X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FEditNodeDialog.java;h=12c91cba5069d50c5518deaf5f240a4c78fa47e8;hb=72a6784258f756eb23b39a9f8021b400829cbcec;hp=2ad2b4b2135bd22da4abfcc9c28e92973237afb5;hpb=6223be7f836ab24df6dc48dd755c9ae550b23fdf;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/gui/EditNodeDialog.java b/src/net/pterodactylus/jsite/gui/EditNodeDialog.java index 2ad2b4b..12c91cb 100644 --- a/src/net/pterodactylus/jsite/gui/EditNodeDialog.java +++ b/src/net/pterodactylus/jsite/gui/EditNodeDialog.java @@ -28,19 +28,19 @@ import java.awt.event.ActionEvent; import java.net.InetAddress; import java.net.UnknownHostException; -import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox; -import javax.swing.JComponent; import javax.swing.JDialog; -import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EtchedBorder; import net.pterodactylus.jsite.i18n.I18n; +import net.pterodactylus.jsite.i18n.I18nable; +import net.pterodactylus.jsite.i18n.gui.I18nAction; +import net.pterodactylus.jsite.i18n.gui.I18nLabel; import net.pterodactylus.jsite.main.Version; import net.pterodactylus.util.swing.SwingUtils; @@ -50,7 +50,7 @@ import net.pterodactylus.util.swing.SwingUtils; * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ */ -public class EditNodeDialog extends JDialog { +public class EditNodeDialog extends JDialog implements I18nable { /** The user-given name of the node. */ private String name; @@ -65,22 +65,34 @@ public class EditNodeDialog extends JDialog { private boolean sameMachine; /** Action of the okay button. */ - private Action okayAction; + private I18nAction okayAction; /** Action of the cancel button. */ - private Action cancelAction; + private I18nAction cancelAction; + + /** The name label. */ + private I18nLabel nameLabel; /** The name textfield. */ private JTextField nameTextField; + /** The hostname label. */ + private I18nLabel hostnameLabel; + /** The hostname textfield. */ private JTextField hostnameTextField; + /** The port label. */ + private I18nLabel portLabel; + /** The port textfield. */ private JTextField portTextField; /** The same machine checkbox. */ private JCheckBox sameMachineCheckBox; + + /** The same machine action. */ + private I18nAction sameMachineAction; /** Whether the dialog was cancelled. */ private boolean cancelled; @@ -96,6 +108,7 @@ public class EditNodeDialog extends JDialog { initActions(); initComponents(); pack(); + I18n.registerI18nable(this); SwingUtils.center(this); } @@ -223,6 +236,12 @@ public class EditNodeDialog extends JDialog { cancel(); } }; + sameMachineAction = new I18nAction("editNodeDialog.checkbox.sameMachine") { + + public void actionPerformed(ActionEvent e) { + /* don't do anything. */ + } + }; } /** @@ -246,43 +265,21 @@ public class EditNodeDialog extends JDialog { contentPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), BorderFactory.createEmptyBorder(12, 12, 12, 12))); nameTextField = new JTextField(); - contentPanel.add(createLabel(I18n.get("editNodeDialog.label.name"), nameTextField), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); + contentPanel.add(nameLabel = new I18nLabel("editNodeDialog.label.name", nameTextField), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); contentPanel.add(nameTextField, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 12, 0, 0), 0, 0)); hostnameTextField = new JTextField(); - contentPanel.add(createLabel(I18n.get("editNodeDialog.label.hostname"), hostnameTextField), new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0)); + contentPanel.add(hostnameLabel = new I18nLabel("editNodeDialog.label.hostname", hostnameTextField), new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0)); contentPanel.add(hostnameTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(12, 12, 0, 0), 0, 0)); portTextField = new JTextField(); - contentPanel.add(createLabel(I18n.get("editNodeDialog.label.port"), portTextField), new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0)); + contentPanel.add(portLabel = new I18nLabel("editNodeDialog.label.port", portTextField), new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0)); contentPanel.add(portTextField, new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(12, 12, 0, 0), 0, 0)); - sameMachineCheckBox = new JCheckBox(new I18nAction("editNodeDialog.checkbox.sameMachine") { - - public void actionPerformed(ActionEvent e) { - /* don't do anything. */ - } - }); + sameMachineCheckBox = new JCheckBox(sameMachineAction); contentPanel.add(sameMachineCheckBox, new GridBagConstraints(0, 3, 2, 1, 1, 1, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0)); } - /** - * Creates a label whose name and mnemonic are initialized from the given - * i18n property. - * - * @param i18nBasename - * The i18n property basename of the label - * @param labelFor - * The component this label describes - * @return The created label - */ - private JLabel createLabel(String i18nBasename, JComponent labelFor) { - JLabel label = new JLabel(I18n.get(i18nBasename + ".name")); - label.setDisplayedMnemonic(I18n.getKey(i18nBasename + ".mnemonic")); - label.setLabelFor(labelFor); - return label; - } - // // PRIVATE ACTIONS // @@ -371,4 +368,22 @@ public class EditNodeDialog extends JDialog { setVisible(false); } + // + // INTERFACE I18nable + // + + /** + * {@inheritDoc} + */ + public void updateI18n() { + okayAction.updateI18n(); + cancelAction.updateI18n(); + nameLabel.updateI18n(); + hostnameLabel.updateI18n(); + portLabel.updateI18n(); + sameMachineAction.updateI18n(); + setTitle(I18n.get("editNodeDialog.title") + " – jSite " + Version.getVersion()); + SwingUtils.repackCentered(this); + } + }