mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
28.21.2015 c49cdeba466abea9cebd03b2b2d73e20644d25d0
opendj-server-legacy/src/main/java/org/opends/quicksetup/ui/UIFactory.java
@@ -24,204 +24,156 @@
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 */
package org.opends.quicksetup.ui;
import org.forgerock.i18n.LocalizableMessage;
import static org.opends.messages.QuickSetupMessages.*;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.text.JTextComponent;
import javax.swing.text.html.HTMLEditorKit;
import java.awt.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
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.JPanel;
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.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.text.JTextComponent;
import javax.swing.text.html.HTMLEditorKit;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import static org.opends.messages.QuickSetupMessages.*;
/**
 * This class provides constants an methods to create Swing objects and to
 * generate UI elements with a common look and feel.
 *
 * <p>
 * When we want to change a color, a background or a font this is the class
 * that should be modified.
 *
 */
public class UIFactory
{
  private static boolean initialized;
  private static String parentPackagePath;
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /**
   * Specifies the horizontal insets between buttons.
   */
  /** Specifies the horizontal insets between buttons. */
  public static final int HORIZONTAL_INSET_BETWEEN_BUTTONS = 5;
  /**
   * Specifies the top inset for the steps.
   */
  /** Specifies the top inset for the steps. */
  public static final int TOP_INSET_STEP = 15;
  /**
   * Specifies the left inset for the steps.
   */
  /** Specifies the left inset for the steps. */
  public static final int LEFT_INSET_STEP = 5;
  /**
   * Specifies the extra left inset for the sub-steps.
   */
  /** Specifies the extra left inset for the sub-steps. */
  public static final int LEFT_INSET_SUBSTEP = 20;
  /**
   * Specifies the top inset for the instructions sub panel.
   */
  /** Specifies the top inset for the instructions sub panel. */
  public static final int TOP_INSET_INSTRUCTIONS_SUBPANEL = 5;
  /**
   * Specifies the top inset for input subpanel.
   */
  /** Specifies the top inset for input subpanel. */
  public static final int TOP_INSET_INPUT_SUBPANEL = 10;
  /**
   * Specifies the top inset for a primary field.
   */
  /** Specifies the top inset for a primary field. */
  public static final int TOP_INSET_PRIMARY_FIELD = 10;
  /**
   * Specifies the top inset for a secondary field.
   */
  /** Specifies the top inset for a secondary field. */
  public static final int TOP_INSET_SECONDARY_FIELD = 5;
  /**
   * Specifies the top inset for a radio button.
   */
  /** Specifies the top inset for a radio button. */
  public static final int TOP_INSET_RADIOBUTTON = 0;
  /**
   * Specifies the top inset for a radio button subordinate panel.
   */
  /** Specifies the top inset for a radio button subordinate panel. */
  public static final int TOP_INSET_RADIO_SUBORDINATE = 0;
  /**
   * Specifies the top inset for the progress bar.
   */
  /** Specifies the top inset for the progress bar. */
  public static final int TOP_INSET_PROGRESS_BAR = 5;
  /**
   * Specifies the top inset for the progress text area.
   */
  /** Specifies the top inset for the progress text area. */
  public static final int TOP_INSET_PROGRESS_TEXTAREA = 4;
  /**
   * Specifies the top inset for the background image.
   */
  /** Specifies the top inset for the background image. */
  public static final int TOP_INSET_BACKGROUND = 70;
  /**
   * Specifies the top inset for the error message.
   */
  /** Specifies the top inset for the error message. */
  public static final int TOP_INSET_ERROR_MESSAGE = 10;
  /**
   * Specifies the top inset for the browse button.
   */
  /** Specifies the top inset for the browse button. */
  public static final int TOP_INSET_BROWSE = 5;
  /**
   * Specifies the right inset for background image.
   */
  /** Specifies the right inset for background image. */
  public static final int RIGHT_INSET_BACKGROUND = 20;
  /**
   * Specifies the left inset for the primary field.
   */
  /** Specifies the left inset for the primary field. */
  public static final int LEFT_INSET_PRIMARY_FIELD = 10;
  /**
   * Specifies the left inset for the browse button.
   */
  /** Specifies the left inset for the browse button. */
  public static final int LEFT_INSET_BROWSE = 10;
  /**
   * Specifies the left inset for radio subordinate panel.
   */
  /** Specifies the left inset for radio subordinate panel. */
  public static final int LEFT_INSET_RADIO_SUBORDINATE = 35;
  /**
   * Specifies the left inset for the secondary field.
   */
  /** Specifies the left inset for the secondary field. */
  public static final int LEFT_INSET_SECONDARY_FIELD = 5;
  /**
   * Specifies the left inset for the background image.
   */
  /** Specifies the left inset for the background image. */
  public static final int LEFT_INSET_BACKGROUND = 20;
  /**
   * Specifies the left inset for the copy url button.
   */
  /** Specifies the left inset for the copy url button. */
  public static final int LEFT_INSET_COPY_BUTTON = 10;
  /**
   * Specifies the left inset for a subordinate subpanel.
   */
  /** Specifies the left inset for a subordinate subpanel. */
  public static final int LEFT_INSET_SUBPANEL_SUBORDINATE = 30;
  /**
   * Specifies the left inset for the progress bar.
   */
  /** Specifies the left inset for the progress bar. */
  public static final int BOTTOM_INSET_PROGRESS_BAR = 10;
  /**
   * Specifies the bottom inset for the background image.
   */
  /** Specifies the bottom inset for the background image. */
  public static final int BOTTOM_INSET_BACKGROUND = 30;
  /**
   * Specifies the top inset for a secondary field.
   */
  /** Specifies the top inset for a secondary field. */
  public static final int BOTTOM_INSET_SECONDARY_FIELD = 5;
  /**
   * Specifies the number of columns of a text field for a path.
   */
  /** Specifies the number of columns of a text field for a path. */
  public static final int PATH_FIELD_SIZE = 20;
  /**
   * Specifies the number of columns of a text field for a relative path.
   */
  /** Specifies the number of columns of a text field for a relative path. */
  public static final int RELATIVE_PATH_FIELD_SIZE = 10;
  /**
   * Specifies the number of columns of a text field for a host name.
   */
  /** Specifies the number of columns of a text field for a host name. */
  public static final int HOST_FIELD_SIZE = 20;
  /**
   * Specifies the number of columns of a text field for a UID.
   */
  /** Specifies the number of columns of a text field for a UID. */
  public static final int UID_FIELD_SIZE = 15;
  /**
   * Specifies the number of columns of a text field for a port.
   */
  /** Specifies the number of columns of a text field for a port. */
  public static final int PORT_FIELD_SIZE = 5;
  /**
   * Specifies the number of columns of a text field for a dn.
   */
  /** Specifies the number of columns of a text field for a dn. */
  public static final int DN_FIELD_SIZE = 20;
  /**
   * Specifies the number of columns of a text field for a password.
   */
  /** Specifies the number of columns of a text field for a password. */
  public static final int PASSWORD_FIELD_SIZE = 15;
  /**
@@ -229,14 +181,12 @@
   */
  public static final int NUMBER_ENTRIES_FIELD_SIZE = 7;
  /**
   * Specifies the number of points for the width of the progress bar.
   */
  /** Specifies the number of points for the width of the progress bar. */
  public static final int PROGRESS_BAR_SIZE = 220;
  /**
   * Specifies the number of extra points that we add to the minimum size of
   * the dialog.
   * Specifies the number of extra points that we add to the minimum size of the
   * dialog.
   */
  public static final int EXTRA_DIALOG_HEIGHT = 75;
@@ -244,257 +194,150 @@
  private static final Insets STEPS_PANEL_INSETS = new Insets(15, 10, 5, 10);
  private static final Insets CURRENT_STEP_PANEL_INSETS =
      new Insets(15, 15, 15, 15);
  private static final Insets CURRENT_STEP_PANEL_INSETS = new Insets(15, 15, 15, 15);
  private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
  /**
   * Specifies the default background color.
   */
  public static final Color DEFAULT_BACKGROUND =
          getColor(INFO_DEFAULT_BACKGROUND_COLOR.get());
  /** Specifies the default background color. */
  public static final Color DEFAULT_BACKGROUND = getColor(INFO_DEFAULT_BACKGROUND_COLOR.get());
  /**
   * Specifies the current step background color.
   */
  public static final Color CURRENT_STEP_PANEL_BACKGROUND =
          getColor(INFO_CURRENT_STEP_PANEL_BACKGROUND_COLOR.get());
  /** Specifies the current step background color. */
  public static final Color CURRENT_STEP_PANEL_BACKGROUND = getColor(INFO_CURRENT_STEP_PANEL_BACKGROUND_COLOR.get());
  /**
   * Specifies the default label color.
   */
  public static final Color DEFAULT_LABEL_COLOR =
          getColor(INFO_DEFAULT_LABEL_COLOR.get());
  /** Specifies the default label color. */
  public static final Color DEFAULT_LABEL_COLOR = getColor(INFO_DEFAULT_LABEL_COLOR.get());
  /**
   * Specifies the valid field color.
   */
  public static final Color FIELD_VALID_COLOR =
          getColor(INFO_FIELD_VALID_COLOR.get());
  /** Specifies the valid field color. */
  public static final Color FIELD_VALID_COLOR = getColor(INFO_FIELD_VALID_COLOR.get());
  /**
   * Specifies the invalid field color.
   */
  public static final Color FIELD_INVALID_COLOR =
          getColor(INFO_FIELD_INVALID_COLOR.get());
  /** Specifies the invalid field color. */
  public static final Color FIELD_INVALID_COLOR = getColor(INFO_FIELD_INVALID_COLOR.get());
  /**
   * Specifies the read only text color.
   */
  public static final Color READ_ONLY_COLOR =
          getColor(INFO_READ_ONLY_COLOR.get());
  /** Specifies the read only text color. */
  public static final Color READ_ONLY_COLOR = getColor(INFO_READ_ONLY_COLOR.get());
  /**
   * Specifies the check box text color.
   */
  public static final Color CHECKBOX_COLOR =
          getColor(INFO_CHECKBOX_COLOR.get());
  /** Specifies the check box text color. */
  public static final Color CHECKBOX_COLOR = getColor(INFO_CHECKBOX_COLOR.get());
  /**
   * Specifies the progress text color.
   */
  public static final Color PROGRESS_COLOR =
          getColor(INFO_PROGRESS_COLOR.get());
  /** Specifies the progress text color. */
  public static final Color PROGRESS_COLOR = getColor(INFO_PROGRESS_COLOR.get());
  /**
   * Specifies the instructions text color.
   */
  public static final Color INSTRUCTIONS_COLOR =
          getColor(INFO_INSTRUCTIONS_COLOR.get());
  /** Specifies the instructions text color. */
  public static final Color INSTRUCTIONS_COLOR = getColor(INFO_INSTRUCTIONS_COLOR.get());
  /**
   * Specifies the text field text color.
   */
  public static final Color TEXTFIELD_COLOR =
          getColor(INFO_TEXTFIELD_COLOR.get());
  /** Specifies the text field text color. */
  public static final Color TEXTFIELD_COLOR = getColor(INFO_TEXTFIELD_COLOR.get());
  /**
   * Specifies the password field text color.
   */
  public static final Color PASSWORDFIELD_COLOR =
          getColor(INFO_PASSWORDFIELD_COLOR.get());
  /** Specifies the password field text color. */
  public static final Color PASSWORDFIELD_COLOR = getColor(INFO_PASSWORDFIELD_COLOR.get());
  /**
   * Specifies the in-line help text color.
   */
  public static final Color INLINE_HELP_COLOR =
          getColor(INFO_INLINE_HELP_COLOR.get());
  /** Specifies the in-line help text color. */
  public static final Color INLINE_HELP_COLOR = getColor(INFO_INLINE_HELP_COLOR.get());
  /**
   * Specifies the panel border color.
   */
  public static final Color PANEL_BORDER_COLOR =
          getColor(INFO_PANEL_BORDER_COLOR.get());
  /** Specifies the panel border color. */
  public static final Color PANEL_BORDER_COLOR = getColor(INFO_PANEL_BORDER_COLOR.get());
  /**
   * Specifies the current step panel border.
   */
  /** Specifies the current step panel border. */
  public static final Border CURRENT_STEP_PANEL_BORDER =
          BorderFactory.createMatteBorder(0, 2, 2, 0, PANEL_BORDER_COLOR);
      BorderFactory.createMatteBorder(0, 2, 2, 0, PANEL_BORDER_COLOR);
  /**
   * Specifies the text area border.
   */
  /** Specifies the text area border. */
  public static final Border TEXT_AREA_BORDER =
          BorderFactory.createMatteBorder(1, 1, 1, 1,
                  getColor(INFO_TEXT_AREA_BORDER_COLOR.get()));
      BorderFactory.createMatteBorder(1, 1, 1, 1, getColor(INFO_TEXT_AREA_BORDER_COLOR.get()));
  /**
   * Specifies the dialog border.
   */
  public static final Border DIALOG_PANEL_BORDER =
    BorderFactory.createMatteBorder(0, 0, 2, 0, PANEL_BORDER_COLOR);
  /** Specifies the dialog border. */
  public static final Border DIALOG_PANEL_BORDER = BorderFactory.createMatteBorder(0, 0, 2, 0, PANEL_BORDER_COLOR);
  private static Font defaultFont;
  private static Font DEFAULT_FONT;
  static
  {
    try
    {
      defaultFont = UIManager.getFont("Label.font").deriveFont(Font.PLAIN).
      deriveFont(12f);
      DEFAULT_FONT = UIManager.getFont("Label.font").deriveFont(Font.PLAIN).deriveFont(12f);
    }
    catch (Throwable t)
    {
      defaultFont = Font.decode("SansSerif-PLAIN-12");
      DEFAULT_FONT = Font.decode("SansSerif-PLAIN-12");
    }
  }
  /**
   * Specifies the font for the step which is not the current one in the steps
   * panel.
   */
  public static final Font NOT_CURRENT_STEP_FONT = defaultFont.deriveFont(14f);
  public static final Font NOT_CURRENT_STEP_FONT = DEFAULT_FONT.deriveFont(14f);
  /**
   * Specifies the font for the step which is the current one in the steps
   * panel.
   */
  public static final Font CURRENT_STEP_FONT =
    defaultFont.deriveFont(14f).deriveFont(Font.BOLD);
  public static final Font CURRENT_STEP_FONT = DEFAULT_FONT.deriveFont(14f).deriveFont(Font.BOLD);
  /**
   * Specifies the font for the title of the current panel.
   */
  public static final Font TITLE_FONT =
    defaultFont.deriveFont(14f).deriveFont(Font.BOLD);
  /** Specifies the font for the title of the current panel. */
  public static final Font TITLE_FONT = DEFAULT_FONT.deriveFont(14f).deriveFont(Font.BOLD);
  /**
   * Specifies the font for the instructions of the current panel.
   */
  public static final Font INSTRUCTIONS_FONT = defaultFont;
  /** Specifies the font for the instructions of the current panel. */
  public static final Font INSTRUCTIONS_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the instructions of the current panel.
   */
  public static final Font INSTRUCTIONS_MONOSPACE_FONT =
    Font.decode("Monospaced-PLAIN-14");
  /** Specifies the font for the instructions of the current panel. */
  public static final Font INSTRUCTIONS_MONOSPACE_FONT = Font.decode("Monospaced-PLAIN-14");
  /**
   * Specifies the font for the primary valid field.
   */
  public static final Font PRIMARY_FIELD_VALID_FONT =
    defaultFont.deriveFont(Font.BOLD);
  /** Specifies the font for the primary valid field. */
  public static final Font PRIMARY_FIELD_VALID_FONT = DEFAULT_FONT.deriveFont(Font.BOLD);
  /**
   * Specifies the font for the secondary valid field.
   */
  public static final Font SECONDARY_FIELD_VALID_FONT = defaultFont;
  /** Specifies the font for the secondary valid field. */
  public static final Font SECONDARY_FIELD_VALID_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the primary invalid field.
   */
  public static final Font PRIMARY_FIELD_INVALID_FONT =
    defaultFont.deriveFont(Font.BOLD | Font.ITALIC);
  /** Specifies the font for the primary invalid field. */
  public static final Font PRIMARY_FIELD_INVALID_FONT = DEFAULT_FONT.deriveFont(Font.BOLD | Font.ITALIC);
  /**
   * Specifies the font for the secondary invalid field.
   */
  public static final Font SECONDARY_FIELD_INVALID_FONT =
    defaultFont.deriveFont(Font.ITALIC);
  /** Specifies the font for the secondary invalid field. */
  public static final Font SECONDARY_FIELD_INVALID_FONT = DEFAULT_FONT.deriveFont(Font.ITALIC);
  /**
   * Specifies the font for the secondary status field.
   */
  public static final Font SECONDARY_STATUS_FONT =
    defaultFont.deriveFont(Font.ITALIC);
  /** Specifies the font for the secondary status field. */
  public static final Font SECONDARY_STATUS_FONT = DEFAULT_FONT.deriveFont(Font.ITALIC);
  /**
   * Specifies the font for read only text.
   */
  public static final Font READ_ONLY_FONT = defaultFont;
  /** Specifies the font for read only text. */
  public static final Font READ_ONLY_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the check box text.
   */
  public static final Font CHECKBOX_FONT = defaultFont;
  /** Specifies the font for the check box text. */
  public static final Font CHECKBOX_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the progress text.
   */
  public static final Font PROGRESS_FONT = defaultFont;
  /** Specifies the font for the progress text. */
  public static final Font PROGRESS_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the text field text.
   */
  public static final Font TEXTFIELD_FONT = defaultFont;
  /** Specifies the font for the text field text. */
  public static final Font TEXTFIELD_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the password field text.
   */
  public static final Font PASSWORD_FIELD_FONT = defaultFont;
  /** Specifies the font for the password field text. */
  public static final Font PASSWORD_FIELD_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the points '....' in the progress panel.
   */
  public static final Font PROGRESS_POINTS_FONT =
    defaultFont.deriveFont(Font.BOLD);
  /** Specifies the font for the points '....' in the progress panel. */
  public static final Font PROGRESS_POINTS_FONT = DEFAULT_FONT.deriveFont(Font.BOLD);
  /**
   * Specifies the font for the done text 'Done' in the progress panel.
   */
  /** Specifies the font for the done text 'Done' in the progress panel. */
  public static final Font PROGRESS_DONE_FONT = PROGRESS_POINTS_FONT;
  /**
   * Specifies the font for the log messages in the progress panel.
   */
  public static final Font PROGRESS_LOG_FONT =
      Font.decode("Monospaced-PLAIN-12");
  /** Specifies the font for the log messages in the progress panel. */
  public static final Font PROGRESS_LOG_FONT = Font.decode("Monospaced-PLAIN-12");
  /**
   * Specifies the font for the error log messages in the progress panel.
   */
  public static final Font PROGRESS_LOG_ERROR_FONT =
      Font.decode("Monospaced-PLAIN-12");
  /** Specifies the font for the error log messages in the progress panel. */
  public static final Font PROGRESS_LOG_ERROR_FONT = Font.decode("Monospaced-PLAIN-12");
  /**
   * Specifies the font for the error messages in the progress panel.
   */
  public static final Font PROGRESS_ERROR_FONT =
    defaultFont.deriveFont(Font.BOLD);
  /** Specifies the font for the error messages in the progress panel. */
  public static final Font PROGRESS_ERROR_FONT = DEFAULT_FONT.deriveFont(Font.BOLD);
  /**
   * Specifies the font for the warning messages in the progress panel.
   */
  public static final Font PROGRESS_WARNING_FONT =
    defaultFont.deriveFont(Font.BOLD);
  /** Specifies the font for the warning messages in the progress panel. */
  public static final Font PROGRESS_WARNING_FONT = DEFAULT_FONT.deriveFont(Font.BOLD);
  /**
   * Specifies the font for the stack trace in the progress panel.
   */
  public static final Font STACK_FONT = defaultFont;
  /** Specifies the font for the stack trace in the progress panel. */
  public static final Font STACK_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the text in the WebBrowserErrorDialog.
   */
  public static final Font ERROR_DIALOG_FONT = defaultFont;
  /** Specifies the font for the text in the WebBrowserErrorDialog. */
  public static final Font ERROR_DIALOG_FONT = DEFAULT_FONT;
  /**
   * Specifies the font for the text in the in-line help.
   */
  public static final Font INLINE_HELP_FONT = defaultFont.deriveFont(
      (float)(defaultFont.getSize() - 2));
  /** Specifies the font for the text in the in-line help. */
  public static final Font INLINE_HELP_FONT = DEFAULT_FONT.deriveFont((float) (DEFAULT_FONT.getSize() - 2));
  private static final String SPAN_CLOSE = "</span>";
@@ -510,8 +353,7 @@
    INFO_DIV_OPEN_ERROR_BACKGROUND_3_COLOR.get()+
    ";vertical-align:middle;text-align:left\">";
  private static final String DIV_OPEN_WARNING_BACKGROUND =
      DIV_OPEN_ERROR_BACKGROUND;
  private static final String DIV_OPEN_WARNING_BACKGROUND = DIV_OPEN_ERROR_BACKGROUND;
  private static final String DIV_OPEN_SUCCESSFUL_BACKGROUND =
    "<div style=\"color:#"+
@@ -523,195 +365,119 @@
    INFO_DIV_OPEN_SUCCESSFUL_BACKGROUND_3_COLOR.get()+
    ";vertical-align:middle;text-align:left\">";
  /**
   * An HTML separator text that can be used in the progress panel.
   */
  /** An HTML separator text that can be used in the progress panel. */
  public static final String HTML_SEPARATOR =
    "<div style=\"font-size:1px;background-color:#"+
    INFO_HTML_SEPARATOR_COLOR.get()+
    ";margin:10px 5px 10px 5px;\"></div>";
  private static final HashMap<IconType, ImageIcon> hmIcons =
      new HashMap<IconType, ImageIcon>();
  private static final HashMap<IconType, ImageIcon> hmIcons = new HashMap<>();
  /**
   * The following enumeration contains the different icons that we can have.
   *
   */
  /** The following enumeration contains the different icons that we can have. */
  public enum IconType
  {
    /**
     * Splash Icon.
     */
    /** Splash Icon. */
    SPLASH,
    /**
     * Current Step Icon.
     */
    /** Current Step Icon. */
    CURRENT_STEP,
    /**
     * The icon displayed by the OS when the dialog is minimized.
     */
    /** The icon displayed by the OS when the dialog is minimized. */
    MINIMIZED,
    /**
     * The icon displayed by the Mac OS when the dialog is minimized.
     */
    /** The icon displayed by the Mac OS when the dialog is minimized. */
    MINIMIZED_MAC,
    /**
     * The background icon.
     */
    /** The background icon. */
    BACKGROUND,
    /**
     * The warning icon.
     */
    /** The warning icon. */
    WARNING,
    /**
     * The warning large icon.
     */
    /** The warning large icon. */
    WARNING_LARGE,
    /**
     * The error icon.
     */
    /** The error icon. */
    ERROR,
    /**
     * The error large icon.
     */
    /** The error large icon. */
    ERROR_LARGE,
    /**
     * The information icon.
     */
    /** The information icon. */
    INFORMATION,
    /**
     * The information large icon.
     */
    /** The information large icon. */
    INFORMATION_LARGE,
    /**
     * Icon to create subsection title in Status Panel.
     */
    /** Icon to create subsection title in Status Panel. */
    SUBSECTION_LEFT,
    /**
     * Icon to create subsection title in Status Panel.
     */
    /** Icon to create subsection title in Status Panel. */
    SUBSECTION_RIGHT,
    /**
     * Question icon.
     */
    /** Question icon. */
    HELP_SMALL,
    /**
     * Hourglass to display when the user must wait.
     */
    /** Hourglass to display when the user must wait. */
    WAIT,
    /**
     * 8 x 8 Hourglass to display when the user must wait.
     */
    /** 8 x 8 Hourglass to display when the user must wait. */
    WAIT_TINY,
    /**
     * No icon.
     */
    /** No icon. */
    NO_ICON
  }
  /**
   * The following enumeration contains the different text styles that we can
   * have.  A text style basically specifies the font and color to be used to
   * have. A text style basically specifies the font and color to be used to
   * render the text.
   *
   */
  public enum TextStyle
  {
    /**
     * Current Step label style for the steps panel.
     */
    /** Current Step label style for the steps panel. */
    CURRENT_STEP,
    /**
     * Not current Step label style for the steps panel.
     */
    /** Not current Step label style for the steps panel. */
    NOT_CURRENT_STEP,
    /**
     * Title label style for the current step panel.
     */
    /** Title label style for the current step panel. */
    TITLE,
    /**
     * Primary field valid label style for the current step panel.
     */
    /** Primary field valid label style for the current step panel. */
    PRIMARY_FIELD_VALID,
    /**
     * Primary field invalid text style for the current step panel.
     */
    /** Primary field invalid text style for the current step panel. */
    PRIMARY_FIELD_INVALID,
    /**
     * Secondary field valid text style for the current step panel.
     */
    /** Secondary field valid text style for the current step panel. */
    SECONDARY_FIELD_VALID,
    /**
     * Secondary field invalid text style for the current step panel.
     */
    /** Secondary field invalid text style for the current step panel. */
    SECONDARY_FIELD_INVALID,
    /**
     * Status messages that appear near components.
     */
    /** Status messages that appear near components. */
    SECONDARY_STATUS,
    /**
     * Textfield text style for the current step panel.
     */
    /** Textfield text style for the current step panel. */
    TEXTFIELD,
    /**
     * Password text style for the current step panel.
     */
    /** Password text style for the current step panel. */
    PASSWORD_FIELD,
    /**
     * Read only text style for the current step panel.
     */
    /** Read only text style for the current step panel. */
    READ_ONLY,
    /**
     * Check box text text style for the current step panel.
     */
    /** Check box text text style for the current step panel. */
    CHECKBOX,
    /**
     * Progress messages text style for the current step panel.
     */
    /** Progress messages text style for the current step panel. */
    PROGRESS,
    /**
     * Text style for the instructions.
     */
    /** Text style for the instructions. */
    INSTRUCTIONS,
    /**
     * In-line help style.
     */
    /** In-line help style. */
    INLINE_HELP,
    /**
     * No text style.
     */
    /** No text style. */
    NO_STYLE
  }
  /**
   * This method initialize the look and feel.
   * @throws Throwable if there is a problem initializing the look and feel.
   *
   * @throws Throwable
   *           if there is a problem initializing the look and feel.
   */
  public static void initializeLookAndFeel() throws Throwable
  {
    final Throwable[] ts = {null};
    final Throwable[] ts = { null };
    Runnable r = new Runnable()
    {
      @Override
      public void run()
      {
        System.setProperty("swing.aatext", "true");
        try
        {
          String lf = UIManager.getSystemLookAndFeelClassName();
          if (lf.equalsIgnoreCase(
              "com.sun.java.swing.plaf.motif.MotifLookAndFeel"))
          if ("com.sun.java.swing.plaf.motif.MotifLookAndFeel".equalsIgnoreCase(lf))
          {
            lf = UIManager.getCrossPlatformLookAndFeelClassName();
          }
          UIManager.setLookAndFeel(lf);
        } catch (Throwable t)
        }
        catch (Throwable t)
        {
          ts[0] = t;
        }
@@ -740,9 +506,11 @@
  }
  /**
   * This method initialize the look and feel and UI settings specific to
   * quick setup.
   * @throws Throwable if there is a problem initializing the look and feel.
   * This method initialize the look and feel and UI settings specific to quick
   * setup.
   *
   * @throws Throwable
   *           if there is a problem initializing the look and feel.
   */
  public static void initialize() throws Throwable
  {
@@ -750,17 +518,14 @@
    {
      try
      {
        UIManager.put("OptionPane.background",
            getColor(INFO_OPTIONPANE_BACKGROUND_COLOR.get()));
        UIManager.put("Panel.background",
            getColor(INFO_PANEL_BACKGROUND_COLOR.get()));
        UIManager.put("ComboBox.background",
            getColor(INFO_COMBOBOX_BACKGROUND_COLOR.get()));
        UIManager.put("OptionPane.background", getColor(INFO_OPTIONPANE_BACKGROUND_COLOR.get()));
        UIManager.put("Panel.background", getColor(INFO_PANEL_BACKGROUND_COLOR.get()));
        UIManager.put("ComboBox.background", getColor(INFO_COMBOBOX_BACKGROUND_COLOR.get()));
      }
      catch (Throwable t)
      {
        // This might occur when we do not get the display
        logger.warn(LocalizableMessage.raw("Error updating UIManager: "+t, t));
        logger.warn(LocalizableMessage.raw("Error updating UIManager: " + t, t));
      }
      initializeLookAndFeel();
      initialized = true;
@@ -769,9 +534,11 @@
  /**
   * Creates a new JPanel.
   *
   * @return JPanel newly created
   */
  public static JPanel makeJPanel() {
  public static JPanel makeJPanel()
  {
    JPanel pnl = new JPanel();
    pnl.setOpaque(false);
    return pnl;
@@ -779,8 +546,11 @@
  /**
   * Creates a JButton with the given label and tooltip.
   * @param label the text of the button.
   * @param tooltip the tooltip of the button.
   *
   * @param label
   *          the text of the button.
   * @param tooltip
   *          the tooltip of the button.
   * @return a JButton with the given label and tooltip.
   */
  public static JButton makeJButton(LocalizableMessage label, LocalizableMessage tooltip)
@@ -804,7 +574,9 @@
  /**
   * Commodity method that returns a JLabel based on a LabelFieldDescriptor.
   * @param desc the LabelFieldDescriptor describing the JLabel.
   *
   * @param desc
   *          the LabelFieldDescriptor describing the JLabel.
   * @return a JLabel based on a LabelFieldDescriptor.
   */
  public static JLabel makeJLabel(LabelFieldDescriptor desc)
@@ -813,7 +585,8 @@
    if (desc.getLabelType() == LabelFieldDescriptor.LabelType.PRIMARY)
    {
      style = UIFactory.TextStyle.PRIMARY_FIELD_VALID;
    } else
    }
    else
    {
      style = UIFactory.TextStyle.SECONDARY_FIELD_VALID;
    }
@@ -822,13 +595,16 @@
  /**
   * Creates a JLabel with the given icon, text and text style.
   * @param iconName the icon.
   * @param text the label text.
   * @param style the text style.
   *
   * @param iconName
   *          the icon.
   * @param text
   *          the label text.
   * @param style
   *          the text style.
   * @return a JLabel with the given icon, text and text style.
   */
  public static JLabel makeJLabel(IconType iconName, LocalizableMessage text,
      TextStyle style)
  public static JLabel makeJLabel(IconType iconName, LocalizableMessage text, TextStyle style)
  {
    JLabel l = new JLabel();
@@ -853,60 +629,54 @@
  /**
   * 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.
   *
   * @param desc
   *          the LabelFieldDescriptor describing the JTextField.
   * @param defaultValue
   *          the default value used to initialize the JTextComponent.
   * @return a JTextComponent based on a LabelFieldDescriptor.
   */
  public static JTextComponent makeJTextComponent(LabelFieldDescriptor desc,
      String defaultValue)
  public static JTextComponent makeJTextComponent(LabelFieldDescriptor desc, String defaultValue)
  {
    if (defaultValue == null)
    {
      defaultValue = "";
    }
    JTextComponent field;
    switch (desc.getType())
    {
    case TEXTFIELD:
      field =
          makeJTextField(LocalizableMessage.raw(defaultValue), desc.getTooltip(), desc
              .getSize(), TextStyle.TEXTFIELD);
      break;
      return makeJTextField(
          LocalizableMessage.raw(defaultValue), desc.getTooltip(), desc.getSize(), TextStyle.TEXTFIELD);
    case PASSWORD:
      field =
          makeJPasswordField(LocalizableMessage.raw(defaultValue), desc.getTooltip(), desc
              .getSize(), TextStyle.PASSWORD_FIELD);
      break;
      return makeJPasswordField(
          LocalizableMessage.raw(defaultValue), desc.getTooltip(), desc.getSize(), TextStyle.PASSWORD_FIELD);
    case READ_ONLY:
      field =
          makeTextPane(LocalizableMessage.raw(defaultValue), TextStyle.READ_ONLY);
      break;
      return makeTextPane(LocalizableMessage.raw(defaultValue), TextStyle.READ_ONLY);
    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.
   * @param tooltip the tooltip text.
   * @param size the number of columns of the JTextField.
   * @param style the text style.
   *
   * @param text
   *          the text.
   * @param tooltip
   *          the tooltip text.
   * @param size
   *          the number of columns of the JTextField.
   * @param style
   *          the text style.
   * @return a JTextField with the given icon, tooltip text, size and text
   * style.
   *         style.
   */
  public static JTextField makeJTextField(LocalizableMessage text, LocalizableMessage tooltip,
      int size, TextStyle style)
  public static JTextField makeJTextField(
      LocalizableMessage text, LocalizableMessage tooltip, int size, TextStyle style)
  {
    JTextField f = new JTextField();
    updateTextFieldComponent(f, text, tooltip, size, style);
@@ -917,15 +687,20 @@
  /**
   * Creates a JPasswordField with the given icon, tooltip text, size and text
   * style.
   * @param text the text.
   * @param tooltip the tooltip text.
   * @param size the number of columns of the JPasswordField.
   * @param style the text style.
   *
   * @param text
   *          the text.
   * @param tooltip
   *          the tooltip text.
   * @param size
   *          the number of columns of the JPasswordField.
   * @param style
   *          the text style.
   * @return a JPasswordField with the given icon, tooltip text, size and text
   * style.
   *         style.
   */
  public static JPasswordField makeJPasswordField(LocalizableMessage text, LocalizableMessage tooltip,
      int size, TextStyle style)
  public static JPasswordField makeJPasswordField(
      LocalizableMessage text, LocalizableMessage tooltip, int size, TextStyle style)
  {
    JPasswordField f = new JPasswordField();
    updateTextFieldComponent(f, text, tooltip, size, style);
@@ -934,16 +709,17 @@
  }
  /**
   * Creates a JRadioButton with the given text, tooltip text and text
   * style.
   * @param text the text of the radio button.
   * @param tooltip the tooltip text.
   * @param style the text style.
   * @return a JRadioButton with the given text, tooltip text and text
   * style.
   * Creates a JRadioButton with the given text, tooltip text and text style.
   *
   * @param text
   *          the text of the radio button.
   * @param tooltip
   *          the tooltip text.
   * @param style
   *          the text style.
   * @return a JRadioButton with the given text, tooltip text and text style.
   */
  public static JRadioButton makeJRadioButton(LocalizableMessage text, LocalizableMessage tooltip,
      TextStyle style)
  public static JRadioButton makeJRadioButton(LocalizableMessage text, LocalizableMessage tooltip, TextStyle style)
  {
    JRadioButton rb = new JRadioButton();
    rb.setOpaque(false);
@@ -962,16 +738,17 @@
  }
  /**
   * Creates a JCheckBox with the given text, tooltip text and text
   * style.
   * @param text the text of the radio button.
   * @param tooltip the tooltip text.
   * @param style the text style.
   * @return a JCheckBox with the given text, tooltip text and text
   * style.
   * Creates a JCheckBox with the given text, tooltip text and text style.
   *
   * @param text
   *          the text of the radio button.
   * @param tooltip
   *          the tooltip text.
   * @param style
   *          the text style.
   * @return a JCheckBox with the given text, tooltip text and text style.
   */
  public static JCheckBox makeJCheckBox(LocalizableMessage text, LocalizableMessage tooltip,
      TextStyle style)
  public static JCheckBox makeJCheckBox(LocalizableMessage text, LocalizableMessage tooltip, TextStyle style)
  {
    JCheckBox cb = new JCheckBox();
    cb.setOpaque(false);
@@ -992,20 +769,26 @@
  /**
   * Creates a JList.
   *
   * @param textStyle the style to be used for the renderer.
   * @param textStyle
   *          the style to be used for the renderer.
   * @param <T>
   *          The type of the JList elements
   * @return a JList.
   */
  public static JList makeJList(TextStyle textStyle)
  public static <T> JList<T> makeJList(TextStyle textStyle)
  {
    JList list = new JList();
    final JList<T> list = new JList<T>();
    list.setCellRenderer(makeCellRenderer(textStyle));
    return list;
  }
  /**
   * Sets the specified text style to the component passed as parameter.
   * @param l the component to update.
   * @param style the text style to use.
   *
   * @param l
   *          the component to update.
   * @param style
   *          the text style to use.
   */
  public static void setTextStyle(JComponent l, TextStyle style)
  {
@@ -1097,51 +880,50 @@
  /**
   * Returns the HTML string representing the provided IconType.
   * @param iconType the IconType for which we want the HTML representation.
   *
   * @param iconType
   *          the IconType for which we want the HTML representation.
   * @return the HTML string representing the provided IconType.
   */
  public static String getIconHtml(IconType iconType)
  {
    String url =
        String.valueOf(UIFactory.class.getClassLoader().getResource(
            getIconPath(iconType)));
    String url = String.valueOf(UIFactory.class.getClassLoader().getResource(getIconPath(iconType)));
    LocalizableMessage description = getIconDescription(iconType);
    LocalizableMessage title = getIconTooltip(iconType);
    return "<img src=\"" + url + "\" alt=\"" + description +
    "\" align=\"middle\" title=\"" + title + "\" >";
    return "<img src=\"" + url + "\" alt=\"" + description + "\" align=\"middle\" title=\"" + title + "\" >";
  }
  /**
   * Returns an ImageIcon object for the provided IconType.
   * @param iconType the IconType for which we want to obtain the ImageIcon.
   *
   * @param iconType
   *          the IconType for which we want to obtain the ImageIcon.
   * @return the ImageIcon.
   */
  public static ImageIcon getImageIcon(IconType iconType)
  {
    if (iconType == null) {
    if (iconType == null)
    {
      iconType = IconType.NO_ICON;
    }
    ImageIcon icon = hmIcons.get(iconType);
    if ((icon == null) && (iconType != IconType.NO_ICON))
    if (icon == null && iconType != IconType.NO_ICON)
    {
      String path = getIconPath(iconType);
      LocalizableMessage description = getIconDescription(iconType);
      try
      {
        Image im =
            Toolkit.getDefaultToolkit().createImage(
                UIFactory.class.getClassLoader().getResource(path));
        Image im = Toolkit.getDefaultToolkit().createImage(UIFactory.class.getClassLoader().getResource(path));
        icon = new ImageIcon(im);
        String ds = description != null ? description.toString() : null;
        icon.setDescription(ds);
        hmIcons.put(iconType, icon);
      } catch (Exception ex)
      }
      catch (Exception ex)
      {
        ex.printStackTrace(); // A bug: this should not happen
        throw new IllegalStateException("Could not load icon for path " + path,
            ex);
        throw new IllegalStateException("Could not load icon for path " + path, ex);
      }
    }
@@ -1150,8 +932,10 @@
  /**
   * Returns a JEditorPane that works with the provided scroll.
   *
   * @see ProgressJEditorPane
   * @param scroll the scroll that will contain the JEditorPane.
   * @param scroll
   *          the scroll that will contain the JEditorPane.
   * @return a JEditorPane that works with the provided scroll.
   */
  public static JEditorPane makeProgressPane(JScrollPane scroll)
@@ -1161,11 +945,14 @@
  /**
   * Returns a read only JEditorPane containing the provided text with the
   * provided font.  The JEditorPane will assume that the text is HTML text.
   * @param text the text to be used to initialize the JEditorPane contents.
   * @param font the font to be used.
   * provided font. The JEditorPane will assume that the text is HTML text.
   *
   * @param text
   *          the text to be used to initialize the JEditorPane contents.
   * @param font
   *          the font to be used.
   * @return a read only JEditorPane containing the provided text with the
   * provided font.
   *         provided font.
   */
  public static JEditorPane makeHtmlPane(LocalizableMessage text, Font font)
  {
@@ -1174,18 +961,23 @@
  /**
   * Returns a read only JEditorPane containing the provided text with the
   * provided font.  The JEditorPane will assume that the text is HTML text.
   * @param text the text to be used to initialize the JEditorPane contents.
   * @param ek HTMLEditor kit used for the new HTML pane
   * @param font the font to be used.
   * provided font. The JEditorPane will assume that the text is HTML text.
   *
   * @param text
   *          the text to be used to initialize the JEditorPane contents.
   * @param ek
   *          HTMLEditor kit used for the new HTML pane
   * @param font
   *          the font to be used.
   * @return a read only JEditorPane containing the provided text with the
   * provided font.
   *         provided font.
   */
  public static JEditorPane makeHtmlPane(LocalizableMessage text, HTMLEditorKit ek,
                                         Font font)
  public static JEditorPane makeHtmlPane(LocalizableMessage text, HTMLEditorKit ek, Font font)
  {
    JEditorPane pane = new JEditorPane();
    if (ek != null) pane.setEditorKit(ek);
    if (ek != null) {
        pane.setEditorKit(ek);
    }
    pane.setContentType("text/html");
    String s = text != null ? String.valueOf(text) : null;
    pane.setText(applyFontToHtmlWithDiv(s, font));
@@ -1196,12 +988,15 @@
  /**
   * Returns a read only JEditorPane containing the provided text with the
   * provided TextStyle.  The JEditorPane will assume that the text is plain
   * provided TextStyle. The JEditorPane will assume that the text is plain
   * text.
   * @param text the text to be used to initialize the JEditorPane contents.
   * @param style the TextStyle to be used.
   *
   * @param text
   *          the text to be used to initialize the JEditorPane contents.
   * @param style
   *          the TextStyle to be used.
   * @return a read only JEditorPane containing the provided text with the
   * provided TextStyle.
   *         provided TextStyle.
   */
  public static JEditorPane makeTextPane(LocalizableMessage text, TextStyle style)
  {
@@ -1215,11 +1010,13 @@
  }
  /**
   * Returns a JScrollPane that contains the provided component.  The scroll
   * pane will not contain any border.
   * @param comp the component contained in the scroll pane.
   * @return a JScrollPane that contains the provided component.  The scroll
   * pane will not contain any border.
   * Returns a JScrollPane that contains the provided component. The scroll pane
   * will not contain any border.
   *
   * @param comp
   *          the component contained in the scroll pane.
   * @return a JScrollPane that contains the provided component. The scroll pane
   *         will not contain any border.
   */
  public static JScrollPane createBorderLessScrollBar(Component comp)
  {
@@ -1236,7 +1033,9 @@
  /**
   * Sets the scroll increment unit for the scroll.
   * @param scroll the scroll to be updated.
   *
   * @param scroll
   *          the scroll to be updated.
   */
  public static void setScrollIncrementUnit(JScrollPane scroll)
  {
@@ -1252,6 +1051,7 @@
  /**
   * Return empty insets.
   *
   * @return empty insets.
   */
  public static Insets getEmptyInsets()
@@ -1261,6 +1061,7 @@
  /**
   * Returns the insets to be used for the button panel.
   *
   * @return the insets to be used for the button panel.
   */
  public static Insets getButtonsPanelInsets()
@@ -1270,6 +1071,7 @@
  /**
   * Returns the insets to be used for the steps panel.
   *
   * @return the insets to be used for the steps panel.
   */
  public static Insets getStepsPanelInsets()
@@ -1279,6 +1081,7 @@
  /**
   * Returns the insets to be used for the current step panel.
   *
   * @return the insets to be used for the current step panel.
   */
  public static Insets getCurrentStepPanelInsets()
@@ -1288,58 +1091,58 @@
  /**
   * Returns a String that contains the html passed as parameter with a span
   * applied.  The span style corresponds to the Font specified as parameter.
   * The goal of this method is to be able to specify a font for an HTML string.
   * applied. The span style corresponds to the Font specified as parameter. The
   * goal of this method is to be able to specify a font for an HTML string.
   *
   * @param html the original html text.
   * @param font the font to be used to generate the new HTML.
   * @param html
   *          the original html text.
   * @param font
   *          the font to be used to generate the new HTML.
   * @return a string that represents the original HTML with the font specified
   * as parameter.
   *         as parameter.
   */
  public static String applyFontToHtml(String html, Font font)
  {
    StringBuilder buf = new StringBuilder();
    buf.append("<span style=\"").append(getFontStyle(font)).append("\">")
        .append(html).append(SPAN_CLOSE);
    buf.append("<span style=\"").append(getFontStyle(font)).append("\">").append(html).append(SPAN_CLOSE);
    return buf.toString();
  }
  /**
   * Returns a String that contains the html passed as parameter with a div
   * applied.  The div style corresponds to the Font specified as parameter.
   * The goal of this method is to be able to specify a font for an HTML string.
   * applied. The div style corresponds to the Font specified as parameter. The
   * goal of this method is to be able to specify a font for an HTML string.
   *
   * @param html the original html text.
   * @param font the font to be used to generate the new HTML.
   * @param html
   *          the original html text.
   * @param font
   *          the font to be used to generate the new HTML.
   * @return a string that represents the original HTML with the font specified
   * as parameter.
   *         as parameter.
   */
  public static String applyFontToHtmlWithDiv(String html, Font font)
  {
    StringBuilder buf = new StringBuilder();
    buf.append("<div style=\"").append(getFontStyle(font)).append("\">")
        .append(html).append(DIV_CLOSE);
    buf.append("<div style=\"").append(getFontStyle(font)).append("\">").append(html).append(DIV_CLOSE);
    return buf.toString();
  }
  /**
   * Returns the HTML style representation for the given font.
   * @param font the font for which we want to get an HTML style representation.
   *
   * @param font
   *          the font for which we want to get an HTML style representation.
   * @return the HTML style representation for the given font.
   */
  private static String getFontStyle(Font font)
  {
    StringBuilder buf = new StringBuilder();
    buf.append("font-family:")
        .append(font.getName())
        .append(";font-size:")
        .append(font.getSize())
        .append("pt");
    buf.append("font-family:").append(font.getName()).append(";font-size:").append(font.getSize()).append("pt");
    if (font.isItalic())
    {
@@ -1355,11 +1158,13 @@
  }
  /**
   * Returns the html text passed as parameter with the error background
   * applied to it.
   * @param html the original html.
   * @return the html text passed as parameter with the error background
   * applied to it.
   * Returns the html text passed as parameter with the error background applied
   * to it.
   *
   * @param html
   *          the original html.
   * @return the html text passed as parameter with the error background applied
   *         to it.
   */
  public static String applyErrorBackgroundToHtml(String html)
  {
@@ -1369,55 +1174,67 @@
  /**
   * Returns the html text passed as parameter with the warning background
   * applied to it.
   * @param html the original html.
   *
   * @param html
   *          the original html.
   * @return the html text passed as parameter with the warning background
   * applied to it.
   *         applied to it.
   */
  public static String applyWarningBackgroundToHtml(String html)
  {
    return DIV_OPEN_WARNING_BACKGROUND + html + DIV_CLOSE;
  }
  /**
   * Returns the html text passed as parameter with the success background
   * applied to it.
   * @param html the original html.
   *
   * @param html
   *          the original html.
   * @return the html text passed as parameter with the success background
   * applied to it.
   *         applied to it.
   */
  public static String applySuccessfulBackgroundToHtml(String html)
  {
    return DIV_OPEN_SUCCESSFUL_BACKGROUND + html + DIV_CLOSE;
  }
  /**
   * Returns the html text passed as parameter with some added margin.
   * @param html the original html text.
   * @param top the top margin.
   * @param right the right margin.
   * @param bottom the bottom margin.
   * @param left the left margin.
   *
   * @param html
   *          the original html text.
   * @param top
   *          the top margin.
   * @param right
   *          the right margin.
   * @param bottom
   *          the bottom margin.
   * @param left
   *          the left margin.
   * @return the html text passed as parameter with some added margin.
   */
  public static String applyMargin(String html, int top, int right, int bottom,
      int left)
  public static String applyMargin(String html, int top, int right, int bottom, int left)
  {
    return "<div style=\"margin:" + top + "px " + right + "px " + bottom + "px "
        + left + "px;\">" + html + DIV_CLOSE;
    return "<div style=\"margin:" + top + "px " + right + "px " + bottom + "px " + left + "px;\">" + html + DIV_CLOSE;
  }
  /**
   * Updates the provided field with all the other arguments.
   * @param field the field to be modified.
   * @param text the new text of the field.
   * @param tooltip the new tooltip text of the field.
   * @param size the new size of the field.
   * @param textStyle the new TextStyle of the field.
   *
   * @param field
   *          the field to be modified.
   * @param text
   *          the new text of the field.
   * @param tooltip
   *          the new tooltip text of the field.
   * @param size
   *          the new size of the field.
   * @param textStyle
   *          the new TextStyle of the field.
   */
  private static void updateTextFieldComponent(JTextField field, LocalizableMessage text,
      LocalizableMessage tooltip, int size, TextStyle textStyle)
  private static void updateTextFieldComponent(
      JTextField field, LocalizableMessage text, LocalizableMessage tooltip, int size, TextStyle textStyle)
  {
    field.setColumns(size);
    if (text != null)
@@ -1446,8 +1263,9 @@
  }
  /**
   * Returns the parent package path.  This is used to retrieve the icon
   * Returns the parent package path. This is used to retrieve the icon
   * qualified names.
   *
   * @return the parent package path.
   */
  private static String getParentPackagePath()
@@ -1464,7 +1282,9 @@
  /**
   * Returns the path of the icon for the given IconType.
   * @param iconType the IconType for which we want to get the path.
   *
   * @param iconType
   *          the IconType for which we want to get the path.
   * @return the path of the icon for the given IconType.
   */
  private static String getIconPath(IconType iconType)
@@ -1544,190 +1364,141 @@
  /**
   * Returns the icon description for the given IconType.
   * @param iconType the IconType for which we want to get the description.
   *
   * @param iconType
   *          the IconType for which we want to get the description.
   * @return the icon description for the given IconType.
   */
  private static LocalizableMessage getIconDescription(IconType iconType)
  {
    LocalizableMessage description;
    switch (iconType)
    {
    case CURRENT_STEP:
      description = INFO_CURRENT_STEP_ICON_DESCRIPTION.get();
      break;
      return INFO_CURRENT_STEP_ICON_DESCRIPTION.get();
    case SPLASH:
      description = INFO_SPLASH_ICON_DESCRIPTION.get();
      break;
      return INFO_SPLASH_ICON_DESCRIPTION.get();
    case BACKGROUND:
      description = INFO_BACKGROUND_ICON_DESCRIPTION.get();
      break;
      return INFO_BACKGROUND_ICON_DESCRIPTION.get();
    case MINIMIZED:
      description = INFO_MINIMIZED_ICON_DESCRIPTION.get();
      break;
      return INFO_MINIMIZED_ICON_DESCRIPTION.get();
    case MINIMIZED_MAC:
      description = INFO_MINIMIZED_ICON_DESCRIPTION.get();
      break;
      return INFO_MINIMIZED_ICON_DESCRIPTION.get();
    case WARNING:
      description = INFO_WARNING_ICON_DESCRIPTION.get();
      break;
      return INFO_WARNING_ICON_DESCRIPTION.get();
    case WARNING_LARGE:
      description = INFO_WARNING_ICON_DESCRIPTION.get();
      break;
      return INFO_WARNING_ICON_DESCRIPTION.get();
    case ERROR:
      description = INFO_ERROR_ICON_DESCRIPTION.get();
      break;
      return INFO_ERROR_ICON_DESCRIPTION.get();
    case ERROR_LARGE:
      description = INFO_ERROR_ICON_DESCRIPTION.get();
      break;
      return INFO_ERROR_ICON_DESCRIPTION.get();
    case INFORMATION:
      description = INFO_INFORMATION_ICON_DESCRIPTION.get();
      break;
      return INFO_INFORMATION_ICON_DESCRIPTION.get();
    case INFORMATION_LARGE:
      description = INFO_INFORMATION_ICON_DESCRIPTION.get();
      break;
      return INFO_INFORMATION_ICON_DESCRIPTION.get();
    case SUBSECTION_LEFT:
      description = INFO_SUBSECTION_LEFT_ICON_DESCRIPTION.get();
      break;
      return INFO_SUBSECTION_LEFT_ICON_DESCRIPTION.get();
    case SUBSECTION_RIGHT:
      description = INFO_SUBSECTION_RIGHT_ICON_DESCRIPTION.get();
      break;
      return INFO_SUBSECTION_RIGHT_ICON_DESCRIPTION.get();
    case HELP_SMALL:
      description = INFO_HELP_SMALL_ICON_DESCRIPTION.get();
      break;
      return INFO_HELP_SMALL_ICON_DESCRIPTION.get();
    case WAIT_TINY:
      description = INFO_HELP_WAIT_DESCRIPTION.get();
      break;
      return INFO_HELP_WAIT_DESCRIPTION.get();
    case WAIT:
      description = INFO_HELP_WAIT_DESCRIPTION.get();
      break;
      return INFO_HELP_WAIT_DESCRIPTION.get();
    case NO_ICON:
      description = null;
      break;
      return null;
    default:
      throw new IllegalArgumentException("Unknown iconName: " + iconType);
    }
    return description;
  }
  /**
   * Returns the icon tooltip text for the given IconType.
   * @param iconType the IconType for which we want to get the tooltip text.
   *
   * @param iconType
   *          the IconType for which we want to get the tooltip text.
   * @return the icon tooltip text for the given IconType.
   */
  private static LocalizableMessage getIconTooltip(IconType iconType)
  {
    if (iconType == null) {
    if (iconType == null)
    {
      iconType = IconType.NO_ICON;
    }
    LocalizableMessage tooltip;
    switch (iconType)
    {
    case CURRENT_STEP:
      tooltip = INFO_CURRENT_STEP_ICON_TOOLTIP.get();
      break;
      return INFO_CURRENT_STEP_ICON_TOOLTIP.get();
    case SPLASH:
      tooltip = INFO_SPLASH_ICON_TOOLTIP.get();
      break;
      return INFO_SPLASH_ICON_TOOLTIP.get();
    case BACKGROUND:
      tooltip = INFO_BACKGROUND_ICON_TOOLTIP.get();
      break;
      return INFO_BACKGROUND_ICON_TOOLTIP.get();
    case MINIMIZED:
      tooltip = INFO_MINIMIZED_ICON_TOOLTIP.get();
      break;
      return INFO_MINIMIZED_ICON_TOOLTIP.get();
    case MINIMIZED_MAC:
      tooltip = INFO_MINIMIZED_ICON_TOOLTIP.get();
      break;
      return INFO_MINIMIZED_ICON_TOOLTIP.get();
    case WARNING:
      tooltip = INFO_WARNING_ICON_TOOLTIP.get();
      break;
      return INFO_WARNING_ICON_TOOLTIP.get();
    case WARNING_LARGE:
      tooltip = INFO_WARNING_ICON_TOOLTIP.get();
      break;
      return INFO_WARNING_ICON_TOOLTIP.get();
    case ERROR:
      tooltip = INFO_ERROR_ICON_TOOLTIP.get();
      break;
      return INFO_ERROR_ICON_TOOLTIP.get();
    case ERROR_LARGE:
      tooltip = INFO_ERROR_ICON_TOOLTIP.get();
      break;
      return INFO_ERROR_ICON_TOOLTIP.get();
    case INFORMATION:
      tooltip = INFO_INFORMATION_ICON_TOOLTIP.get();
      break;
      return INFO_INFORMATION_ICON_TOOLTIP.get();
    case INFORMATION_LARGE:
      tooltip = INFO_INFORMATION_ICON_TOOLTIP.get();
      break;
      return INFO_INFORMATION_ICON_TOOLTIP.get();
    case SUBSECTION_LEFT:
      tooltip = null;
      break;
    case SUBSECTION_RIGHT:
      tooltip = null;
      break;
    case HELP_SMALL:
      tooltip = null;
      break;
    case WAIT_TINY:
      tooltip = null;
      break;
    case WAIT:
      tooltip = null;
      break;
    case NO_ICON:
      tooltip = null;
      break;
      return null;
    default:
      throw new IllegalArgumentException("Unknown iconName: " + iconType);
    }
    return tooltip;
  }
  private static ListCellRenderer makeCellRenderer(final TextStyle textStyle)
  private static <T> ListCellRenderer<T> makeCellRenderer(final TextStyle textStyle)
  {
    return new ListCellRenderer()
    return new ListCellRenderer<T>()
    {
      public Component getListCellRendererComponent(JList list,
          Object value,
          int index,
          boolean isSelected,
      @Override
      public Component getListCellRendererComponent(JList<? extends T> list, T value, int index, boolean isSelected,
          boolean cellHasFocus)
      {
        JLabel l =
            makeJLabel(IconType.NO_ICON, LocalizableMessage.raw(value
                .toString()), textStyle);
        final JLabel l = makeJLabel(IconType.NO_ICON, LocalizableMessage.raw(value.toString()), textStyle);
        l.setBorder(new EmptyBorder(TOP_INSET_SECONDARY_FIELD, 0, 0, 0));
        return l;
      }
@@ -1738,32 +1509,33 @@
/**
 * This class has been written to have a better behaviour with the scroll pane
 * than the one we have by default in the case of the progress panel.
 *
 * <p>
 * With the default scroll pane behaviour when we set a new text in a
 * JEditorPane the scroll bar goes systematically up.  With this implementation
 * the expected behaviour is:
 *
 * <p>
 * If the scroll bar is at the bottom we will display the latest text contained
 * in the pane.
 *
 * <p>
 * If the scroll bar is not at the bottom we will keep on displaying the same
 * thing that the user is viewing.
 *
 * <p>
 * This behaviour allows the user to check the log content even when the
 * installation/uninstallation is still running and sending new log messages.
 *
 */
class ProgressJEditorPane extends JEditorPane
{
  private static final long serialVersionUID = 1221976708322628818L;
  private JScrollPane scroll;
  private final JScrollPane scroll;
  private boolean ignoreScrollToVisible;
  /**
   * Constructor for the ProgressJEditorPane.
   * @param scroll the JScrollPane that will contain this editor pane.
   *
   * @param scroll
   *          the JScrollPane that will contain this editor pane.
   */
  public ProgressJEditorPane(JScrollPane scroll)
  {
@@ -1773,29 +1545,26 @@
    setBorder(new EmptyBorder(3, 3, 3, 3));
  }
  /** {@inheritDoc} */
  @Override
  public void setText(String text)
  {
    // Scroll can be null in constructor
    if (scroll != null)
    {
      /* We apply the following policy: if the user is displaying the latest
       * part of the JTextArea we assume that when we add text (s)he wants
       * to see the text that is added, if not we assume that (s)he want to keep
      /*
       * We apply the following policy: if the user is displaying the latest
       * part of the JTextArea we assume that when we add text (s)he wants to
       * see the text that is added, if not we assume that (s)he want to keep
       * viewing what is visible and so we ignore the next scrollRectToVisible
       * call (that will be done inside JTextArea.setText method).
       */
      JScrollBar vBar = scroll.getVerticalScrollBar();
      ignoreScrollToVisible =
          (vBar != null)
              && ((vBar.getValue() + vBar.getVisibleAmount()) < 0.97 * vBar
                  .getMaximum());
          vBar != null && vBar.getValue() + vBar.getVisibleAmount() < 0.97 * vBar.getMaximum();
      super.setText(text);
    }
  }
  /** {@inheritDoc} */
  @Override
  public void scrollRectToVisible(Rectangle rect)
  {
@@ -1808,25 +1577,28 @@
}
/**
 * A class used to be able to select the contents of the text field when
 * it gets the focus.
 *
 * A class used to be able to select the contents of the text field when it gets
 * the focus.
 */
class TextFieldFocusListener implements FocusListener
{
  private JTextField tf;
  private final JTextField tf;
  /**
   * The constructor for this listener.
   * @param tf the text field associated with this listener.
   *
   * @param tf
   *          the text field associated with this listener.
   */
  TextFieldFocusListener(JTextField tf)
  {
    this.tf = tf;
  }
  /** {@inheritDoc} */
  @Override
  public void focusGained(FocusEvent e)
  {
    if ((tf.getText() == null) || "".equals(tf.getText()))
    if (tf.getText() == null || "".equals(tf.getText()))
    {
      tf.setText(" ");
      tf.selectAll();
@@ -1838,7 +1610,7 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void focusLost(FocusEvent e)
  {
  }