Example usage for com.intellij.openapi.ui Messages showPasswordDialog

List of usage examples for com.intellij.openapi.ui Messages showPasswordDialog

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages showPasswordDialog.

Prototype

@Nullable
public static String showPasswordDialog(@Nls String message,
        @Nls(capitalization = Nls.Capitalization.Title) String title) 

Source Link

Usage

From source file:de.fu_berlin.inf.dpp.intellij.ui.views.buttons.ConnectButton.java

License:Open Source License

/**
 * Asks for Name, Password and domain and server for a new XMPP account.
 *//*  w ww . j a va  2  s  .  c  o  m*/
protected XMPPAccount createNewAccount() {
    final String userID = SafeDialogUtils.showInputDialog("Your User-ID, e.g. user@saros-con.imp.fu-berlin.de",
            "", "Login");
    if (userID.isEmpty()) {
        return null;
    }
    if (!userID.contains("@")) {
        SafeDialogUtils.showError("No @ found in the ID!", "Error");
        return null;
    }

    String[] fields = userID.split(USERID_SEPARATOR);
    String username = fields[0];
    String domain = fields[1];

    final String password = Messages.showPasswordDialog("Password", "Password");
    if (password.isEmpty()) {
        return null;
    }
    String server = SafeDialogUtils.showInputDialog("XMPP server (optional, not necessary in most cases)", "",
            "Server");

    try {
        return accountStore.createAccount(username, password, domain, server, 0, true, true);
    } catch (IllegalArgumentException e) {
        LOG.error("Error creating account", e);
        SafeDialogUtils.showError("There was an error creating the account.\n Details:\n\n" + e.getMessage(),
                "Error");
    }
    return null;
}