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

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

Introduction

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

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:com.ibm.xsp.extlib.designer.bluemix.action.DeployAction.java

License:Open Source License

public static void deployWithQuestion() {
    if (ToolbarAction.project != null) {
        ManifestMultiPageEditor editor = BluemixUtil.getManifestEditor(ToolbarAction.project);
        if (editor != null) {
            if (editor.isDirty()) {
                MessageDialog dg = new MessageDialog(null, _DEPLOY_TXT, null,
                        "Do you want to save the Manifest before deployment?", // $NLX-DeployAction.DoyouwanttosavetheManifest-1$
                        MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                                IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                        0);//from  ww w  .  j  av  a  2s. c o m

                switch (dg.open()) {
                case 0:
                    //yes
                    editor.doSave(null);
                    break;
                case 1:
                    //no
                    break;
                case 2:
                    //cancel
                    return;
                }
            }
        }

        // Check for a valid configuration
        BluemixConfig config = ConfigManager.getInstance().getConfig(ToolbarAction.project);
        if (config.isValid(true)) {
            // Check the Server configuration
            if (BluemixUtil.isServerConfigured()) {
                // All good - Deploy !!!
                DeployJob job = new DeployJob(config, ToolbarAction.project);
                job.start();
            } else {
                // Server configuration problem
                BluemixUtil.displayConfigureServerDialog();
            }
        } else {
            if (config.isValid(false)) {
                // Something is wrong with the Manifest
                if (ManifestUtil.doesManifestExist(config)) {
                    // Corrupt
                    String msg = "The Manifest for this application is invalid. Cannot deploy."; // $NLX-DeployAction.TheManifestforthisapplicationisin-1$
                    MessageDialog.openError(null, _DEPLOY_TXT, msg);
                } else {
                    // Missing
                    String msg = "The Manifest for this application is missing. Do you want to open the Configuration Wizard?"; // $NLX-DeployAction.TheManifestforthisapplicationismi-1$
                    if (MessageDialog.openQuestion(null, _DEPLOY_TXT, msg)) {
                        ConfigBluemixWizard.launch();
                    }
                }
            } else {
                // App has not been configured or the bluemix.properties file is missing or corrupt
                String msg = "This application is not configured for deployment. Do you want to open the Configuration Wizard?"; // $NLX-DeployAction.Thisapplicationisnotconfiguredfor-1$
                if (MessageDialog.openQuestion(null, _DEPLOY_TXT, msg)) {
                    ConfigBluemixWizard.launch();
                }
            }
        }
    } else {
        MessageDialog.openError(null, _DEPLOY_TXT,
                "No application has been selected or the selected application is not open."); // $NLX-DeployAction.Noapplicationhasbeenselectedorthe-1$
    }
}

From source file:com.ibm.xsp.extlib.designer.tooling.panels.applicationlayout.ApplicationLayoutBasicsPanel.java

License:Open Source License

private boolean showConfigWarning() {
    String msg = "If you change the configuration, all attribute values associated with the current configuration will be lost. Do you want to continue?"; // $NLX-ApplicationLayoutBasicsPanel.Youareabouttochangetheconfigurati-1$
    MessageDialog dlg = new MessageDialog(getShell(), "Domino Designer", // $NLX-ApplicationLayoutDropDialog.Dominodesigner-1$
            null, // image 
            msg, MessageDialog.WARNING, new String[] { "Continue", "Cancel" }, // $NLX-ApplicationLayoutBasicsPanel.Continue-1$ $NLX-ApplicationLayoutBasicsPanel.Cancel-2$
            1);/*from   www  . j  a v  a2s.c o m*/

    int code = dlg.open();
    // "Continue" was returning 256.. but then started returning 0 at some point...did SWT version change (it was pending)?
    boolean bShouldContinue = (code == MessageDialog.OK); //Only continue if 'OK' (Continue) is pressed - otherwise bail out

    return bShouldContinue;
}

From source file:com.ibm.xsp.extlib.designer.tooling.utils.WizardUtils.java

License:Open Source License

public static boolean displayContinueDialog(Shell shell, String title, String msg) {
    MessageDialog dialog = new MessageDialog(shell, title, null, msg, MessageDialog.WARNING,
            new String[] { "Continue", "Cancel" }, 0); // $NLX-WizardUtils.Continue-1$ $NLX-WizardUtils.Cancel-2$
    return (dialog.open() == 0);
}

From source file:com.iw.plugins.spindle.ui.properties.ProjectPropertyPage.java

License:Mozilla Public License

private void doOk(IProgressMonitor monitor) throws CoreException {
    // store the values as properties
    IResource resource = (IResource) getElement();

    // resource.setPersistentProperty(
    // new QualifiedName("", PROJECT_TYPE_PROPERTY),
    // new Integer(TapestryProject.APPLICATION_PROJECT_TYPE).toString());

    resource.setPersistentProperty(new QualifiedName("", CONTEXT_ROOT_PROPERTY), fWebContextRoot.getText());

    resource.setPersistentProperty(new QualifiedName("", VALIDATE_WEBXML_PROPERTY),
            Boolean.toString(fValidateWebXML.getSelection()));

    final IProject workspaceProject = (IProject) (this.getElement().getAdapter(IProject.class));
    IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
        public void run(IProgressMonitor monitor) throws CoreException {
            if (fIsTapestryProjectCheck.getSelection()) {

                String projectName = workspaceProject.getProject().getName();
                String temp = fWebContextRoot.getText();
                createFolderIfRequired(projectName + temp);
                fNewProjectMetadata.setWebContext(temp);
                fNewProjectMetadata.setValidateWebXML(fValidateWebXML.getSelection());
                fNewProjectMetadata.saveProperties(monitor);
                IJavaProject jproject = getJavaProject();
                TapestryProject prj = getTapestryProject();
                if (prj == null) {
                    TapestryProject.addTapestryNature(jproject, true);
                } else {
                    prj.clearMetadata();
                }//from   ww  w  .java  2  s  .  c o  m
                try {
                    if (jproject
                            .findType(TapestryCore.getString("TapestryComponentSpec.specInterface")) == null) {
                        MessageDialog dialog = new MessageDialog(getShell(), "Tapestry jars missing", null,
                                "Add the Tapestry jars to the classpath?", MessageDialog.INFORMATION,
                                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
                        // OK is the default
                        int result = dialog.open();
                        if (result == 0) {
                            List entries = Arrays.asList(jproject.getRawClasspath());
                            ArrayList useEntries = new ArrayList(entries);
                            useEntries.add(JavaCore.newContainerEntry(new Path(TapestryCore.CORE_CONTAINER)));
                            jproject.setRawClasspath(
                                    (IClasspathEntry[]) useEntries.toArray(new IClasspathEntry[entries.size()]),
                                    monitor);
                        }
                    }
                } catch (JavaModelException e) {
                    UIPlugin.log(e);
                }

            } else {
                TapestryProject.removeTapestryNature(getJavaProject());
            }

            if (fIsTapestryProjectCheck.getSelection()) {
                IProject project = getJavaProject().getProject();
                project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            }
        }

    };

    UIPlugin.getWorkspace().run(runnable, monitor);
}

From source file:com.javapathfinder.vjp.config.LaunchDialog.java

License:Open Source License

private boolean shouldVerify() {
    if (VerifyJob.isRunning()) {
        new MessageDialog(getShell(), "Program being verified.", null,
                "Only one program can be verified at a time.", MessageDialog.ERROR, new String[] { "OK" }, 0)
                        .open();/*from   w  ww .  j  ava2  s .  c  o m*/
        return false;
    }
    if (!editor.isDirty())
        return true;
    MessageDialog dialog = new MessageDialog(getShell(), "Save Changes?", null,
            "Before the program can be verified changes made to the configuration must first be saved.",
            MessageDialog.ERROR, new String[] { "&Save New Properties and Verify",
                    "&Revert to Old Properties and Verify", "&Cancel" },
            2);
    int option = dialog.open();
    if (option == 0)
        editor.saveProperties();
    else if (option == 1)
        editor.revertProperties();
    else
        return false;
    return true;
}

From source file:com.liferay.ide.portlet.ui.action.BuildLanguagesAction.java

License:Open Source License

protected boolean checkLanguageFileEncoding(IFile langFile) throws CoreException {
    IProgressMonitor monitor = new NullProgressMonitor();

    try {//from  ww w .j  a  v a 2  s  .co m
        langFile.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    } catch (Exception e) {
        PortletUIPlugin.logError(e);
    }

    String charset = langFile.getCharset(true);

    if (!"UTF-8".equals(charset)) //$NON-NLS-1$
    {
        String dialogMessage = NLS.bind(Msgs.languageFileCharacterSet, charset);

        MessageDialog dialog = new MessageDialog(getDisplay().getActiveShell(), Msgs.incompatibleCharacterSet,
                getDisplay().getSystemImage(SWT.ICON_WARNING), dialogMessage, MessageDialog.WARNING,
                new String[] { Msgs.yes, Msgs.no, Msgs.cancel }, 0);

        int retval = dialog.open();

        if (retval == 0) {
            langFile.setCharset("UTF-8", monitor); //$NON-NLS-1$

            String question = NLS.bind(Msgs.forcedEditFile, langFile.getName());

            if (MessageDialog.openQuestion(getDisplay().getActiveShell(), Msgs.previewFile, question)) {
                IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), langFile);
            }

            return false;
        } else if (retval == 2) {
            return false;
        }
    }

    return true;
}

From source file:com.liferay.ide.portlet.ui.handlers.BuildLangHandler.java

License:Open Source License

protected boolean checkLanguageFileEncoding(IFile langFile) throws CoreException {
    IProgressMonitor monitor = new NullProgressMonitor();

    try {//  ww  w  . j  a va2 s  .c o m
        langFile.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    } catch (Exception e) {
        PortletUIPlugin.logError(e);
    }

    String charset = langFile.getCharset(true);

    if (!"UTF-8".equals(charset)) {
        String dialogMessage = NLS.bind(Msgs.languageFileCharacterSet, charset);

        MessageDialog dialog = new MessageDialog(UIUtil.getActiveShell(), Msgs.incompatibleCharacterSet,
                UIUtil.getActiveShell().getDisplay().getSystemImage(SWT.ICON_WARNING), dialogMessage,
                MessageDialog.WARNING, new String[] { Msgs.yes, Msgs.no, Msgs.cancel }, 0);

        int retval = dialog.open();

        if (retval == 0) {
            langFile.setCharset("UTF-8", monitor); //$NON-NLS-1$

            String question = NLS.bind(Msgs.forcedEditFile, langFile.getName());

            if (MessageDialog.openQuestion(UIUtil.getActiveShell(), Msgs.previewFile, question)) {
                IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), langFile);
            }

            return false;
        } else if (retval == 2) {
            return false;
        }
    }

    return true;
}

From source file:com.liferay.ide.server.tomcat.ui.CleanAppServerAction.java

License:Open Source License

protected void cleanAppServer(IProject project, String bundleZipLocation) throws CoreException {
    String[] labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };

    MessageDialog dialog = new MessageDialog(getDisplay().getActiveShell(), getTitle(), null,
            Msgs.deleteEntireTomcatDirectory, MessageDialog.WARNING, labels, 1);

    int retval = dialog.open();

    if (retval == MessageDialog.OK) {
        new CleanAppServerJob(project, bundleZipLocation).schedule();
    }/*w w  w  . ja v  a 2 s . com*/
}

From source file:com.mentor.nucleus.bp.core.util.UIUtil.java

License:Open Source License

/**
 * Note this "MessageDialog" currently only supports an array of 2 dialog button
 * labels.   This is why the result is a boolean.  It simply behaves in
 * a similar manner as if a yes/no question had been asked (offset 0 is
 * yes and offset 1 is no).   If additional buttons are ever needed this
 * will need to be modified to handle it.
 *//*from  ww  w.  ja  v  a  2s  .com*/
public static boolean openMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage,
        String dialogMessage, BPMessageTypes dialogType, String[] dialogButtonLabels, int defaultIndex) {
    int standardDialogType = MessageDialog.WARNING;
    if (dialogType == BPMessageTypes.ERROR) {
        standardDialogType = MessageDialog.ERROR;
    } else if ((dialogType == BPMessageTypes.INFORMATION)) {
        standardDialogType = MessageDialog.INFORMATION;
    }
    boolean result = (defaultIndex == MessageDialog.OK);
    if (CoreUtil.IsRunningHeadless) {
        outputTextForheadlessRun(dialogType, dialogTitle, dialogMessage, "");
    } else {
        MessageDialog dialog = new MessageDialog(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
                standardDialogType, dialogButtonLabels, defaultIndex);
        dialog.setBlockOnOpen(true);
        int actualResult = dialog.open();
        result = MessageDialog.OK == actualResult;
    }
    return result;
}

From source file:com.mentor.nucleus.bp.core.util.UIUtil.java

License:Open Source License

/**
 * //w  w w  .  j  a va 2s.c  om
 * @param msg
 * @return true if the user responds yes and false if the user responds no
 */
public static boolean displayYesNoQuestion(final String msg) {
    displayYesNoQuestion_isYes = true;

    if (CoreUtil.IsRunningHeadless) {
        displayYesNoQuestion_isYes = UIUtil.openMessageDialog(null, "BridgePoint UML Suite", null, msg,
                UIUtil.BPMessageTypes.QUESTION, new String[] { "Yes", "No" }, 0); // yes is he default
    } else {
        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

            public void run() {
                org.eclipse.swt.widgets.Shell sh = PlatformUI.getWorkbench().getDisplay().getActiveShell();
                MessageDialog dialog = new MessageDialog(sh, "BridgePoint UML Suite", null, msg,
                        MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0); // yes is the default

                displayYesNoQuestion_isYes = (dialog.open() == 0);
            }
        });
    }
    return displayYesNoQuestion_isYes;
}