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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a simple Yes/No question dialog.

Usage

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.TargetURLDialog.java

License:Open Source License

@Override
protected void okPressed() {
    //      List<CloudURL> allUrls = CloudUiUtil.getAllUrls(serverTypeId);
    for (CloudServerURL url : allCloudUrls) {
        if (url.getName().equals(name)) {
            MessageDialog.openError(getParentShell(), Messages.TargetURLDialog_ERROR_DUPLICATE_TITLE,
                    NLS.bind(Messages.TargetURLDialog_ERROR_DUPLICATE_BODY, name));
            return;
        }/*w  ww .  j  a  v a2  s .  co  m*/
    }

    final boolean[] shouldProceed = new boolean[] { false };

    BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

        public void run() {
            url = replaceWildcard(cloudUrl.getUrl(), wildcard, value);
            try {
                DockerFoundryPlugin.getCloudFoundryClientFactory().getCloudFoundryOperations(url)
                        .getCloudInfo();
                shouldProceed[0] = true;
            } catch (Exception e) {
                shouldProceed[0] = MessageDialog.openQuestion(getParentShell(),
                        Messages.TargetURLDialog_ERROR_INVALID_URL_TITLE,
                        NLS.bind(Messages.TargetURLDialog_ERROR_INVALID_URL_BODY, url));
            }
        }
    });

    if (shouldProceed[0]) {
        super.okPressed();
    }
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.wizards.CloudUrlWizard.java

License:Open Source License

protected boolean validateURL() {

    final Exception[] exception = new Exception[1];
    final Boolean[] shouldProceed = new Boolean[1];
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            shouldProceed[0] = launchURLValidation(exception, monitor);
        }/* w w w. j  av  a 2  s  . c  o m*/
    };

    try {
        // Must both fork and set cancellable to true in order to enable
        // cancellation of long-running validations
        getContainer().run(true, true, runnable);
    } catch (InvocationTargetException e) {
        exception[0] = e;
    } catch (InterruptedException e) {
        exception[0] = e;
    }
    if (!shouldProceed[0]) {
        String errorMessage = getErrorMessage(exception[0], url);
        shouldProceed[0] = MessageDialog.openQuestion(getShell(), Messages.CloudUrlWizard_ERROR_KEEP_TITLE,
                errorMessage + Messages.CloudUrlWizard_ERROR_KEEP_BODY);
    }
    return shouldProceed[0];

}

From source file:com.adobe.granite.ide.eclipse.ui.wizards.np.NewGraniteProjectWizard.java

License:Apache License

private boolean assertPublicRepoConfigured() {
    try {//  w ww. ja v a2  s  . c  o  m
        List<ArtifactRepository> repos = MavenPlugin.getMaven().getPluginArtifactRepositories();
        for (Iterator<ArtifactRepository> it = repos.iterator(); it.hasNext();) {
            ArtifactRepository artifactRepository = it.next();
            if (isRepoAdobeCom(artifactRepository)) {
                return true;
            }
        }
        if (!MessageDialog.openQuestion(getShell(), "Could not find repo.adobe.com in settings.xml",
                "Could not find repo.adobe.com or *.adobe.com as a configured repository. Please note that you need direct or indirect access to an adobe.com repository.\n\n"
                        + "For details on how to setup repo.adobe.com please visit http://helpx.adobe.com/experience-manager/kb/SetUpTheAdobeMavenRepository.html\n\n"
                        + "Would you still like to continue?")) {
            reportError(new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
                    "Could not find repo.adobe.com as a configured repository (double-check settings.xml as per http://helpx.adobe.com/experience-manager/kb/SetUpTheAdobeMavenRepository.html)")));
            return false;
        } else {
            return true;
        }
    } catch (CoreException e) {
        reportError(e);
        return false;
    }

}

From source file:com.alibaba.antx.config.gui.MainWindow.java

License:Open Source License

public void handleShellCloseEvent() {
    if (MessageDialog.openQuestion(getShell(), "??",
            "??/?????")) {
        super.handleShellCloseEvent();
    }/*  w w  w .j  a v  a  2s.  co m*/
}

From source file:com.aliyun.odps.eclipse.utils.DialogUtil.java

License:Apache License

public static void question(String title, String msg) {
    MessageDialog.openQuestion(Display.getDefault().getActiveShell(), title, msg);
}

From source file:com.amalto.workbench.service.MissingJarService.java

License:Open Source License

private void showRestartConfirmDialog() {
    Display.getDefault().syncExec(new Runnable() {

        public void run() {
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            boolean restart = MessageDialog.openQuestion(shell, Messages.MissingJarService_InstallJarTitle,
                    Messages.MissingJarService_RestartStudioMsg);
            if (restart) {
                PlatformUI.getWorkbench().restart();
            }/*from   w  w w . j  a v a  2 s  . co m*/
        }
    });

}

From source file:com.amazonaws.eclipse.ec2.ui.views.instances.CreateAmiAction.java

License:Apache License

private void createAmiFromInstance(Instance instance) {
    boolean userIdIsValid = (InstanceSelectionTable.accountInfo.getUserId() != null);
    if (!InstanceSelectionTable.accountInfo.isValid()
            || !InstanceSelectionTable.accountInfo.isCertificateValid() || !userIdIsValid) {
        String message = "Your AWS account information doesn't appear to be fully configured yet.  "
                + "To bundle an instance you'll need all the information configured, "
                + "including your AWS account ID, EC2 certificate and private key file."
                + "\n\nWould you like to configure it now?";

        if (MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),
                "Configure AWS Account Information", message)) {
            new SetupAwsAccountAction().run();
        }//from  w w w  .  j  av a 2s.c  o  m

        return;
    }

    KeyPairManager keyPairManager = new KeyPairManager();
    String keyName = instance.getKeyName();
    String keyPairFilePath = keyPairManager
            .lookupKeyPairPrivateKeyFile(AwsToolkitCore.getDefault().getCurrentAccountId(), keyName);

    if (keyPairFilePath == null) {
        String message = "There is no private key registered for the key this host was launched with ("
                + keyName + ").";
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "No Registered Private Key", message);
        return;
    }

    BundleDialog bundleDialog = new BundleDialog(Display.getCurrent().getActiveShell());
    if (bundleDialog.open() != IDialogConstants.OK_ID)
        return;

    String bundleName = bundleDialog.getImageName();
    String s3Bucket = bundleDialog.getS3Bucket();

    BundleJob job = new BundleJob(instance, s3Bucket, bundleName);
    job.schedule();
}

From source file:com.amazonaws.eclipse.ec2.ui.views.instances.OpenShellAction.java

License:Apache License

protected void openInstanceShell(Instance instance, String user) {
    PlatformUtils platformUtils = new PlatformUtils();

    try {/* w  w w  . j ava2  s. co  m*/
        KeyPairManager keyPairManager = new KeyPairManager();

        String keyName = instance.getKeyName();
        String keyPairFilePath = keyPairManager
                .lookupKeyPairPrivateKeyFile(AwsToolkitCore.getDefault().getCurrentAccountId(), keyName);

        if (user == null) {
            user = Ec2Plugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_SSH_USER);
        }

        if (keyPairFilePath == null) {
            throw new Exception("Unable to locate the private key file for the selected key '" + keyName + "'");
        }

        if (!platformUtils.isSshClientConfigured()) {
            String message = "Your SSH client doesn't appear to be configured correctly yet.  Would you like to configure it now?";

            if (MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "SSH Client Configuration",
                    message)) {
                new SetupExternalToolsAction().run();
            }

            return;
        }

        platformUtils.openShellToRemoteHost(user, instance.getPublicDnsName(), keyPairFilePath);
    } catch (Exception e) {
        Status status = new Status(IStatus.ERROR, Ec2Plugin.PLUGIN_ID,
                "Unable to open a shell to the selected instance: " + e.getMessage(), e);
        StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
    }
}

From source file:com.amitinside.e4.rcp.todo.handlers.UpdateHandler.java

License:Apache License

@Execute
public void execute(final IProvisioningAgent agent, final Shell parent, final UISynchronize sync,
        final IWorkbench workbench) {
    Job j = new Job("Update Job") {
        private boolean doInstall = false;

        /*//from   ww w  .j  a  v  a 2  s.  co m
         * (non-Javadoc)
         * 
         * @see
         * org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime
         * .IProgressMonitor)
         */
        @Override
        protected IStatus run(final IProgressMonitor monitor) {

            /* 1. Prepare update plumbing */

            final ProvisioningSession session = new ProvisioningSession(agent);
            final UpdateOperation operation = new UpdateOperation(session);

            // Create uri
            URI uri = null;
            try {
                uri = new URI(REPOSITORY_LOC);
            } catch (final URISyntaxException e) {
                sync.syncExec(new Runnable() {
                    @Override
                    public void run() {
                        MessageDialog.openError(parent, "URI invalid", e.getMessage());
                    }
                });
                return Status.CANCEL_STATUS;
            }

            // Set location of artifact and metadata repo
            // (Explain difference between meta und artifact repo)
            operation.getProvisioningContext().setArtifactRepositories(new URI[] { uri });
            operation.getProvisioningContext().setMetadataRepositories(new URI[] { uri });

            /* 2. Check for updates */

            // Run update checks causing I/O
            final IStatus status = operation.resolveModal(monitor);

            // Failed to find updates (inform user and exit)
            if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
                sync.syncExec(new Runnable() {
                    /*
                     * (non-Javadoc)
                     * 
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        MessageDialog.openWarning(parent, "No update",
                                "No updates for the current installation have been found");
                    }
                });
                return Status.CANCEL_STATUS;
            }

            /* 3. Ask if updates should be installed and run installation */

            // found updates, ask user if to install?
            if (status.isOK() && status.getSeverity() != IStatus.ERROR) {
                sync.syncExec(new Runnable() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        String updates = "";
                        Update[] possibleUpdates = operation.getPossibleUpdates();
                        for (Update update : possibleUpdates) {
                            updates += update + "\n";
                        }
                        doInstall = MessageDialog.openQuestion(parent, "Relly install updates?", updates);
                    }
                });
            }

            // Install! (causing I/0)
            if (doInstall) {
                final ProvisioningJob provisioningJob = operation.getProvisioningJob(monitor);
                // Updates cannot run from within Eclipse IDE!!!
                if (provisioningJob == null) {
                    System.err.println("Running update from within Eclipse IDE? This won't work!!!");
                    throw new NullPointerException();
                }

                // Register a job change listener to track
                // installation progress and notify user upon success
                provisioningJob.addJobChangeListener(new JobChangeAdapter() {
                    @Override
                    public void done(IJobChangeEvent event) {
                        if (event.getResult().isOK()) {
                            sync.syncExec(new Runnable() {

                                @Override
                                public void run() {
                                    boolean restart = MessageDialog.openQuestion(parent,
                                            "Updates installed, restart?",
                                            "Updates have been installed successfully, do you want to restart?");
                                    if (restart) {
                                        workbench.restart();
                                    }
                                }
                            });

                        }
                        super.done(event);
                    }
                });

                provisioningJob.schedule();
            }
            return Status.OK_STATUS;
        }
    };
    j.schedule();
}

From source file:com.android.ide.eclipse.adt.AdtPlugin.java

License:Open Source License

/**
 * Display a yes/no question dialog box. This dialog is opened synchronously in the ui thread,
 * therefore this message can be called from any thread.
 * @param title The title of the dialog box
 * @param message The error message//from  ww  w .j a va 2 s . c  o  m
 * @return true if OK was clicked.
 */
public final static boolean displayPrompt(final String title, final String message) {
    // get the current Display and Shell
    final Display display = getDisplay();

    // we need to ask the user what he wants to do.
    final boolean[] result = new boolean[1];
    display.syncExec(new Runnable() {
        @Override
        public void run() {
            Shell shell = display.getActiveShell();
            result[0] = MessageDialog.openQuestion(shell, title, message);
        }
    });
    return result[0];
}