change some alignments
[jSite2.git] / src / net / pterodactylus / jsite / gui / EditNodeDialog.java
index 73602fc..3f0694d 100644 (file)
@@ -39,12 +39,14 @@ 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;
 
 /**
  * Dialog that lets the user edit the properties of a node.
- * 
+ *
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
  * @version $Id$
  */
@@ -89,12 +91,15 @@ public class EditNodeDialog extends JDialog implements I18nable {
        /** The same machine checkbox. */
        private JCheckBox sameMachineCheckBox;
 
+       /** The same machine action. */
+       private I18nAction sameMachineAction;
+
        /** Whether the dialog was cancelled. */
        private boolean cancelled;
 
        /**
         * Creates a new node edit dialog with the given parent.
-        * 
+        *
         * @param parentDialog
         *            The parent dialog of this dialog
         */
@@ -113,7 +118,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Returns the user-given name of the node.
-        * 
+        *
         * @return The user-given name of the node
         */
        public String getNodeName() {
@@ -122,7 +127,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Sets the user-given name of the node.
-        * 
+        *
         * @param name
         *            The name of the node
         */
@@ -133,7 +138,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Returns the hostname of the node.
-        * 
+        *
         * @return The hostname of the node
         */
        public String getNodeHostname() {
@@ -142,7 +147,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Sets the hostname of the node.
-        * 
+        *
         * @param hostname
         *            The hostname of the node
         */
@@ -153,7 +158,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Returns the FCP port number of the node.
-        * 
+        *
         * @return The FCP port number of the node
         */
        public int getNodePort() {
@@ -162,7 +167,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Sets the FCP port number of the node.
-        * 
+        *
         * @param port
         *            The FCP port number of the node
         */
@@ -173,7 +178,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Returns whether the node is on the same machine as jSite.
-        * 
+        *
         * @return <code>true</code> if the node is on the same machine as jSite,
         *         <code>false</code> otherwise
         */
@@ -183,7 +188,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Sets whether the node is on the same machine as jSite.
-        * 
+        *
         * @param sameMachine
         *            <code>true</code> if the node is on the same machine as
         *            jSite, <code>false</code> otherwise
@@ -195,7 +200,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Returns whether the dialog was cancelled.
-        * 
+        *
         * @return <code>true</code> if the dialog was cancelled,
         *         <code>false</code> if the user clicked “okay”
         */
@@ -231,6 +236,12 @@ public class EditNodeDialog extends JDialog implements I18nable {
                                cancel();
                        }
                };
+               sameMachineAction = new I18nAction("editNodeDialog.checkbox.sameMachine") {
+
+                       public void actionPerformed(ActionEvent e) {
+                               /* don't do anything. */
+                       }
+               };
        }
 
        /**
@@ -255,23 +266,20 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
                nameTextField = new JTextField();
                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, 10, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 12, 0, 0), 0, 0));
+               contentPanel.add(nameTextField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 12, 0, 0), 0, 0));
 
                hostnameTextField = new JTextField();
                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, 10, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(12, 12, 0, 0), 0, 0));
+               contentPanel.add(hostnameTextField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(12, 12, 0, 0), 0, 0));
 
                portTextField = new JTextField();
                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, 10, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(12, 12, 0, 0), 0, 0));
+               contentPanel.add(portTextField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(12, 12, 0, 0), 0, 0));
 
-               sameMachineCheckBox = new JCheckBox(new I18nAction("editNodeDialog.checkbox.sameMachine") {
+               sameMachineCheckBox = new JCheckBox(sameMachineAction);
+               contentPanel.add(sameMachineCheckBox, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0));
 
-                       public void actionPerformed(ActionEvent e) {
-                               /* don't do anything. */
-                       }
-               });
-               contentPanel.add(sameMachineCheckBox, new GridBagConstraints(0, 3, 2, 1, 1, 1, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0));
+               contentPanel.add(new JPanel(), new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        }
 
        //
@@ -280,7 +288,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Checks the name textfield for valid input.
-        * 
+        *
         * @return <code>true</code> if the name textfield seem okay,
         *         <code>false</code> if there is an error
         */
@@ -290,7 +298,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
 
        /**
         * Verifies the hostname textfield by resolving the given name.
-        * 
+        *
         * @return <code>true</code> if the hostname is not empty and can be
         *         resolved, <code>false</code> otherwise
         */
@@ -309,7 +317,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
        /**
         * Verifies that the port number is numeric and in the range from
         * <code>0</code> to <code>65535</code>.
-        * 
+        *
         * @return <code>true</code> if the port number is okay,
         *         <code>false</code> otherwise
         */
@@ -375,6 +383,7 @@ public class EditNodeDialog extends JDialog implements I18nable {
                nameLabel.updateI18n();
                hostnameLabel.updateI18n();
                portLabel.updateI18n();
+               sameMachineAction.updateI18n();
                setTitle(I18n.get("editNodeDialog.title") + " – jSite " + Version.getVersion());
                SwingUtils.repackCentered(this);
        }