Example usage for com.intellij.openapi.ui.popup.util PopupUtil showBalloonForActiveComponent

List of usage examples for com.intellij.openapi.ui.popup.util PopupUtil showBalloonForActiveComponent

Introduction

In this page you can find the example usage for com.intellij.openapi.ui.popup.util PopupUtil showBalloonForActiveComponent.

Prototype

public static void showBalloonForActiveComponent(@NotNull final String message, final MessageType type) 

Source Link

Usage

From source file:org.jetbrains.idea.svn.checkin.IdeaSvnkitBasedAuthenticationCallback.java

License:Apache License

@Override
@Nullable//  w w  w . j  a  v  a 2  s  .c o  m
public PasswordAuthentication getProxyAuthentication(@NotNull SVNURL repositoryUrl) {
    final Proxy proxy = getIdeaDefinedProxy(repositoryUrl);
    if (proxy == null)
        return null;
    if (myProxyCredentialsWereReturned) {
        // ask loud
        final HttpConfigurable instance = HttpConfigurable.getInstance();
        if (instance.USE_HTTP_PROXY || instance.USE_PROXY_PAC) {
            PopupUtil.showBalloonForActiveComponent(
                    "Failed to authenticate to proxy. You can change proxy credentials in HTTP proxy settings.",
                    MessageType.ERROR);
        } else {
            PopupUtil.showBalloonForActiveComponent("Failed to authenticate to proxy.", MessageType.ERROR);
        }
        return null;
    }
    final InetSocketAddress address = (InetSocketAddress) proxy.address();
    final PasswordAuthentication authentication;
    try {
        authentication = Authenticator.requestPasswordAuthentication(repositoryUrl.getHost(),
                address.getAddress(), repositoryUrl.getPort(), repositoryUrl.getProtocol(),
                repositoryUrl.getHost(), repositoryUrl.getProtocol(), new URL(repositoryUrl.toString()),
                Authenticator.RequestorType.PROXY);
    } catch (MalformedURLException e) {
        LOG.info(e);
        return null;
    }

    if (authentication != null) {
        myProxyCredentialsWereReturned = true;
    }

    return authentication;
}

From source file:org.jetbrains.idea.svn.checkin.IdeaSvnkitBasedAuthenticationCallback.java

License:Apache License

@Override
public boolean askProxyCredentials(SVNURL repositoryUrl) {
    if (repositoryUrl == null) {
        return false;
    }//  ww w.java2 s  .c o  m

    PasswordAuthentication authentication = getProxyAuthentication(repositoryUrl);

    if (authentication != null) {
        // for 'generic' proxy variant (suppose user defined proxy in Subversion config but no password)
        try {
            initTmpDir(SvnConfiguration.getInstance(myVcs.getProject()));
        } catch (IOException e) {
            PopupUtil.showBalloonForActiveComponent("Failed to authenticate to proxy: " + e.getMessage(),
                    MessageType.ERROR);
            return false;
        }
        return IdeaSVNConfigFile.putProxyCredentialsIntoServerFile(myTempDirectory, repositoryUrl.getHost(),
                authentication);
    }
    return false;
}