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

jvergara
04.51.2007 093e406859be8e3a49e48cfc14f0a5276bc70d5d
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ProgressPanel.java
@@ -32,6 +32,8 @@
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
@@ -60,6 +62,8 @@
  private String lastText;
  private Component lastFocusComponent;
  /**
   * ProgressPanel constructor.
   * @param application Application this panel represents
@@ -89,6 +93,8 @@
        getMsg("progressbar-initial-label"), UIFactory.PROGRESS_FONT);
    progressBarLabel.setOpaque(false);
    progressBarLabel.setEditable(false);
    progressBarLabel.setFocusable(false);
    progressBarLabel.setFocusCycleRoot(false);
    CustomHTMLEditorKit htmlEditor = new CustomHTMLEditorKit();
    htmlEditor.addActionListener(new ActionListener()
    {
@@ -145,6 +151,8 @@
    gbc.weighty = 1.0;
    panel.add(scroll, gbc);
    addFocusListeners();
    return panel;
  }
@@ -167,6 +175,17 @@
  /**
   * {@inheritDoc}
   */
  public void endDisplay()
  {
    if (lastFocusComponent != null)
    {
      lastFocusComponent.requestFocusInWindow();
    }
  }
  /**
   * {@inheritDoc}
   */
  public void displayProgress(ProgressDescriptor descriptor)
  {
    ProgressStep status = descriptor.getProgressStep();
@@ -175,6 +194,7 @@
    if (status.isLast()) {
      progressBar.setVisible(false);
      progressBarLabel.setFocusable(true);
      btnCancel.setVisible(false);
      if (!status.isError()) {
        summaryText = "<form>"+summaryText+"</form>";
@@ -252,6 +272,38 @@
    return panel;
  }
  /**
   * Adds the required focus listeners to the fields.
   */
  private void addFocusListeners()
  {
    final FocusListener l = new FocusListener()
    {
      public void focusGained(FocusEvent e)
      {
        lastFocusComponent = e.getComponent();
      }
      public void focusLost(FocusEvent e)
      {
      }
    };
    JComponent[] comps =
    {
        progressBarLabel,
        progressBar,
        btnCancel,
        detailsTextArea
    };
    for (int i = 0; i < comps.length; i++)
    {
      comps[i].addFocusListener(l);
    }
    lastFocusComponent = detailsTextArea;
  }
//  public static void main(String[] args) {
//    final UserData ud = new UpgradeUserData();
//    ud.setServerLocation("XXX/XXXXX/XX/XXXXXXXXXXXX/XXXX");