whitespace fixups
[jSite2.git] / src / net / pterodactylus / jsite / gui / ConfigurationDialog.java
index 00c0776..92c547a 100644 (file)
@@ -20,6 +20,7 @@ import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JSpinner;
 import javax.swing.JTabbedPane;
@@ -37,9 +38,8 @@ import net.pterodactylus.util.swing.SwingUtils;
 
 /**
  * The configuration dialog.
- * 
+ *
  * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
  */
 public class ConfigurationDialog extends JDialog implements I18nable {
 
@@ -102,7 +102,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Creates a new configuration dialog.
-        * 
+        *
         * @param swingInterface
         *            The Swing interface
         */
@@ -122,7 +122,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
        /**
         * Returns whether the dialog was cancelled or confirmed. If the dialog was
         * cancelled, no further processing should be done.
-        * 
+        *
         * @return <code>true</code> if the dialog was cancelled,
         *         <code>false</code> otherwise
         */
@@ -132,7 +132,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Returns whether the advanced mode is selected.
-        * 
+        *
         * @return <code>true</code> if the advanced mode is selected,
         *         <code>false</code> otherwise
         */
@@ -142,7 +142,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Sets whether the advanced mode is selected.
-        * 
+        *
         * @param advancedMode
         *            <code>true</code> if the advanced mode is selected,
         *            <code>false</code> otherwise
@@ -155,7 +155,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
         * Returns whether the “beautify” checkbox has been selected. The result of
         * this method should not be used if {@link #wasCancelled()} returned
         * <code>true</code>!
-        * 
+        *
         * @return <code>true</code> if the checkbox was selected,
         *         <code>false</code> otherwise
         */
@@ -165,7 +165,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Sets the state of the “antialias” checkbox.
-        * 
+        *
         * @param antialias
         *            The state of the checkbox
         */
@@ -175,7 +175,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Returns the font for the controls.
-        * 
+        *
         * @return The control font, or <code>null</code> if no custom control
         *         font is to be used
         */
@@ -185,7 +185,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Sets the font for the controls.
-        * 
+        *
         * @param controlFont
         *            The control font, or <code>null</code> if no custom control
         *            font is to be used
@@ -207,7 +207,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Returns the font for user input.
-        * 
+        *
         * @return The font for user input, or <code>null</code> if no custom user
         *         input font is to be used
         */
@@ -217,7 +217,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Sets the font for user input.
-        * 
+        *
         * @param userFont
         *            The font for user input, or <code>null</code> if no custom
         *            user input font is to be used
@@ -240,7 +240,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
        /**
         * Returns the class name of the selected look and feel, if a custom look
         * and feel is selected.
-        * 
+        *
         * @return The class name of the look and feel to load, or <code>null</code>
         *         if no special look and feel should be used
         */
@@ -253,7 +253,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Sets the given look and feel.
-        * 
+        *
         * @param lookAndFeel
         *            The class name of the look and feel, or <code>null</code> to
         *            not select a custom look and feel
@@ -268,6 +268,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
                        LookAndFeelWrapper lookAndFeelWrapper = (LookAndFeelWrapper) customLAFComboBox.getItemAt(lookAndFeelIndex);
                        if (lookAndFeelWrapper.getClassName().equals(lookAndFeel)) {
                                customLAFComboBox.setSelectedIndex(lookAndFeelIndex);
+                               customLAFComboBox.setEnabled(true);
                                useCustomLAFCheckBox.setSelected(true);
                                break;
                        }
@@ -385,7 +386,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Creates the interface configuration panel.
-        * 
+        *
         * @return The interface configuration panel
         */
        private JComponent createInterfaceConfig() {
@@ -401,7 +402,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
        /**
         * Creates the panel for the interface tweaks configuration.
-        * 
+        *
         * @return The interface tweaks configuration panel
         */
        private JComponent createInterfaceTweaksConfig() {
@@ -437,11 +438,11 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
                LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
                List<LookAndFeelWrapper> lookAndFeelWrappers = new ArrayList<LookAndFeelWrapper>();
-               for (LookAndFeelInfo lookAndFeelInfo: lookAndFeelInfos) {
+               for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) {
                        lookAndFeelWrappers.add(new LookAndFeelWrapper(lookAndFeelInfo.getClassName(), lookAndFeelInfo.getName()));
                }
                customLAFComboBox = new JComboBox(lookAndFeelWrappers.toArray(new LookAndFeelWrapper[0]));
-               interfaceTweaksConfigPanel.add(customLAFComboBox, new GridBagConstraints(1, 4, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+               interfaceTweaksConfigPanel.add(customLAFComboBox, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
 
                interfaceTweaksConfigPanel.add(new JPanel(), new GridBagConstraints(0, 5, 3, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
 
@@ -456,6 +457,18 @@ public class ConfigurationDialog extends JDialog implements I18nable {
         * Called when the “okay” button is clicked.
         */
        private void actionOkay() {
+               if (useCustomControlFontCheckBox.isSelected()) {
+                       if (controlFontList.getSelectedItem() == null) {
+                               JOptionPane.showMessageDialog(this, I18n.get("configurationDialog.error.noControlFontSelected.message"), I18n.get("configurationDialog.error.noControlFontSelected.title"), JOptionPane.ERROR_MESSAGE);
+                               return;
+                       }
+               }
+               if (useCustomUserFontCheckBox.isSelected()) {
+                       if (userFontList.getSelectedItem() == null) {
+                               JOptionPane.showMessageDialog(this, I18n.get("configurationDialog.error.noUserFontSelected.message"), I18n.get("configurationDialog.error.noUserFontSelected.title"), JOptionPane.ERROR_MESSAGE);
+                               return;
+                       }
+               }
                cancelled = false;
                setVisible(false);
        }
@@ -478,18 +491,19 @@ public class ConfigurationDialog extends JDialog implements I18nable {
        public void updateI18n() {
                okayAction.updateI18n();
                cancelAction.updateI18n();
+               advancedModeAction.updateI18n();
                restartRequiredLabel.updateI18n();
                antialiasAction.updateI18n();
                useCustomControlFontAction.updateI18n();
                useCustomUserFontAction.updateI18n();
+               useCustomLAFAction.updateI18n();
                SwingUtils.repackCentered(this);
        }
 
        /**
         * Wrapper around class name and name of a {@link LookAndFeel}.
-        * 
+        *
         * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
-        * @version $Id$
         */
        private static class LookAndFeelWrapper {
 
@@ -502,7 +516,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
                /**
                 * Creates a new wrapper around the given class name and name of a look
                 * and feel.
-                * 
+                *
                 * @param className
                 *            The class name of the look and feel
                 * @param lookAndFeelName
@@ -515,7 +529,7 @@ public class ConfigurationDialog extends JDialog implements I18nable {
 
                /**
                 * Returns the class name of the look and feel.
-                * 
+                *
                 * @return The class name of the look and feel
                 */
                public String getClassName() {