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

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

Introduction

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

Prototype

public static boolean openConfirm(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple confirm (OK/Cancel) dialog.

Usage

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

License:Apache License

public void handleRefresh() {
    boolean refresh = true;
    if (isDirty()) {
        String confMsg = "Refresh will overwrite unsaved activity implementors. Continue?";
        refresh = MessageDialog.openConfirm(getSite().getShell(), "Confirm Refresh", confMsg);
    }//from w  w w  . j a  v a 2 s . c  om
    if (refresh) {
        toolboxWrapper.refresh();
        dirtyStateChanged(false);
        actionGroup.getDeleteAction().setEnabled(false);
    }
}

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

License:Apache License

public void handleSave() {
    boolean save = true;
    if (toolboxWrapper.getProject().isProduction()) {
        String confMsg = "Save activity implementors in Production environment?";
        save = MessageDialog.openConfirm(getSite().getShell(), "Confirm Save", confMsg);
    }//from   w  w w .jav a 2s . c om
    if (save) {
        List<ActivityImpl> dirtyImpls = toolboxWrapper.getDirtyImpls();
        List<String> dirtyImplNames = new ArrayList<String>();
        for (ActivityImpl dirtyImpl : dirtyImpls)
            dirtyImplNames.add(dirtyImpl.getImplClassName());
        int res = PluginMessages.uiList(getSite().getShell(),
                "The following modified activity implementors will be saved", "Save Implementors",
                dirtyImplNames);
        if (res == Dialog.CANCEL)
            return;

        getDesignerProxy().saveActivityImpls(dirtyImpls);

        toolboxWrapper.clearDirty();
        dirtyStateChanged(false);
        actionGroup.getDeleteAction().setEnabled(false);
        toolboxWrapper.update(); // redraw to reflect the change
    }
}

From source file:com.centurylink.mdw.plugin.launch.ProcessLaunchConfiguration.java

License:Apache License

protected void launchProcess(WorkflowProcess process, String masterRequestId, String owner, Long ownerId,
        boolean synchronous, String responseVarName, Map<String, String> parameters, Long activityId,
        boolean showLogs, int logWatchPort, boolean liveView) {
    List<VariableValue> variableValues = new ArrayList<VariableValue>();
    for (String varName : parameters.keySet()) {
        VariableVO variableVO = process.getVariable(varName);
        if (parameters.get(varName).length() > 0) {
            VariableTypeVO varType = process.getProject().getDataAccess()
                    .getVariableType(variableVO.getVariableType());
            variableValues.add(new VariableValue(variableVO, varType, parameters.get(varName)));
        }/*  www  .java2  s.c  o m*/
    }
    DesignerProxy designerProxy = process.getProject().getDesignerProxy();
    try {
        if (showLogs || liveView) {
            watch = true;

            LogWatcher logWatcher = designerProxy.getLogWatcher(MdwPlugin.getDisplay());
            if (logWatcher.isRunning()) {
                MdwPlugin.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        String message = "Live View is already monitoring an existing instance.  Disconnect to monitor new instance?";
                        watch = MessageDialog.openConfirm(MdwPlugin.getDisplay().getActiveShell(), "Live View",
                                message);
                    }
                });
            }

            if (watch) {
                logWatcher.shutdown();
                logWatcher.setMasterRequestId(masterRequestId);
                logWatcher.setProcess(process);
                logWatcher.startup(liveView);
            }
        }
        if (synchronous) {
            String response = designerProxy.launchSynchronousProcess(process, masterRequestId, owner, ownerId,
                    variableValues, responseVarName);
            if (isWriteToConsole())
                writeToConsole("Process Launch Response", response + "\n");
        } else {
            MDWStatusMessage statusMsg = designerProxy.launchProcess(process, masterRequestId, owner, ownerId,
                    variableValues, activityId);
            if (isWriteToConsole())
                writeToConsole("Process Launch Response", statusMsg.getStatusMessage() + "\n");
        }
    } catch (Exception ex) {
        showError(ex, "Launch Process", process.getProject());
    }
}

From source file:com.centurylink.mdw.plugin.project.extensions.CustomTaskManager.java

License:Apache License

@Override
public boolean removeUi(WorkflowProject project, Shell shell) throws ExtensionModuleException {
    String message = "Custom Task Manager project references will be removed.  (Please delete web project '"
            + project.getWebProjectName() + "' by hand.)";
    return MessageDialog.openConfirm(shell, "Remove Custom Task Manager", message);
}

From source file:com.centurylink.mdw.plugin.server.ServiceMixConfigurator.java

License:Apache License

public void doClientShell(Shell shell) {
    try {//from   w  w w .ja  v a2  s .c  o m
        // check for shell settings mismatch
        File karafShellProps = new File(getServerSettings().getServerLoc() + FILE_SEP + "etc" + FILE_SEP
                + "org.apache.karaf.shell.cfg");
        if (karafShellProps.exists()) {
            Properties shellProps = new Properties();
            shellProps.load(new FileInputStream(karafShellProps));
            String sshPort = shellProps.getProperty("sshPort");
            if (sshPort != null) {
                if (!sshPort.equals(String.valueOf(getServerSettings().getCommandPort()))) {
                    if (!MessageDialog.openConfirm(shell, "SSH Port Mismatch",
                            "The SSH port configured in the MDW Server Settings ("
                                    + getServerSettings().getCommandPort() + ") "
                                    + " appears to be different from the SSH port specified in the sshPort property in "
                                    + karafShellProps + " (" + sshPort + ").  Continue Client Shell Launch?")) {
                        return;
                    }
                }
            }
        }
    } catch (Exception ex) {
        PluginMessages.log(ex);
    }
    try {
        Runtime rt = Runtime.getRuntime();
        File smixBinDir = new File(getServerSettings().getHome() + FILE_SEP + "bin");
        String[] env = getEnvironment(false);
        for (int i = 0; i < env.length; i++) {
            if (env[i].toUpperCase().startsWith("COMSPEC="))
                env[i] = "COMSPEC="; // comspec causes command-line
                                     // interpretation problems
        }

        ServerConsoleSettings consoleSettings = MdwPlugin.getSettings().getServerConsoleSettings();
        if (ClientShell.Putty == consoleSettings.getClientShell()) {
            // putty
            File exe = consoleSettings.getClientShellExe();
            if (exe != null) {
                if (exe.exists() && exe.isFile())
                    rt.exec(exe + " -ssh -P " + getServerSettings().getCommandPort() + " -l "
                            + getServerSettings().getUser() + " -pw " + getServerSettings().getPassword() + " "
                            + getServerSettings().getHost(), env, exe.getParentFile());
                else
                    MessageDialog.openError(shell, "Client Shell",
                            "Putty executable file not found: '" + exe + "'");
            } else {
                MessageDialog.openError(shell, "Client Shell",
                        "Please specify the Putty executable location in your MDW Server Console preferences");
            }
        } else {
            // karaf client shell
            rt.exec("cmd /c start client.bat -a " + getServerSettings().getCommandPort() + " -u "
                    + getServerSettings().getUser() + " -p " + getServerSettings().getPassword(), env,
                    smixBinDir);
        }
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Client Shell", getServerSettings().getProject());
    }
}

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

License:Open Source License

/**
 * @param job/*from ww  w .j  a va2  s  .c om*/
 * @param monitor
 * @return <code>true</code> if succeeded
 * @throws CloudBeesException
 */
public void deleteJob(final Job job) throws CloudBeesException {
    boolean openConfirm = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
            "DELETING BUILD JOB!",
            "Are you sure you want to delete this build job?\n" + "Name: " + job.getDisplayName());

    if (openConfirm) {
        JenkinsService service = CloudBeesUIPlugin.getDefault().getJenkinsServiceForUrl(job.url);
        service.deleteJenkinsJob(job.url, new NullProgressMonitor());
    }

}

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  w  ww  .  ja v  a  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.run.ui.launchconfiguration.CBCloudLaunchShortcut.java

License:Open Source License

protected void internalLaunch(Object element, IProgressMonitor monitor, final IFile file, IProject project,
        final String preappid) throws CloudBeesException {

    // Strategy for decising if build is needed: invoke project build always when selection is project
    if (project != null) {
        try {/*from w  w  w.  java 2s . c om*/
            String appId = BeesSDK.getBareAppId(project);
            String account = CloudBeesUIPlugin.getDefault().getActiveAccountName(monitor);
            BeesSDK.deploy(project, account, appId, true, monitor);
            return;
        } catch (CloudBeesException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (file != null) {// deploy specified file, without build. If unknown type, confirm first.
        String appId;
        try {

            if (!BeesSDK.hasSupportedExtension(file.getName())) {
                final String ext = BeesSDK.getExtension(file.getName());

                final Boolean[] openConfirm = new Boolean[] { Boolean.FALSE };

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

                    public void run() {
                        openConfirm[0] = MessageDialog.openConfirm(
                                CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy to CloudBees RUN@cloud",
                                ext + " is an unknown app package type.\nAre you sure you want to deploy '"
                                        + file.getName() + "' to '" + preappid + "'?");
                    }

                });

                if (!openConfirm[0]) {
                    return;
                }

            }

            String account = CloudBeesUIPlugin.getDefault().getActiveAccountName(monitor);
            appId = BeesSDK.getAccountAppId(account, null, file.getProject());
            BeesSDK.deploy(project, appId, file.getRawLocation().toFile(), monitor);
            return;
        } catch (Exception e) {
            final Exception e2 = e;
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
                public void run() {
                    MessageDialog.openWarning(CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy failed!",
                            "Deployment failed for '" + file.getName() + "': " + e2.getMessage());
                }
            });
        }
    }

}

From source file:com.cloudbees.eclipse.run.ui.launchconfiguration.CBLocalLaunchDelegate.java

License:Open Source License

public static Process internalLaunch(IProgressMonitor monitor, final IFile file, IProject project,
        boolean debug, String port, String debugPort) {

    try {//from w w w  . jav a  2 s  .  co  m

        // Strategy for deciding if build is needed: invoke project build always when selection is project
        if (project != null) {
            return wrappedDeployLocal(project, file, debug, port, debugPort, monitor);
        } else if (file != null) {// deploy specified file, without build. If unknown type, confirm first.

            if (!BeesSDK.hasSupportedExtension(file.getName())) {
                final String ext = BeesSDK.getExtension(file.getName());

                final Boolean[] openConfirm = new Boolean[] { Boolean.FALSE };

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

                    public void run() {
                        openConfirm[0] = MessageDialog.openConfirm(
                                CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy to local",
                                ext + " is an unknown app package type.\nAre you sure you want to deploy '"
                                        + file.getName() + "' to local?");
                    }

                });

                if (!openConfirm[0]) {
                    return null;
                }

            }

            return wrappedDeployLocal(file.getProject(), file, debug, port, debugPort, monitor);

        }
    } catch (Exception e) {
        e.printStackTrace();
        final Exception e2 = e;
        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
            public void run() {
                MessageDialog.openWarning(CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy failed!",
                        "Deployment failed for '" + file.getName() + "': " + e2.getMessage());
            }
        });
    }

    return null;
}

From source file:com.clustercontrol.accesscontrol.dialog.ObjectPrivilegeEditDialog.java

License:Open Source License

/**
 * ?????// w  w  w.j  a  v a2 s .c o m
 *
 * @return true?false
 *
 * @see com.clustercontrol.dialog.CommonDialog#action()
 */
@Override
protected boolean action() {
    boolean result = true;

    java.util.List<ObjectPrivilegeInfo> inputdata = createInputData();
    StringBuffer confirmList = new StringBuffer();
    StringBuffer successList = new StringBuffer();
    StringBuffer failureList = new StringBuffer();
    String[] args = null;

    // ????????
    if (m_objects.size() > 1) {
        for (ObjectBean objectBean : m_objects) {
            confirmList.append(objectBean.getObjectId() + "\n");
        }

        args = new String[] { confirmList.toString() };
        if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                Messages.getString("message.accesscontrol.53", args))) {
            return false;
        }
    }

    for (ObjectBean objectBean : m_objects) {
        String objectPrivilegeParam = Messages.getString("object.privilege.param", new String[] {
                HinemosModuleMessage.nameToString(objectBean.getObjectType()), objectBean.getObjectId() });
        String managerName = objectBean.getManagerName();
        AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName);
        try {
            wrapper.replaceObjectPrivilegeInfo(objectBean.getObjectType(), objectBean.getObjectId(), inputdata);
            successList.append(objectPrivilegeParam + "(" + managerName + ")\n");
        } catch (UsedObjectPrivilege_Exception e) {
            args = new String[] { HinemosModuleMessage.nameToString(e.getFaultInfo().getObjectType()),
                    e.getFaultInfo().getObjectId() };
            // ?????????????
            failureList.append(
                    objectPrivilegeParam + " (" + Messages.getString("message.accesscontrol.36", args) + ")\n");
        } catch (InvalidRole_Exception e) {
            // ???
            failureList.append(
                    objectPrivilegeParam + " (" + Messages.getString("message.accesscontrol.16") + ")\n");
        } catch (JobMasterNotFound_Exception e) {
            // ????
            failureList.append(
                    objectPrivilegeParam + " (" + Messages.getString("message.accesscontrol.46") + ")\n");
        } catch (Exception e) {
            // ?
            m_log.warn("getOwnUserList(), " + HinemosMessage.replace(e.getMessage()), e);
            failureList.append(
                    objectPrivilegeParam + " (" + Messages.getString("message.hinemos.failure.unexpected")
                            + ", " + HinemosMessage.replace(e.getMessage()) + ")\n");
        }
    }

    // ?
    if (successList.length() != 0) {
        args = new String[] { successList.toString() };
        MessageDialog.openInformation(null, Messages.getString("successful"),
                Messages.getString("message.accesscontrol.49", args));
    }

    // 
    if (failureList.length() != 0) {
        args = new String[] { failureList.toString() };
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.accesscontrol.50", args));
    }

    return result;
}