Example usage for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress

List of usage examples for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress

Introduction

In this page you can find the example usage for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress.

Prototype

IRunnableWithProgress

Source Link

Usage

From source file:com.centurylink.mdw.plugin.project.RemoteWorkflowProjectWizard.java

License:Apache License

@Override
public boolean performFinish() {
    try {/*from w  w  w.  jav a  2  s .  c  om*/
        getContainer().run(false, false, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Creating workflow project", 100);
                if (workflowProject.isFilePersist()) {
                    try {
                        File projectDir = new File(
                                ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile() + "/"
                                        + workflowProject.getName());
                        projectDir.mkdir();
                        String repositoryUrl = workflowProject.getMdwVcsRepository().getRepositoryUrl();
                        if (repositoryUrl != null && repositoryUrl.length() > 0) {
                            workflowProject.setPersistType(PersistType.Git);
                            workflowProject.getMdwVcsRepository().setProvider(VcsRepository.PROVIDER_GIT);
                            monitor.subTask("Cloning Git repository");
                            monitor.worked(10);
                            Platform.getBundle("org.eclipse.egit.ui").start(); // avoid
                                                                               // Eclipse
                                                                               // default
                                                                               // Authenticator
                            monitor.worked(10);
                            VcsRepository gitRepo = workflowProject.getMdwVcsRepository();
                            VersionControlGit vcsGit = new VersionControlGit();
                            vcsGit.connect(gitRepo.getRepositoryUrl(), gitRepo.getUser(), gitRepo.getPassword(),
                                    projectDir);
                            vcsGit.cloneRepo();
                        } else {
                            File assetDir = new File(
                                    projectDir + "/" + workflowProject.getMdwVcsRepository().getLocalPath());
                            assetDir.mkdirs();
                        }
                    } catch (Exception ex) {
                        throw new InvocationTargetException(ex);
                    }
                }
                monitor.worked(50);
                ProjectInflator projectInflator = new ProjectInflator(workflowProject, MdwPlugin.getSettings());
                projectInflator.inflateRemoteProject(getContainer());
                WorkflowProjectManager.addProject(workflowProject);
                monitor.worked(25);

                monitor.done();
            }
        });
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Remote Project", workflowProject);
        return false;
    }

    DesignerPerspective.promptForShowPerspective(activeWindow, workflowProject);
    return true;
}

From source file:com.cisco.yangide.ext.refactoring.ui.RenameLinkedMode.java

License:Open Source License

private RenameSupport undoAndCreateRenameSupport(String newName) throws CoreException {
    // Assumption: the linked mode model should be shut down by now.

    final ISourceViewer viewer = editor.getViewer();

    try {//from w w  w.j a v a 2s. c  o  m
        if (!fOriginalName.equals(newName)) {
            editor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() {
                @Override
                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    if (viewer instanceof ITextViewerExtension6) {
                        IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
                        if (undoManager instanceof IUndoManagerExtension) {
                            IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
                            IUndoContext undoContext = undoManagerExtension.getUndoContext();
                            IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
                            while (undoManager.undoable()) {
                                if (fStartingUndoOperation != null && fStartingUndoOperation
                                        .equals(operationHistory.getUndoOperation(undoContext))) {
                                    return;
                                }
                                undoManager.undo();
                            }
                        }
                    }
                }
            });
        }
    } catch (InvocationTargetException e) {
        throw new CoreException(
                new Status(IStatus.ERROR, YangRefactoringPlugin.PLUGIN_ID, "Error saving editor", e));
    } catch (InterruptedException e) {
        // canceling is OK
        return null;
    } finally {
        editor.reconcileModel();
    }

    viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y);

    if (newName.length() == 0) {
        return null;
    }
    return new RenameSupport(originalFile, originalNode, newName);
}

From source file:com.cisco.yangide.ui.wizards.YangFileWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    if (yangPage.getModule().isEmpty()) {
        yangPage.init();/* w ww.  j a  va2 s .  c  om*/
    }
    try {
        getContainer().run(false, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                IFile file = filePage.createNewFile();
                try {
                    file.setContents(getTemplateContent(), true, false, monitor);
                } catch (CoreException | IOException e) {
                    YangUIPlugin.log(e);
                }

                BasicNewResourceWizard.selectAndReveal(file, workbench.getActiveWorkbenchWindow());

                // Open editor on new file.
                IWorkbenchWindow dw = workbench.getActiveWorkbenchWindow();
                try {
                    if (dw != null) {
                        IWorkbenchPage page = dw.getActivePage();
                        if (page != null) {
                            IDE.openEditor(page, file, true);
                        }
                    }
                } catch (PartInitException e) {
                    YangUIPlugin.log(e);
                }
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        YangUIPlugin.log(e);
    }
    return true;
}

From source file:com.cloudbees.eclipse.dev.ui.actions.OpenJunitViewAction.java

License:Open Source License

@Override
public void run() {

    IStructuredSelection sel = getStructuredSelection();
    Object selection = sel.getFirstElement();

    //System.out.println("Show test results: " + selection);

    if (selection instanceof JenkinsBuildDetailsResponse) {
        final JenkinsBuildDetailsResponse build = (JenkinsBuildDetailsResponse) selection;

        try {// ww w  . jav a  2s . co m
            IRunnableWithProgress op = new IRunnableWithProgress() {
                public void run(final IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    try {
                        InputStream testReport = CloudBeesUIPlugin.getDefault()
                                .getJenkinsServiceForUrl(build.url).getTestReport(build.url, monitor);
                        if (testReport == null) {
                            StatusManager.getManager()
                                    .handle(new Status(IStatus.ERROR, CloudBeesDevUiPlugin.PLUGIN_ID,
                                            "The build did not produce test results."),
                                            StatusManager.SHOW | StatusManager.BLOCK);
                        }

                        if (monitor.isCanceled()) {
                            throw new InterruptedException();
                        }

                        String projectName = null; // TODO

                        final TestRunSession testRunSession = JUnitReportSupport
                                .importJenkinsTestRunSession(build.getDisplayName(), projectName, testReport);
                        CloudBeesDevUiPlugin.getDefault().showView(TestRunnerViewPart.NAME);
                        JUnitReportSupport.getJUnitModel().addTestRunSession(testRunSession);
                    } catch (Exception e) {
                        throw new InvocationTargetException(e);
                    }
                }
            };

            //PlatformUI.getWorkbench().getProgressService().busyCursorWhile(op);
            IProgressService service = PlatformUI.getWorkbench().getProgressService();
            service.run(false, true, op);
        } catch (InterruptedException e) {
            // cancelled
        } catch (InvocationTargetException e) {
            IStatus status;
            if (e.getCause() instanceof CoreException) {
                status = ((CoreException) e.getCause()).getStatus();
            } else {
                status = new Status(IStatus.ERROR, CloudBeesDevUiPlugin.PLUGIN_ID,
                        "Unexpected error while processing test results", e);
            }
            StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
        }
    }
}

From source file:com.cloudbees.eclipse.dev.ui.views.build.ArtifactsClickListener.java

License:Open Source License

public static void deployWar(final JenkinsBuildDetailsResponse build, final Artifact selectedWar) {
    final Artifact war;
    final ApplicationInfo app;

    if (build.artifacts == null) {
        return;//from  www . j  ava 2  s  . co  m
    }

    final DeployWarAppDialog[] selector = new DeployWarAppDialog[1];
    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
        @Override
        public void run() {
            final List<Artifact> wars = new ArrayList<Artifact>();
            final List<ApplicationInfo> apps = new ArrayList<ApplicationInfo>();
            try {
                PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
                    @Override
                    public void run(final IProgressMonitor monitor) {
                        try {
                            for (Artifact art : build.artifacts) {
                                if (art.relativePath != null && art.relativePath.endsWith(".war")) {
                                    wars.add(art);
                                    monitor.worked(1);
                                }
                            }

                            apps.addAll(BeesSDK.getList().getApplications());
                            monitor.worked(1);
                        } catch (Exception e) {
                            CloudBeesDevUiPlugin.getDefault().getLogger().error(e);
                        }
                    }
                });
            } catch (InterruptedException e) {
                return;
            } catch (Exception e) {
                CloudBeesDevUiPlugin.getDefault().getLogger().error(e);
            }

            if (wars.isEmpty() || apps.isEmpty()) {
                MessageDialog.openInformation(CloudBeesUIPlugin.getActiveWindow().getShell(),
                        "Deploy to RUN@cloud", "Deployment is not possible.");
                return;
            }

            selector[0] = new DeployWarAppDialog(CloudBeesUIPlugin.getActiveWindow().getShell(), wars,
                    selectedWar, apps);
            selector[0].open();
        }
    });

    if (selector[0] == null) {
        return;
    }

    war = selector[0].getSelectedWar();
    app = selector[0].getSelectedApp();

    if (war == null || app == null) {
        return; // cancelled
    }

    org.eclipse.core.runtime.jobs.Job job = new org.eclipse.core.runtime.jobs.Job("Deploy war to RUN@cloud") {
        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            try {
                String warUrl = getWarUrl(build, war);
                JenkinsService service = CloudBeesUIPlugin.getDefault().getJenkinsServiceForUrl(warUrl);
                BufferedInputStream in = new BufferedInputStream(service.getArtifact(warUrl, monitor));

                String warName = warUrl.substring(warUrl.lastIndexOf("/"));
                final File tempWar = File.createTempFile(warName, null);
                tempWar.deleteOnExit();

                monitor.beginTask("Deploy war to RUN@cloud", 100);
                SubMonitor subMonitor = SubMonitor.convert(monitor, "Downloading war file...", 50);
                OutputStream out = new BufferedOutputStream(new FileOutputStream(tempWar));
                byte[] buf = new byte[1 << 12];
                int len = 0;
                while ((len = in.read(buf)) >= 0) {
                    out.write(buf, 0, len);
                    subMonitor.worked(1);
                }

                out.flush();
                out.close();
                in.close();

                final String[] newAppUrl = new String[1];
                try {
                    subMonitor = SubMonitor.convert(monitor, "Deploying war file to RUN@cloud...", 50);
                    ApplicationDeployArchiveResponse result = BeesSDK.deploy(null, app.getId(),
                            tempWar.getAbsoluteFile(), subMonitor);
                    subMonitor.worked(50);
                    if (result != null) {
                        newAppUrl[0] = result.getUrl();
                    }
                } catch (Exception e) {
                    return new Status(IStatus.ERROR, CloudBeesDevUiPlugin.PLUGIN_ID, e.getMessage(), e);
                } finally {
                    monitor.done();
                }

                PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            if (newAppUrl[0] != null) {
                                boolean openConfirm = MessageDialog.openConfirm(
                                        CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy to RUN@cloud",
                                        "Deployment succeeded to RUN@cloud '" + app.getId() + "'.\nOpen "
                                                + newAppUrl[0] + " in the browser?");

                                if (openConfirm) {
                                    CloudBeesUIPlugin.getDefault().openWithBrowser(newAppUrl[0]);
                                }
                            } else {
                                MessageDialog.openWarning(CloudBeesUIPlugin.getActiveWindow().getShell(),
                                        "Deploy to RUN@cloud",
                                        "Deployment failed to RUN@cloud '" + app.getId() + "'.");
                            }
                        } catch (Exception e) {
                            CloudBeesDevUiPlugin.getDefault().getLogger().error(e);
                        }
                    }
                });

                return Status.OK_STATUS;
            } catch (OperationCanceledException e) {
                return Status.CANCEL_STATUS;
            } catch (Exception e) {
                e.printStackTrace(); // TODO
                return new Status(IStatus.ERROR, CloudBeesDevUiPlugin.PLUGIN_ID, e.getMessage(), e);
            } finally {
                monitor.done();
            }
        }
    };

    job.setUser(true);
    job.schedule();
}

From source file:com.cloudbees.eclipse.dev.ui.views.build.BuildPart.java

License:Open Source License

protected void reloadData() {
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

            BuildEditorInput details = (BuildEditorInput) getEditorInput();
            JenkinsService service = CloudBeesUIPlugin.getDefault()
                    .getJenkinsServiceForUrl(getBuildEditorInput().getJobUrl());

            try {

                setData(service.getJobDetails(details.getBuildUrl(), monitor),
                        service.getJobBuilds(getBuildEditorInput().getJobUrl(), monitor));

            } catch (CloudBeesException e) {
                CloudBeesUIPlugin.getDefault().getLogger().error(e);
                BuildPart.this.setOffline(service);
            }/*from ww  w.ja  v  a 2s .  com*/

            reloadUI();
        }
    };

    IProgressService service = PlatformUI.getWorkbench().getProgressService();
    try {
        service.run(false, true, op);
    } catch (InvocationTargetException e) {
        CloudBeesUIPlugin.getDefault().getLogger().error(e);
    } catch (InterruptedException e) {
        CloudBeesUIPlugin.getDefault().getLogger().error(e);
    }
}

From source file:com.cloudbees.eclipse.dev.ui.views.build.BuildPart.java

License:Open Source License

protected void switchToBuild(final long buildNo) {
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

            BuildEditorInput details = (BuildEditorInput) getEditorInput();
            String newBuildUrl = getBuildEditorInput().getJobUrl() + "/" + buildNo + "/";

            JenkinsService service = CloudBeesUIPlugin.getDefault()
                    .getJenkinsServiceForUrl(getBuildEditorInput().getJobUrl());

            try {
                setData(service.getJobDetails(newBuildUrl, monitor),
                        service.getJobBuilds(getBuildEditorInput().getJobUrl(), monitor));
                details.setBuildUrl(BuildPart.this.dataBuildDetail.url);
                details.setDisplayName(BuildPart.this.dataBuildDetail.getDisplayName());

            } catch (CloudBeesException e) {
                CloudBeesUIPlugin.getDefault().getLogger().error(e);
                BuildPart.this.setOffline(service);
            }/*  w  w  w  .j  a v a 2 s  .co m*/

            reloadUI();

        }
    };

    IProgressService service = PlatformUI.getWorkbench().getProgressService();
    try {
        service.run(false, true, op);
    } catch (InvocationTargetException e) {
        CloudBeesUIPlugin.getDefault().getLogger().error(e);
    } catch (InterruptedException e) {
        CloudBeesUIPlugin.getDefault().getLogger().error(e);
    }
}

From source file:com.cloudbees.eclipse.dev.ui.views.build.BuildPart.java

License:Open Source License

private void loadInitialData() {
    if (getEditorInput() == null) {
        return;/*from   w w  w  . j a v a  2s.c  om*/
    }

    final BuildEditorInput details = (BuildEditorInput) getEditorInput();

    if (details == null || details.getBuildUrl() == null) {

        // No last build available
        if (this.contentBuildHistory != null && !this.contentBuildHistory.isDisposed()) {
            this.contentBuildHistory.dispose();
        }

        this.contentJUnitTests.setText("No data available.");
        this.testsLink.setVisible(false);
        this.testsLink.getParent().layout(true);
        this.textTopSummary.setText("Latest build not available.");
        this.form.setText(getBuildEditorInput().getDisplayName());
        setPartName(getBuildEditorInput().getDisplayName());

    } else {

        IRunnableWithProgress op = new IRunnableWithProgress() {
            public void run(final IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {

                JenkinsService service = CloudBeesUIPlugin.getDefault()
                        .getJenkinsServiceForUrl(getBuildEditorInput().getBuildUrl());

                try {

                    setData(service.getJobDetails(getBuildEditorInput().getBuildUrl(), monitor),
                            service.getJobBuilds(getBuildEditorInput().getJobUrl(), monitor));

                } catch (CloudBeesException e) {
                    CloudBeesUIPlugin.getDefault().getLogger().error(e);
                    BuildPart.this.setOffline(service);
                    return;
                }

                reloadUI();

            }
        };

        IProgressService service = PlatformUI.getWorkbench().getProgressService();
        try {
            service.run(false, true, op);
        } catch (InvocationTargetException e) {
            CloudBeesUIPlugin.getDefault().getLogger().error(e);
        } catch (InterruptedException e) {
            CloudBeesUIPlugin.getDefault().getLogger().error(e);
        }
    }
}

From source file:com.cloudbees.eclipse.run.ui.wizards.ClickStartComposite.java

License:Open Source License

private Exception loadData() {

    if (AuthStatus.OK != CloudBeesUIPlugin.getDefault().getAuthStatus()) {
        ClickStartComposite.this
                .updateErrorStatus("User is not authenticated. Please review CloudBees account settings.");
        return null;
    }//  w  w w .  j ava  2 s  .  c o  m

    final Exception[] ex = { null };

    final IRunnableWithProgress operation1 = new IRunnableWithProgress() {

        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                monitor.beginTask(" Loading ClickStart templates from the repository...", 0);

                Collection<ClickStartTemplate> retlist = CloudBeesCorePlugin.getDefault().getClickStartService()
                        .loadTemplates(monitor);

                templateProvider.setElements(retlist.toArray(new ClickStartTemplate[0]));

                Display.getDefault().syncExec(new Runnable() {
                    public void run() {
                        v.refresh();
                        ClickStartComposite.this.validate();
                    }
                });

            } catch (CloudBeesException e) {
                ex[0] = e;
            }
        }
    };

    final IRunnableWithProgress operation2 = new IRunnableWithProgress() {

        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

            GitConnectionType type = CloudBeesUIPlugin.getDefault().getGitConnectionType();
            if (!type.equals(GitConnectionType.SSH)) {
                return;
            }

            try {
                monitor.beginTask(" Testing your connection to ssh://git.cloudbees.com...", 0);

                try {
                    if (!ForgeEGitSync.validateSSHConfig(monitor)) {
                        ex[0] = new CloudBeesException("Failed to connect!");
                    }
                } catch (JSchException e) {
                    ex[0] = e;
                }

            } catch (CloudBeesException e) {
                ex[0] = e;
            }
        }
    };
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            try {
                wizcontainer.run(true, false, operation2);
                if (ex[0] == null) {
                    wizcontainer.run(true, false, operation1);
                }

                if (ex[0] != null) {
                    //ex[0].printStackTrace();

                    if ("Auth fail".equals(ex[0].getMessage())) {
                        ClickStartComposite.this
                                .updateErrorStatus("Authentication failed. Are SSH keys properly configured?");
                    } else {
                        ClickStartComposite.this.updateErrorStatus(ex[0].getMessage());
                    }

                    ClickStartComposite.this.setPageComplete(ex[0] == null);
                }
            } catch (Exception e) {
                CBRunUiActivator.logError(e);
                e.printStackTrace();
            }
        }
    });

    return ex[0];

}

From source file:com.cloudbees.eclipse.ui.internal.preferences.GeneralPreferencePage.java

License:Open Source License

private void createCompositeLogin() {
    Group group = new Group(getFieldEditorParent(), SWT.SHADOW_ETCHED_IN);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    GridLayout gl = new GridLayout(1, false);
    gl.marginLeft = 5;/*from w w  w . ja  v  a2s .  co  m*/
    gl.marginRight = 5;
    gl.marginTop = 5;
    gl.marginBottom = 5;
    gl.horizontalSpacing = 5;

    group.setLayout(gl);

    Composite groupInnerComp = new Composite(group, SWT.NONE);

    groupInnerComp.setLayout(new GridLayout(2, false));
    groupInnerComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    group.setText(Messages.pref_group_login);

    final StringFieldEditor fieldEmail = new StringFieldEditor(PreferenceConstants.P_EMAIL, Messages.pref_email,
            30, groupInnerComp);

    fieldEmail.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addField(fieldEmail);

    final StringFieldEditor fieldPassword = new StringFieldEditor(PreferenceConstants.P_PASSWORD,
            Messages.pref_password, 30, groupInnerComp) {

        @Override
        protected void doLoad() {
            try {
                if (getTextControl() != null) {
                    String value = CloudBeesUIPlugin.getDefault().readP();
                    getTextControl().setText(value);
                    this.oldValue = value;
                }
            } catch (StorageException e) {
                // Ignore StorageException, very likely just
                // "No password provided."
            }
        }

        @Override
        protected void doStore() {
            try {

                CloudBeesUIPlugin.getDefault().storeP(getTextControl().getText());

            } catch (Exception e) {
                CloudBeesUIPlugin.showError(
                        "Saving password failed!\nPossible cause: Eclipse security master password is not set.",
                        e);
            }
        }

        @Override
        protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns);
            getTextControl().setEchoChar('*');
        }
    };

    fieldPassword.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addField(fieldPassword);

    Composite signupAndValidateRow = new Composite(groupInnerComp, SWT.NONE);
    GridData signupRowData = new GridData(GridData.FILL_HORIZONTAL);
    signupRowData.horizontalSpan = 2;

    signupAndValidateRow.setLayoutData(signupRowData);
    GridLayout gl2 = new GridLayout(2, false);
    gl2.marginWidth = 0;
    gl2.marginHeight = 0;
    gl2.marginTop = 5;
    signupAndValidateRow.setLayout(gl2);

    createSignUpLink(signupAndValidateRow);

    Button b = new Button(signupAndValidateRow, SWT.PUSH);
    GridData validateButtonLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    validateButtonLayoutData.widthHint = 75;
    b.setLayoutData(validateButtonLayoutData);

    b.setText(Messages.pref_validate_login);
    b.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            final String email = fieldEmail.getStringValue();
            final String password = fieldPassword.getStringValue();

            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            try {
                dialog.run(true, true, new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor) {
                        try {
                            monitor.beginTask("Validating CloudBees account...", 100); //TODO i18n

                            monitor.subTask("Connecting...");//TODO i18n
                            monitor.worked(10);
                            GrandCentralService gcs = new GrandCentralService();
                            gcs.setAuthInfo(email, password);
                            monitor.worked(20);

                            monitor.subTask("Validating...");//TODO i18n

                            final boolean loginValid = gcs.validateUser(monitor);
                            monitor.worked(50);

                            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                                public void run() {
                                    if (loginValid) {
                                        MessageDialog.openInformation(
                                                CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay()
                                                        .getActiveShell(),
                                                "Validation result", "Validation successful!");//TODO i18n
                                    } else {
                                        MessageDialog.openError(
                                                CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay()
                                                        .getActiveShell(),
                                                "Validation result",
                                                "Validation was not successful!\nWrong email or password?");//TODO i18n
                                    }
                                }

                            });

                            monitor.worked(20);

                        } catch (CloudBeesException e1) {
                            throw new RuntimeException(e1);
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (InvocationTargetException e1) {
                Throwable t1 = e1.getTargetException().getCause() != null ? e1.getTargetException().getCause()
                        : e1.getTargetException();
                Throwable t2 = t1.getCause() != null ? t1.getCause() : null;

                CloudBeesUIPlugin.showError("Failed to validate your account.", t1.getMessage(), t2);
            } catch (InterruptedException e1) {
                CloudBeesUIPlugin.showError("Failed to validate your account.", e1);
            }

        }
    });

}