Search in sources :

Example 1 with CvsLoginWorker

use of com.intellij.cvsSupport2.connections.login.CvsLoginWorker in project intellij-community by JetBrains.

the class Cvs2SettingsEditPanel method testConnection.

private static void testConnection(final CvsRootConfiguration configuration, final Component component, Project project) {
    final CvsLoginWorker loginWorker = configuration.getLoginWorker(project);
    final Ref<Boolean> success = new Ref<>();
    ProgressManager.getInstance().run(new Task.Modal(project, CvsBundle.message("message.connecting.to.cvs.server"), false) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            indicator.setText2(CvsBundle.message("message.current.global.timeout.setting", CvsApplicationLevelConfiguration.getInstance().TIMEOUT));
            try {
                final ThreeState result = LoginPerformer.checkLoginWorker(loginWorker, true);
                if (ThreeState.NO == result) {
                    showConnectionFailedMessage(component, CvsBundle.message("test.connection.login.failed.text"));
                } else if (ThreeState.UNSURE == result) {
                    showConnectionFailedMessage(component, CvsBundle.message("error.message.authentication.canceled"));
                } else {
                    success.set(Boolean.TRUE);
                }
            } catch (ProcessCanceledException ignore) {
            } catch (final Exception e) {
                showConnectionFailedMessage(component, e.getLocalizedMessage());
            }
        }
    });
    if (success.get() != Boolean.TRUE)
        return;
    try {
        configuration.testConnection(project);
        showSuccessfulConnectionMessage(component);
    } catch (ProcessCanceledException ignore) {
    } catch (final Exception e) {
        showConnectionFailedMessage(component, e.getLocalizedMessage());
    }
}
Also used : ThreeState(com.intellij.util.ThreeState) Ref(com.intellij.openapi.util.Ref) Task(com.intellij.openapi.progress.Task) CvsLoginWorker(com.intellij.cvsSupport2.connections.login.CvsLoginWorker) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) InputException(com.intellij.openapi.ui.InputException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Aggregations

CvsLoginWorker (com.intellij.cvsSupport2.connections.login.CvsLoginWorker)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 InputException (com.intellij.openapi.ui.InputException)1 Ref (com.intellij.openapi.util.Ref)1 ThreeState (com.intellij.util.ThreeState)1