Example usage for org.eclipse.jface.dialogs MessageDialog openInformation

List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openInformation.

Prototype

public static void openInformation(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard information dialog.

Usage

From source file:com.centurylink.mdw.plugin.designer.views.ProcessExplorerActionGroup.java

License:Apache License

private IAction createUnlockAction() {
    IAction action = new Action() {
        public void run() {
            if (unlockApplies(getSelection())) {
                WorkflowProject project = (WorkflowProject) getSelection().getFirstElement();
                WorkflowProjectManager.getInstance().makeLocal(project);
                project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwVcsRepository());
                MessageDialog.openInformation(getViewSite().getShell(), "Remote Project Unlocked",
                        project.getName() + " has been unlocked.  Please close any open assets and refresh.");
            }/*  ww w .j a va  2 s.  com*/
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "unlock");
    action.setText("Unlock");

    return action;
}

From source file:com.centurylink.mdw.plugin.designer.wizards.ImportPackageWizard.java

License:Apache License

@Override
public boolean performFinish() {
    final List<WorkflowPackage> importedPackages = new ArrayList<WorkflowPackage>();
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                WorkflowProject wfp = topFolder.getProject();
                DesignerProxy designerProxy = wfp.getDesignerProxy();

                monitor.beginTask("Import Packages",
                        100 * importPackageSelectPage.getSelectedPackages().size());
                monitor.subTask("Importing selected packages...");
                monitor.worked(10);//w ww  . j a v  a 2s.  co  m

                for (File pkgFile : importPackageSelectPage.getSelectedPackages()) {
                    ProgressMonitor progressMonitor = new SwtProgressMonitor(
                            new SubProgressMonitor(monitor, 100));
                    if (pkgFile.getContent() == null && pkgFile.getUrl() != null) { // download
                                                                                    // postponed
                                                                                    // for
                                                                                    // discovered
                                                                                    // assets
                        HttpHelper httpHelper = new HttpHelper(pkgFile.getUrl());
                        httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
                        httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
                        pkgFile.setContent(httpHelper.get());
                    }
                    String pkgFileContent = pkgFile.getContent();

                    Importer importer = new Importer(designerProxy.getPluginDataAccess(),
                            wfp.isFilePersist() && wfp.isRemote() ? null : getShell());
                    WorkflowPackage importedPackage = importer.importPackage(wfp, pkgFileContent,
                            progressMonitor);
                    if (importedPackage == null) // canceled
                    {
                        progressMonitor.done();
                        break;
                    } else {
                        if (upgradeAssets) {
                            progressMonitor.subTask("Upgrading activity implementors and other assets...");
                            designerProxy.upgradeAssets(importedPackage);
                        }

                        if (wfp.isFilePersist()) // file system eclipse sync
                            wfp.getSourceProject().refreshLocal(2, null);
                        // TODO refresh Archive in case existing package was
                        // moved there

                        importedPackage.addElementChangeListener(wfp);
                        for (WorkflowProcess pv : importedPackage.getProcesses())
                            pv.addElementChangeListener(wfp);
                        for (ExternalEvent ee : importedPackage.getExternalEvents())
                            ee.addElementChangeListener(wfp);
                        for (ActivityImpl ai : importedPackage.getActivityImpls())
                            ai.addElementChangeListener(wfp);
                        for (WorkflowAsset wa : importedPackage.getAssets())
                            wa.addElementChangeListener(wfp);
                        importedPackages.add(importedPackage);

                        if (wfp.isRemote() && wfp.isFilePersist()) {
                            // zip and upload imported packages to server
                            java.io.File tempDir = wfp.getTempDir();
                            if (!tempDir.exists()) {
                                if (!tempDir.mkdirs())
                                    throw new IOException("Unable to create temp directory: " + tempDir);
                            }
                            java.io.File zipFile = new java.io.File(tempDir + "/packages"
                                    + StringHelper.filenameDateToString(new Date()) + ".zip");
                            java.io.File assetDir = wfp.getAssetDir();
                            List<java.io.File> includes = new ArrayList<java.io.File>();
                            for (WorkflowPackage pkg : importedPackages)
                                includes.add(
                                        new java.io.File(assetDir + "/" + pkg.getName().replace('.', '/')));
                            // TODO populate excludes with non-imported
                            // package dirs (why, since these are not in
                            // includes?)
                            FileHelper.createZipFileWith(assetDir, zipFile, includes);
                            String uploadUrl = wfp.getServiceUrl()
                                    + "/upload?overwrite=true&assetZip=true&user="
                                    + importPackagePage.getProject().getUser().getUsername();
                            InputStream is = new FileInputStream(zipFile);
                            try {
                                ByteArrayOutputStream os = new ByteArrayOutputStream();
                                int read = 0;
                                byte[] bytes = new byte[1024];
                                while ((read = is.read(bytes)) != -1)
                                    os.write(bytes, 0, read);

                                String encryptedPassword = CryptUtil
                                        .encrypt(wfp.getMdwDataSource().getDbPassword());
                                HttpHelper httpHelper = new HttpHelper(new URL(uploadUrl),
                                        wfp.getMdwDataSource().getDbUser(), encryptedPassword);
                                byte[] resp = httpHelper.postBytes(os.toByteArray());
                                PluginMessages.log("Asset download respose: " + new String(resp));
                            } finally {
                                is.close();
                            }
                        }
                    }
                    progressMonitor.done();
                }

                wfp.getDesignerProxy().getCacheRefresh().doRefresh(true);
            } catch (ActionCancelledException ex) {
                throw new OperationCanceledException();
            } catch (Exception ex) {
                PluginMessages.log(ex);
                throw new InvocationTargetException(ex);
            }
        }
    };

    try {
        getContainer().run(true, true, op);
        for (WorkflowPackage importedPackage : importedPackages)
            importedPackage.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, importedPackage);
        if (importedPackages.size() > 0)
            DesignerPerspective.promptForShowPerspective(PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
                    importedPackages.get(0));
        return true;
    } catch (InterruptedException ex) {
        MessageDialog.openInformation(getShell(), "Import Package", "Import Cancelled");
        return true;
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Import Package", importPackagePage.getProject());
        return false;
    }
}

From source file:com.centurylink.mdw.plugin.designer.wizards.ImportProjectWizard.java

License:Apache License

@Override
public boolean performFinish() {
    if (errorMessage != null) {
        MessageDialog.openError(getShell(), "Import Project", errorMessage);
        return false;
    }/*  ww  w .  j a  v  a  2s. c o m*/

    BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
        public void run() {
            List<IProject> existingProjects = new ArrayList<IProject>();
            for (WorkflowProject toImport : projectsToImport) {
                IProject existing = MdwPlugin.getWorkspaceRoot().getProject(toImport.getName());
                if (existing != null && existing.exists())
                    existingProjects.add(existing);
            }

            if (!existingProjects.isEmpty()) {
                String text = "Please confirm that the following workspace projects should be overwritten:";
                ListSelectionDialog lsd = new ListSelectionDialog(getShell(), existingProjects,
                        new ExistingProjectContentProvider(), new ProjectLabelProvider(), text);
                lsd.setTitle("Existing Projects");
                lsd.setInitialSelections(existingProjects.toArray(new IProject[0]));
                lsd.open();
                Object[] results = (Object[]) lsd.getResult();
                if (results == null) {
                    cancel = true;
                    return;
                }

                for (IProject existing : existingProjects) {
                    boolean include = false;
                    for (Object included : results) {
                        if (existing.getName().equals(((IProject) included).getName()))
                            include = true;
                    }
                    if (include) {
                        WorkflowProjectManager.getInstance().deleteProject(existing);
                    } else {
                        WorkflowProject toRemove = null;
                        for (WorkflowProject wfp : projectList) {
                            if (wfp.getName().equals(existing.getName())) {
                                toRemove = wfp;
                                break;
                            }
                        }
                        if (toRemove != null)
                            projectsToImport.remove(toRemove);
                    }
                }
            }
        }
    });

    if (cancel)
        return false;

    if (projectsToImport.isEmpty()) {
        MessageDialog.openInformation(getShell(), "Import Projects", "No projects to import.");
        return true;
    }

    try {
        getContainer().run(false, false, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Importing MDW project(s)", 100);
                monitor.worked(20);
                try {
                    for (WorkflowProject workflowProject : projectsToImport) {
                        if (workflowProject.isFilePersist()) {
                            File projectDir = new File(
                                    ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile() + "/"
                                            + workflowProject.getName());
                            projectDir.mkdir();
                            String repositoryUrl = projectsToImport.get(0).getMdwVcsRepository()
                                    .getRepositoryUrl();
                            if (repositoryUrl != null && repositoryUrl.length() > 0) {
                                Platform.getBundle("org.eclipse.egit.ui").start(); // avoid
                                                                                   // Eclipse
                                                                                   // default
                                                                                   // Authenticator
                                workflowProject.setPersistType(PersistType.Git);
                                workflowProject.getMdwVcsRepository().setProvider(VcsRepository.PROVIDER_GIT);
                                monitor.subTask("Cloning Git repository for " + workflowProject.getLabel());
                                monitor.worked(1);
                                VcsRepository gitRepo = workflowProject.getMdwVcsRepository();
                                VersionControlGit vcsGit = new VersionControlGit();
                                String user = null;
                                String password = null;
                                if (MdwPlugin.getSettings().isUseDiscoveredVcsCredentials()) {
                                    user = gitRepo.getUser();
                                    password = gitRepo.getPassword();
                                }
                                vcsGit.connect(gitRepo.getRepositoryUrl(), user, password, projectDir);
                                vcsGit.cloneRepo();
                            } else {
                                File assetDir = new File(projectDir + "/"
                                        + workflowProject.getMdwVcsRepository().getLocalPath());
                                assetDir.mkdirs();
                            }
                            monitor.worked(40 / projectsToImport.size());
                        }
                        ProjectInflator inflator = new ProjectInflator(workflowProject,
                                MdwPlugin.getSettings());
                        inflator.inflateRemoteProject(getContainer());
                    }
                } catch (Exception ex) {
                    throw new InvocationTargetException(ex);
                }

                ProjectImporter projectImporter = new ProjectImporter(projectsToImport);
                projectImporter.doImport();
                monitor.worked(20);
                monitor.done();
            }
        });
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Import Project");
        return false;
    }

    DesignerPerspective.openPerspective(activeWindow);
    return true;
}

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

License:Apache License

public boolean performOk() {
    IProject project = (IProject) getElement();
    try {//from   w  w w  .ja v  a  2  s. co  m
        WorkflowProjectManager.getInstance().save(getProject(), project);
    } catch (CoreException ex) {
        PluginMessages.uiError(getShell(), ex, "Project Settings", getProject());
        return false;
    }

    if (getProject().getPersistType() == PersistType.Git) {
        if (!gitRepositoryUrlTextField.getText().trim().equals(originalGitRepositoryUrl)
                || !gitBranchTextField.getText().trim().equals(originalGitBranch)
                || !assetLocalPathTextField.getText().trim().equals(originalAssetLocalPath)
                || (includeArchiveCheckbox != null
                        && includeArchiveCheckbox.getSelection() != originalIncludeArchive)) {
            getProject().getMdwVcsRepository().setEntrySource("projectSettingsPropertyPage");
            getProject().fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, getProject().getMdwVcsRepository());
        }
    }
    if (!databaseJdbcUrlTextField.getText().trim().equals(originalJdbcUrl)) {
        getProject().getMdwDataSource().setEntrySource("projectSettingsPropertyPage");
        getProject().fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, getProject().getMdwDataSource());
    }
    if (mdwVersionComboBox != null && !mdwVersionComboBox.getText().equals(originalMdwVersion)) {
        getProject().fireElementChangeEvent(ChangeType.VERSION_CHANGE, getProject().getMdwVersion());
        if (MessageDialog.openQuestion(getShell(), "Update Framework Libraries",
                "The MDW version has changed.  Would you like to download updated framework libraries to match the new selection?")) {
            ProjectUpdater updater = new ProjectUpdater(getProject(), MdwPlugin.getSettings());
            try {
                updater.updateFrameworkJars(null);
                ExtensionModulesUpdater modulesUpdater = new ExtensionModulesUpdater(getProject());
                modulesUpdater.doUpdate(getShell());
            } catch (Exception ex) {
                PluginMessages.uiError(getShell(), ex, "Update Framework Libraries", getProject());
                return false;
            }
        }
        if (getProject().isOsgi())
            MessageDialog.openInformation(getShell(), "MDW Version Changed",
                    "The MDW version has been updated in the plug-in settings file.  Please update any MDW dependencies in your pom.xml build file.");
    }
    if (getProject().isRemote()) {
        if (!hostTextField.getText().trim().equals(originalHost)
                || !portTextField.getText().trim().equals(String.valueOf(originalPort))) {
            getProject().fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, getProject().getServerSettings());
        }
        if (!contextRootTextField.getText().trim().equals(originalContextRoot)) {
            getProject().fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, getProject().getWebContextRoot());
        }
        if (syncSwitch != null && syncSwitch.getSelection() != originalSync) {
            WorkflowProjectManager.getInstance().makeLocal(getProject());
            getProject().fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, getProject().getMdwVcsRepository());
            MessageDialog.openInformation(getShell(), "Remote Project Unlocked",
                    getProject().getName() + " has been unlocked.  Please close any open assets and refresh.");
        }
    }
    if (updateServerCacheCheckbox.getSelection() != originalRefreshServerCache)
        getProject().fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, getProject().isUpdateServerCache());

    return true;
}

From source file:com.ceteva.basicIO.AddLicenseKey.java

protected void buttonPressed(int buttonId) {
    if (buttonId == 0)
        key = text.getText();//from  w  ww .j a va 2s.co m
    super.buttonPressed(buttonId);
    MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Information",
            "Please restart the tool");
}

From source file:com.cisco.yangide.ext.refactoring.actions.InlineGroupingAction.java

License:Open Source License

@Override
public void run(ITextSelection selection) {
    if (node != null && (node instanceof GroupingDefinition || node instanceof UsesNode)) {
        IFile file = ((IFileEditorInput) editor.getEditorInput()).getFile();
        InlineGroupingRefactoring refactoring = new InlineGroupingRefactoring(file, (ASTNamedNode) node);
        InlineGroupingRefactoringWizard wizard = new InlineGroupingRefactoringWizard(refactoring);

        RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
        try {/*  w w  w .  j  a  va2s  . c o  m*/
            op.run(getShell(), "Inline Grouping");
        } catch (InterruptedException e) {
            // do nothing
        }
    } else {
        MessageDialog.openInformation(getShell(), "Inline",
                "Operation unavailable on the current selection.\nSelect a grouping or uses element.");
    }
}

From source file:com.cisco.yangide.ext.refactoring.actions.RenameAction.java

License:Open Source License

@Override
public void run(ITextSelection selection) {
    if (node != null && (isDirectRename(node) || isIndirectRename(node))) {
        RenameLinkedMode activeLinkedMode = RenameLinkedMode.getActiveLinkedMode();
        if (activeLinkedMode != null) {
            if (activeLinkedMode.isCaretInLinkedPosition()) {
                activeLinkedMode.startFullDialog();
                return;
            } else {
                activeLinkedMode.cancel();
            }//  w w  w .  j  av  a2s. com
        }

        ASTNode originalNode = null;
        IFile file = ((IFileEditorInput) editor.getEditorInput()).getFile();
        if (isIndirectRename(node)) {
            ElementIndexInfo info = RefactorUtil.getByReference(file.getProject(), node);
            if (info != null) {
                if (info.getEntry() != null && !info.getEntry().isEmpty()) {
                    MessageDialog.openInformation(getShell(), "Rename",
                            "Operation unavailable on the current selection.\n"
                                    + "The original element is located in JAR file and cannot be renamed.");
                    return;
                }
                originalNode = RefactorUtil.resolveIndexInfo(info);
            }
            if (originalNode == null) {
                MessageDialog.openInformation(getShell(), "Rename",
                        "Operation unavailable on the current selection.\n"
                                + "Cannot find the original element for the reference.");
                return;
            }
            file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(info.getPath()));
        } else {
            originalNode = node;
        }
        new RenameLinkedMode((ASTNamedNode) originalNode, file, (ASTNamedNode) node, editor).start();
    } else {
        MessageDialog.openInformation(getShell(), "Rename", "Operation unavailable on the current selection.\n"
                + "Select a grouping name, module name, type name or identify name.");
    }
}

From source file:com.clevercloud.eclipse.plugin.handlers.CreditsHandler.java

License:Creative Commons License

@Override
public Object execute(ExecutionEvent event) {
    Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
    MessageDialog.openInformation(shell, "Credits",
            "\nIcons are under Creative Commons Attribution 2.5 License\n"
                    + "http://www.famfamfam.com/lab/icons/silk/");
    return null;/* w  w w. jav a 2s. c  o  m*/
}

From source file:com.cloudbees.eclipse.dev.ui.CloudBeesDevUiPlugin.java

License:Open Source License

public void reloadForgeRepos(final boolean userAction, final boolean askSync) throws CloudBeesException {

    //      PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, new IRunnableWithProgress() {
    //        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    org.eclipse.core.runtime.jobs.Job job = new org.eclipse.core.runtime.jobs.Job(
            "Detecting Forge repositories") {
        @Override//from www.  ja v  a 2 s .  c om
        protected IStatus run(final IProgressMonitor monitor) {

            try {
                monitor.beginTask("Detecting Forge repositories", 10);

                final List<ForgeInstance> forgeRepos = CloudBeesUIPlugin.getDefault().getForgeRepos(monitor);
                int step = 1000 / Math.max(forgeRepos.size(), 1);

                IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 4);
                subMonitor.beginTask("", 1000);
                for (ForgeInstance repo : forgeRepos) {
                    subMonitor.subTask("Detecting repository '" + repo.url + "'");
                    CloudBeesCorePlugin.getDefault().getGrandCentralService().getForgeSyncService()
                            .updateStatus(repo, subMonitor);
                    subMonitor.worked(step);
                }
                subMonitor.subTask("");

                boolean needsToSync = false;
                final List<ForgeInstance> toSync = new ArrayList<ForgeInstance>();
                if (askSync) {
                    for (ForgeInstance repo : forgeRepos) {
                        if (repo.status != STATUS.SYNCED) {
                            toSync.add(repo);
                            if (userAction || repo.status == STATUS.UNKNOWN) { // automatically check only unknowns, which are either new or failed
                                needsToSync = true;
                            }
                        }
                    }
                }

                if (askSync && needsToSync && userAction) {
                    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
                        @Override
                        public void run() {

                            ForgeSyncConfirmation confDialog = new ForgeSyncConfirmation(CloudBeesDevUiPlugin
                                    .getDefault().getWorkbench().getDisplay().getActiveShell(), toSync);
                            int result = confDialog.open();

                            toSync.clear();
                            if (result == Dialog.OK) {
                                if (confDialog.getSelectedRepos() != null
                                        && !confDialog.getSelectedRepos().isEmpty()) {
                                    toSync.addAll(confDialog.getSelectedRepos());
                                }
                                // set those which user has seen but not checked as SKIPPED, otherwise it is UNKNOWN and must be checked
                                for (ForgeInstance repo : forgeRepos) {
                                    if (repo.status != STATUS.SYNCED) {
                                        if (!toSync.contains(repo)) {
                                            repo.status = STATUS.SKIPPED;
                                        } else {
                                            repo.status = STATUS.UNKNOWN;
                                        }
                                    }
                                }
                            }
                        }
                    });
                } else {
                    toSync.clear();
                }

                String mess = new String();
                if (!toSync.isEmpty()) {
                    subMonitor = new SubProgressMonitor(monitor, 4);
                    subMonitor.beginTask("", 1000);
                    for (ForgeInstance repo : toSync) {
                        subMonitor.subTask("Synchronizing repository '" + repo.url + "'");
                        CloudBeesCorePlugin.getDefault().getGrandCentralService().getForgeSyncService()
                                .sync(repo, subMonitor);
                        mess += repo.status.getLabel() + " " + repo.url + "\n\n"; // TODO show lastException somewhere here?
                        subMonitor.worked(step);
                    }
                    subMonitor.subTask("");
                }

                CloudBeesUIPlugin.getDefault().getPreferenceStore()
                        .setValue(PreferenceConstants.P_FORGE_INSTANCES, ForgeInstance.encode(forgeRepos));

                if (forgeRepos.isEmpty()) {
                    mess = "Found no Forge repositories!";
                }

                Iterator<CBRemoteChangeListener> iterator = CloudBeesUIPlugin.getDefault()
                        .getJenkinsChangeListeners().iterator();
                while (iterator.hasNext()) {
                    CBRemoteChangeListener listener = iterator.next();
                    listener.forgeChanged(forgeRepos);
                }

                monitor.worked(4);

                if (userAction && !toSync.isEmpty()) {
                    final String msg = mess;
                    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
                        @Override
                        public void run() {
                            MessageDialog.openInformation(CloudBeesDevUiPlugin.getDefault().getWorkbench()
                                    .getDisplay().getActiveShell(), "Synced Forge repositories", msg);
                        }
                    });
                }

                return Status.OK_STATUS; // new Status(Status.INFO, PLUGIN_ID, mess);
            } catch (Exception e) {
                CloudBeesUIPlugin.getDefault().getLogger().error(e);
                Iterator<CBRemoteChangeListener> iterator = CloudBeesUIPlugin.getDefault()
                        .getJenkinsChangeListeners().iterator();
                while (iterator.hasNext()) {
                    CBRemoteChangeListener listener = iterator.next();
                    listener.forgeChanged(null);
                }
                return new Status(Status.ERROR, PLUGIN_ID, e.getLocalizedMessage(), e);
            } finally {
                monitor.done();
            }
        }
    };

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

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;/* ww  w  .j a  v  a  2s.  c o  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();
}