/**
   * Returns the first wizard page.
   *
   * @param registration the registration object
   * @param isCreateAccount indicates if the simple form should be opened as a create account form
   *     or as a login form
   * @return the first wizard page.
   */
  public Object getSimpleForm(JabberAccountRegistration registration, boolean isCreateAccount) {
    this.registration = registration;

    firstWizardPage = new FirstWizardPage(this);

    return firstWizardPage.getSimpleForm();
  }
 /**
  * Returns a simple account registration form that would be the first form shown to the user. Only
  * if the user needs more settings she'll choose to open the advanced wizard, consisted by all
  * pages.
  *
  * @param isCreateAccount indicates if the simple form should be opened as a create account form
  *     or as a login form
  * @return a simple account registration form
  */
 public Object getSimpleForm(boolean isCreateAccount) {
   firstWizardPage = new FirstWizardPage(this);
   return firstWizardPage.getSimpleForm();
 }
 /**
  * Returns a simple account registration form that would be the first form shown to the user. Only
  * if the user needs more settings she'll choose to open the advanced wizard, consisted by all
  * pages.
  *
  * @param isCreateAccount indicates if the simple form should be opened as a create account form
  *     or as a login form
  * @return a simple account registration form
  */
 public Object getSimpleForm(boolean isCreateAccount) {
   firstWizardPage = new FirstWizardPage(registration, getWizardContainer());
   return firstWizardPage.getSimpleForm();
 }
  /**
   * Installs the account defined in this wizard.
   *
   * @param userName the user name to sign in with
   * @param password the password to sign in with
   * @return the created <tt>ProtocolProviderService</tt> corresponding to the new account
   * @throws OperationFailedException if the operation didn't succeed
   */
  public ProtocolProviderService signin(final String userName, final String password)
      throws OperationFailedException {
    /*
     * If firstWizardPage is null we are requested sign-in from initial
     * account registration form we must init firstWizardPage in order to
     * init default values
     * Pawel: firstWizardPage is never null, and commitPage fails with no
     * user ID provided for simple account wizard. Now userName and password
     * are reentered here.
     */
    final AccountPanel accPanel = (AccountPanel) firstWizardPage.getSimpleForm();
    /*
     * XXX Swing is not thread safe! We've experienced deadlocks on OS X
     * upon invoking accPanel's setters. In order to address them, (1)
     * invoke accPanel's setters on the AWT event dispatching thread and (2)
     * do it only if absolutely necessary.
     */
    String accPanelUsername = accPanel.getUsername();
    boolean equals = false;
    final boolean rememberPassword = (password != null);

    if (StringUtils.isEquals(accPanelUsername, userName)) {
      char[] accPanelPasswordChars = accPanel.getPassword();
      char[] passwordChars = (password == null) ? null : password.toCharArray();

      if (accPanelPasswordChars == null)
        equals = ((passwordChars == null) || passwordChars.length == 0);
      else if (passwordChars == null) equals = (accPanelPasswordChars.length == 0);
      else equals = Arrays.equals(accPanelPasswordChars, passwordChars);
      if (equals) {
        boolean accPanelRememberPassword = accPanel.isRememberPassword();

        equals = (accPanelRememberPassword == rememberPassword);
      }
    }
    if (!equals) {
      try {
        if (SwingUtilities.isEventDispatchThread()) {
          accPanel.setUsername(userName);
          accPanel.setPassword(password);
          accPanel.setRememberPassword(rememberPassword);
        } else {
          SwingUtilities.invokeAndWait(
              new Runnable() {
                public void run() {
                  accPanel.setUsername(userName);
                  accPanel.setPassword(password);
                  accPanel.setRememberPassword(rememberPassword);
                }
              });
        }
      } catch (Exception e) {
        if (e instanceof OperationFailedException) {
          throw (OperationFailedException) e;
        } else {
          throw new OperationFailedException(
              "Failed to set username and password on " + accPanel.getClass().getName(),
              OperationFailedException.INTERNAL_ERROR,
              e);
        }
      }
    }

    if (!firstWizardPage.isCommitted()) firstWizardPage.commitPage();
    if (!firstWizardPage.isCommitted()) {
      throw new OperationFailedException(
          "Could not confirm data.", OperationFailedException.GENERAL_ERROR);
    }

    ProtocolProviderFactory factory = JabberAccRegWizzActivator.getJabberProtocolProviderFactory();

    return installAccount(
        factory,
        registration.getUserID(), // The user id may get changed.
        // Server part can be added in the
        // data commit.
        password);
  }