From 4cd4ffb2771ea2d133b30273b1ffea0fef6b4552 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Tue, 17 Apr 2007 20:23:12 +0000
Subject: [PATCH] This commit introduces preliminary versions of the upgrader tool's GUI wizard panels.  Effort has been made to make the panels conform to the design at

---
 opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java |   92 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 76 insertions(+), 16 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java b/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java
index c4cad53..4b9b33d 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java
@@ -36,22 +36,8 @@
 import java.awt.Toolkit;
 import java.util.HashMap;
 
-import javax.swing.BorderFactory;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComponent;
-import javax.swing.JEditorPane;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JPasswordField;
-import javax.swing.JRadioButton;
-import javax.swing.JScrollBar;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.ListCellRenderer;
-import javax.swing.UIManager;
+import javax.swing.*;
+import javax.swing.text.JTextComponent;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 
@@ -645,6 +631,14 @@
   }
 
   /**
+   * Creates a JComboBox.
+   * @return JComboBox a new combo box
+   */
+  static public JComboBox makeJComboBox() {
+    return new JComboBox();
+  }
+
+  /**
    * Creates a JButton with the given label and tooltip.
    * @param label the text of the button.
    * @param tooltip the tooltip of the button.
@@ -670,6 +664,24 @@
   }
 
   /**
+   * Commodity method that returns a JLabel based on a LabelFieldDescriptor.
+   * @param desc the LabelFieldDescriptor describing the JLabel.
+   * @return a JLabel based on a LabelFieldDescriptor.
+   */
+  static public JLabel makeJLabel(LabelFieldDescriptor desc)
+  {
+    UIFactory.TextStyle style;
+    if (desc.getLabelType() == LabelFieldDescriptor.LabelType.PRIMARY)
+    {
+      style = UIFactory.TextStyle.PRIMARY_FIELD_VALID;
+    } else
+    {
+      style = UIFactory.TextStyle.SECONDARY_FIELD_VALID;
+    }
+    return makeJLabel(UIFactory.IconType.NO_ICON, desc.getLabel(), style);
+  }
+
+  /**
    * Creates a JLabel with the given icon, text and text style.
    * @param iconName the icon.
    * @param text the label text.
@@ -700,6 +712,47 @@
   }
 
   /**
+   * Commodity method that returns a JTextComponent based on a
+   * LabelFieldDescriptor.
+   * @param desc the LabelFieldDescriptor describing the JTextField.
+   * @param defaultValue the default value used to initialize the
+   * JTextComponent.
+   * @return a JTextComponent based on a
+   * LabelFieldDescriptor.
+   */
+  static public JTextComponent makeJTextComponent(LabelFieldDescriptor desc,
+      String defaultValue)
+  {
+    JTextComponent field;
+    switch (desc.getType())
+    {
+    case TEXTFIELD:
+
+      field =
+          makeJTextField(defaultValue, desc.getTooltip(), desc
+              .getSize(), TextStyle.TEXTFIELD);
+      break;
+
+    case PASSWORD:
+
+      field =
+          makeJPasswordField(defaultValue, desc.getTooltip(), desc
+              .getSize(), TextStyle.PASSWORD_FIELD);
+      break;
+
+    case READ_ONLY:
+
+      field =
+          makeTextPane(defaultValue, TextStyle.READ_ONLY);
+      break;
+
+    default:
+      throw new IllegalArgumentException("Unknown type: " + desc.getType());
+    }
+    return field;
+  }
+
+  /**
    * Creates a JTextField with the given icon, tooltip text, size and text
    * style.
    * @param text the text.
@@ -910,6 +963,9 @@
    */
   public static ImageIcon getImageIcon(IconType iconType)
   {
+    if (iconType == null) {
+      iconType = IconType.NO_ICON;
+    }
     ImageIcon icon = hmIcons.get(iconType);
     if ((icon == null) && (iconType != IconType.NO_ICON))
     {
@@ -979,6 +1035,7 @@
     setTextStyle(pane, style);
     pane.setEditable(false);
     pane.setBorder(new EmptyBorder(0, 0, 0, 0));
+    pane.setOpaque(false);
     return pane;
   }
 
@@ -1357,6 +1414,9 @@
    */
   private static String getIconTooltip(IconType iconType)
   {
+    if (iconType == null) {
+      iconType = IconType.NO_ICON;
+    }
     String tooltip;
     switch (iconType)
     {

--
Gitblit v1.10.0