From 60c946948a0acbdf61f70a2f687c31363214e359 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Wed, 25 Apr 2007 03:25:16 +0000
Subject: [PATCH] corrected some upgrader presentation problems and consolidated some UIFactory imposed settings

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java |  143 +++++++++++++++++++++++++++++++----
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ConfirmUninstallPanel.java                |    3 
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/SecurityOptionsDialog.java                |    7 -
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java          |   70 -----------------
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java                     |    1 
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java         |    1 
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java         |    1 
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java                            |    9 +
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebProxyDialog.java                       |    5 +
 9 files changed, 140 insertions(+), 100 deletions(-)

diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
index ea6100e..5bfc2cf 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
@@ -325,7 +325,6 @@
       checkBox =
           UIFactory.makeJCheckBox(getMsg("start-server-label"),
               getMsg("start-server-tooltip"), UIFactory.TextStyle.CHECKBOX);
-      checkBox.setOpaque(false);
       checkBox.setSelected(getApplication().getUserData().getStartServer());
     }
     return checkBox;
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ConfirmUninstallPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ConfirmUninstallPanel.java
index 12231a9..5d2440a 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ConfirmUninstallPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ConfirmUninstallPanel.java
@@ -150,7 +150,6 @@
     {
       JCheckBox cb = UIFactory.makeJCheckBox(labels[i], tooltips[i],
           UIFactory.TextStyle.INSTRUCTIONS);
-      cb.setOpaque(false);
       cb.setSelected(true);
       hmCbs.put(fieldNames[i], cb);
     }
@@ -245,7 +244,6 @@
     JCheckBox cbOutsideDbs = UIFactory.makeJCheckBox(
         getMsg("delete-outside-dbs-label"),
         getMsg("delete-outside-dbs-tooltip"), UIFactory.TextStyle.INSTRUCTIONS);
-    cbOutsideDbs.setOpaque(false);
     cbOutsideDbs.setSelected(true);
     hmCbs.put(FieldName.EXTERNAL_DB_DIRECTORIES, cbOutsideDbs);
 
@@ -265,7 +263,6 @@
         getMsg("delete-outside-logs-label"),
         getMsg("delete-outside-logs-tooltip"),
         UIFactory.TextStyle.INSTRUCTIONS);
-    cbOutsideLogs.setOpaque(false);
     cbOutsideLogs.setSelected(true);
     hmCbs.put(FieldName.EXTERNAL_LOG_FILES, cbOutsideLogs);
 
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java
index 9ef09ec..e285a0c 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java
@@ -468,7 +468,6 @@
     for (DataOptions.Type type : hmRadioButtons.keySet())
     {
       rb = hmRadioButtons.get(type);
-      rb.setOpaque(false);
       rb.setSelected(type == defaultType);
       buttonGroup.add(rb);
     }
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/SecurityOptionsDialog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/SecurityOptionsDialog.java
index 8e22792..0a79f0c 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/SecurityOptionsDialog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/SecurityOptionsDialog.java
@@ -354,7 +354,6 @@
     cbEnableSSL = UIFactory.makeJCheckBox(getMsg("enable-ssl-label"),
         getMsg("enable-ssl-tooltip"), UIFactory.TextStyle.PRIMARY_FIELD_VALID);
     cbEnableSSL.addActionListener(l);
-    cbEnableSSL.setOpaque(false);
     String sPort = "";
     int port = securityOptions.getSslPort();
     if (port > 0)
@@ -368,12 +367,10 @@
         getMsg("enable-starttls-tooltip"),
         UIFactory.TextStyle.SECONDARY_FIELD_VALID);
     cbEnableStartTLS.addActionListener(l);
-    cbEnableStartTLS.setOpaque(false);
     rbUseSelfSignedCertificate = UIFactory.makeJRadioButton(
         getMsg("use-self-signed-label"),
         getMsg("use-self-signed-tooltip"),
         UIFactory.TextStyle.SECONDARY_FIELD_VALID);
-    rbUseSelfSignedCertificate.setOpaque(false);
     rbUseSelfSignedCertificate.addActionListener(l);
     lSelfSignedName = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
         getMsg("self-signed-certificate-name-label"),
@@ -388,7 +385,6 @@
         getMsg("use-existing-certificate-label"),
         getMsg("use-existing-certificate-tooltip"),
         UIFactory.TextStyle.SECONDARY_FIELD_VALID);
-    rbUseExistingCertificate.setOpaque(false);
     rbUseExistingCertificate.addActionListener(l);
     ButtonGroup group1 = new ButtonGroup();
     group1.add(rbUseSelfSignedCertificate);
@@ -402,19 +398,16 @@
         getMsg("jks-certificate-label"),
         getMsg("jks-certificate-tooltip"),
         UIFactory.TextStyle.SECONDARY_FIELD_VALID);
-    rbJKS.setOpaque(false);
     rbJKS.addActionListener(l);
     rbPKCS11 = UIFactory.makeJRadioButton(
         getMsg("pkcs11-certificate-label"),
         getMsg("pkcs11-certificate-tooltip"),
         UIFactory.TextStyle.SECONDARY_FIELD_VALID);
-    rbPKCS11.setOpaque(false);
     rbPKCS11.addActionListener(l);
     rbPKCS12 = UIFactory.makeJRadioButton(
         getMsg("pkcs12-certificate-label"),
         getMsg("pkcs12-certificate-tooltip"),
         UIFactory.TextStyle.SECONDARY_FIELD_VALID);
-    rbPKCS12.setOpaque(false);
     rbPKCS12.addActionListener(l);
     ButtonGroup group2 = new ButtonGroup();
     group2.add(rbJKS);
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java
index 0496457..f9d9a03 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java
@@ -493,6 +493,11 @@
   private static final HashMap<IconType, ImageIcon> hmIcons =
       new HashMap<IconType, ImageIcon>();
 
+  static {
+    UIManager.put("OptionPane.background",Color.WHITE);
+    UIManager.put("Panel.background",Color.WHITE);
+  }
+
   /**
    * The following enumeration contains the different icons that we can have.
    *
@@ -839,7 +844,7 @@
       TextStyle style)
   {
     JRadioButton rb = new JRadioButton();
-
+    rb.setOpaque(false);
     if (text != null)
     {
       rb.setText(text);
@@ -867,7 +872,7 @@
       TextStyle style)
   {
     JCheckBox cb = new JCheckBox();
-
+    cb.setOpaque(false);
     if (text != null)
     {
       cb.setText(text);
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebProxyDialog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebProxyDialog.java
index 9825931..49639e0 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebProxyDialog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebProxyDialog.java
@@ -305,7 +305,10 @@
     gbc.gridy = 2;
     gbc.fill = GridBagConstraints.HORIZONTAL;
     gbc.insets.top = 0;
-    p.add(chkRequiresAuth = new JCheckBox("Required by proxy"), gbc);
+    p.add(chkRequiresAuth =
+            UIFactory.makeJCheckBox("Required by proxy","",
+                    UIFactory.TextStyle.SECONDARY_FIELD_VALID
+            ), gbc);
     chkRequiresAuth.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent actionEvent) {
         tfUserName.setEnabled(chkRequiresAuth.isSelected());
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java
index 34a8a6b..b755818 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java
@@ -30,37 +30,40 @@
 import org.opends.quicksetup.upgrader.RemoteBuildManager;
 import org.opends.quicksetup.ui.CustomHTMLEditorKit;
 import org.opends.quicksetup.ui.UIFactory;
+import org.opends.quicksetup.ui.WebProxyDialog;
+import org.opends.quicksetup.i18n.ResourceProvider;
 
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
-import java.net.Proxy;
-import java.net.SocketAddress;
-import java.net.URL;
+import java.net.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.lang.reflect.InvocationTargetException;
 
 /**
-   * This panel represents the big error message the pops up when the
+ * This panel represents the big error message the pops up when the
  * panel can't download the build information.
  */
 class BuildListDownloadErrorPanel extends JPanel {
 
+  static private final Logger LOG =
+          Logger.getLogger(BuildListDownloadErrorPanel.class.getName());
+
   private RemoteBuildManager rbm = null;
   private Throwable reason = null;
-  private ChooseVersionPanel chooseVersionPanel;
 
   private static final long serialVersionUID = 4614415561629811272L;
 
   /**
    * Creates an instance.
-   * @param rbm RemoteBuildManager that is having trouble.
+   *
+   * @param rbm    RemoteBuildManager that is having trouble.
    * @param reason Throwable indicating the error when downloading
-   * @param chooseVersionPanel ChooseVersionPanel where the error occurred
    */
-  public BuildListDownloadErrorPanel(ChooseVersionPanel chooseVersionPanel,
-                                     RemoteBuildManager rbm,
+  public BuildListDownloadErrorPanel(RemoteBuildManager rbm,
                                      Throwable reason) {
-    this.chooseVersionPanel = chooseVersionPanel;
     this.rbm = rbm;
     this.reason = reason;
     layoutPanel();
@@ -83,11 +86,11 @@
     }
 
     String html =
-            chooseVersionPanel.getMsg("upgrade-choose-version-build-list-error",
-            new String[]{
-                    baseContext,
-                    reason.getLocalizedMessage(),
-                    proxyString});
+            getMsg("upgrade-choose-version-build-list-error",
+                    new String[]{
+                            baseContext,
+                            reason.getLocalizedMessage(),
+                            proxyString});
 
     /* This helps with debugger the HTML rendering
     StringBuffer content = new StringBuffer();
@@ -107,7 +110,7 @@
     CustomHTMLEditorKit ek = new CustomHTMLEditorKit();
     ek.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent ev) {
-        chooseVersionPanel.specifyProxy(getParent());
+        specifyProxy(getParent());
 
         // Since the proxy info may change we need
         // to regenerate the text
@@ -120,4 +123,112 @@
     add(UIFactory.makeHtmlPane(html, ek, UIFactory.INSTRUCTIONS_FONT));
   }
 
+  /**
+   * Returns a localized message for a key value.  In  the properties file we
+   * have something of type:
+   * key=value
+   * <p/>
+   * For instance if we pass as key "mykey" and as arguments {"value1"} and
+   * in the properties file we have:
+   * mykey=value with argument {0}.
+   * <p/>
+   * This method will return "value with argument value1".
+   *
+   * @param key  the key in the properties file.
+   * @param args the arguments to be passed to generate the resulting value.
+   * @return the value associated to the key in the properties file.
+   * @see org.opends.quicksetup.i18n.ResourceProvider#getMsg(String,String[])
+   */
+  public String getMsg(String key, String[] args) {
+    return getI18n().getMsg(key, args);
+  }
+
+  /**
+   * Returns a ResourceProvider instance.
+   *
+   * @return a ResourceProvider instance.
+   */
+  public ResourceProvider getI18n() {
+    return ResourceProvider.getInstance();
+  }
+
+  /**
+   * Displays a dialog prompting the user for proxy information
+   * after which applys the new proxy information to the available
+   * RemoteBuildManager.
+   *
+   * @param parent Component that will server as parent to the dialog
+   */
+  void specifyProxy(final Component parent) {
+    Runnable proxySpecifier = new Runnable() {
+      public void run() {
+        String host = null;
+        Integer port = null;
+        Proxy proxy = rbm.getProxy();
+        if (proxy != null) {
+          SocketAddress address = proxy.address();
+          if (address instanceof InetSocketAddress) {
+            host = ((InetSocketAddress) address).getHostName();
+            port = ((InetSocketAddress) address).getPort();
+          }
+        }
+        String user = rbm.getProxyUserName();
+        char[] pw = rbm.getProxyPassword();
+        WebProxyDialog dlg;
+        if (parent instanceof Dialog) {
+          dlg = new WebProxyDialog((Dialog) parent, host, port, user, pw);
+        } else if (parent instanceof Frame) {
+          dlg = new WebProxyDialog((Frame) parent, host, port, user, pw);
+        } else {
+          dlg = new WebProxyDialog((Frame) null, host, port, user, pw);
+        }
+        dlg.setVisible(true);
+        SocketAddress address = dlg.getSocketAddress();
+        if (address != null) {
+          proxy = new Proxy(Proxy.Type.HTTP, address);
+          rbm.setProxy(proxy);
+          rbm.setProxyUserName(dlg.getUserName());
+          rbm.setProxyPassword(dlg.getPassword());
+        }
+      }
+    };
+    if (SwingUtilities.isEventDispatchThread()) {
+      proxySpecifier.run();
+    } else {
+      try {
+        SwingUtilities.invokeAndWait(proxySpecifier);
+      } catch (InterruptedException e) {
+        LOG.log(Level.INFO, "error", e);
+      } catch (InvocationTargetException e) {
+        LOG.log(Level.INFO, "error", e);
+      } catch (Throwable t) {
+        LOG.log(Level.INFO, "error", t);
+      }
+    }
+  }
+
+//  public static void main(String[] args) {
+//    String[] options = {"Retry", "Close"};
+//    try {
+//      JOptionPane op = new JOptionPane(
+//      //JOptionPane.showOptionDialog(null,
+//              new BuildListDownloadErrorPanel(
+//                      new RemoteBuildManager(null,
+//                              new URL("http://builds.opends.org")),
+//                      new IllegalArgumentException("abc")),
+//              JOptionPane.ERROR_MESSAGE,
+//              JOptionPane.YES_NO_OPTION,
+//              null,
+//              options,
+//              null);
+//      op.setBackground(Color.WHITE);
+//      //op.getRootPane().setBackground(Color.WHITE);
+//      JDialog dlg = op.createDialog(null, "Network Error");
+//      dlg.getContentPane().setBackground(Color.WHITE);
+//      dlg.setVisible(true);
+//    } catch (MalformedURLException e) {
+//      e.printStackTrace();
+//    }
+//  }
+
 }
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java
index ba14398..6ec0fec 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java
@@ -28,12 +28,7 @@
 package org.opends.quicksetup.upgrader.ui;
 
 import org.opends.quicksetup.UserData;
-import org.opends.quicksetup.ui.FieldName;
-import org.opends.quicksetup.ui.GuiApplication;
-import org.opends.quicksetup.ui.QuickSetupStepPanel;
-import org.opends.quicksetup.ui.UIFactory;
-import org.opends.quicksetup.ui.Utilities;
-import org.opends.quicksetup.ui.WebProxyDialog;
+import org.opends.quicksetup.ui.*;
 import org.opends.quicksetup.upgrader.Build;
 import org.opends.quicksetup.upgrader.RemoteBuildManager;
 import org.opends.quicksetup.upgrader.Upgrader;
@@ -42,11 +37,6 @@
 import javax.swing.*;
 import java.awt.*;
 import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.SocketAddress;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
@@ -218,62 +208,6 @@
   }
 
   /**
-   * Displays a dialog prompting the user for proxy information
-   * after which applys the new proxy information to the available
-   * RemoteBuildManager.
-   * @param parent Component that will server as parent to the dialog
-   */
-  void specifyProxy(final Component parent) {
-    Runnable proxySpecifier = new Runnable() {
-      public void run() {
-        String host = null;
-        Integer port = null;
-        RemoteBuildManager rbm =
-                ((Upgrader) getApplication()).getRemoteBuildManager();
-        Proxy proxy = rbm.getProxy();
-        if (proxy != null) {
-          SocketAddress address = proxy.address();
-          if (address instanceof InetSocketAddress) {
-            host = ((InetSocketAddress) address).getHostName();
-            port = ((InetSocketAddress) address).getPort();
-          }
-        }
-        String user = rbm.getProxyUserName();
-        char[] pw = rbm.getProxyPassword();
-        WebProxyDialog dlg;
-        if (parent instanceof Dialog) {
-          dlg = new WebProxyDialog((Dialog) parent, host, port, user, pw);
-        } else if (parent instanceof Frame) {
-          dlg = new WebProxyDialog((Frame) parent, host, port, user, pw);
-        } else {
-          dlg = new WebProxyDialog((Frame) null, host, port, user, pw);
-        }
-        dlg.setVisible(true);
-        SocketAddress address = dlg.getSocketAddress();
-        if (address != null) {
-          proxy = new Proxy(Proxy.Type.HTTP, address);
-          rbm.setProxy(proxy);
-          rbm.setProxyUserName(dlg.getUserName());
-          rbm.setProxyPassword(dlg.getPassword());
-        }
-      }
-    };
-    if (SwingUtilities.isEventDispatchThread()) {
-      proxySpecifier.run();
-    } else {
-      try {
-        SwingUtilities.invokeAndWait(proxySpecifier);
-      } catch (InterruptedException e) {
-        LOG.log(Level.INFO, "error", e);
-      } catch (InvocationTargetException e) {
-        LOG.log(Level.INFO, "error", e);
-      } catch (Throwable t) {
-        LOG.log(Level.INFO, "error", t);
-      }
-    }
-  }
-
-  /**
    * Renders the combo box when there has been an error downloading
    * the build information.
    */
@@ -343,7 +277,7 @@
         try {
         String[] options = { "Retry", "Close" };
         int i = JOptionPane.showOptionDialog(getMainWindow(),
-                new BuildListDownloadErrorPanel(ChooseVersionPanel.this, rbm,
+                new BuildListDownloadErrorPanel(rbm,
                         throwable),
                 "Network Error",
                 JOptionPane.YES_NO_OPTION,
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
index 1ebf08c..9b255bd 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
@@ -204,7 +204,6 @@
       checkBox =
           UIFactory.makeJCheckBox(getMsg("upgrade-review-panel-start-server"),
               getMsg("start-server-tooltip"), UIFactory.TextStyle.CHECKBOX);
-      checkBox.setOpaque(false);
       checkBox.setSelected(getApplication().getUserData().getStartServer());
     }
     return checkBox;

--
Gitblit v1.10.0