Example usage for org.eclipse.jface.dialogs MessageDialogWithToggle setPrefStore

List of usage examples for org.eclipse.jface.dialogs MessageDialogWithToggle setPrefStore

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialogWithToggle setPrefStore.

Prototype

public void setPrefStore(IPreferenceStore prefStore) 

Source Link

Document

A mutator for the preference store to be modified by the toggle button.

Usage

From source file:com.aptana.ide.debug.internal.ui.InstallDebuggerPromptStatusHandler.java

License:Open Source License

/**
 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
 *///  w ww .j  ava  2  s.  c o  m
public Object handleStatus(IStatus status, Object source) throws CoreException {
    Shell shell = DebugUiPlugin.getActiveWorkbenchShell();
    String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension;

    if ("install".equals(source)) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit);
        return null;
    } else if ("postinstall".equals(source)) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit);
        return null;
    } else if ("nopdm".equals(source)) { //$NON-NLS-1$
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING,
                new String[] { StringUtils.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download),
                        CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP },
                0);
        switch (md.open()) {
        case 0:
            WorkbenchHelper.launchBrowser("http://www.aptana.com/pro/pdm.php", "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ //$NON-NLS-2$
            /* continue */
        case 1:
            return new Boolean(true);
        case 3:
            WorkbenchHelper.launchBrowser("http://www.aptana.com/docs/index.php/Installing_the_IE_debugger"); //$NON-NLS-1$
            return new Boolean(true);
        default:
            break;
        }
        return null;
    } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning,
                        new String[] { ((String) source).substring(5) }));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled,
                        new String[] { ((String) source).substring(10) }));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$
        MessageDialog.openWarning(shell, title, ((String) source).substring(8));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                title, null,
                MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed,
                        new Object[] { ((String) source).substring(7) }),
                MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0);
        while (true) {
            switch (md.open()) {
            case IDialogConstants.OK_ID:
                return null;
            default:
                break;
            }
            WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$
                    ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$
                    : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$
        }
    }
    IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore();

    String pref = store.getString(IDebugUIConstants.PREF_INSTALL_DEBUGGER);
    if (pref != null) {
        if (pref.equals(MessageDialogWithToggle.ALWAYS)) {
            return new Boolean(true);
        }
    }
    String message = StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled,
            new String[] { (String) source });

    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message,
            MessageDialog.INFORMATION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null,
            false);
    dialog.setPrefKey(IDebugUIConstants.PREF_INSTALL_DEBUGGER);
    dialog.setPrefStore(store);

    while (true) {
        switch (dialog.open()) {
        case IDialogConstants.YES_ID:
            return new Boolean(true);
        case IDialogConstants.NO_ID:
            return new Boolean(false);
        default:
            break;
        }
        WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$
                ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$
                : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$
    }
}

From source file:com.aptana.ide.debug.internal.ui.Startup.java

License:Open Source License

private String showBrowserNotFoundDialog(final boolean download) {
    final String[] path = new String[] { null };
    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
        public void run() {

            if (Display.getCurrent().getActiveShell() == null) { // another message box is shown
                return;
            }//from   w w  w. ja va 2s  .  c  om
            MessageDialogWithToggle md = new MessageDialogWithToggle(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    Messages.Startup_Notification, null, Messages.Startup_AptanaRequiresFirefox,
                    MessageDialog.INFORMATION,
                    new String[] { IDialogConstants.PROCEED_LABEL, StringUtils.ellipsify(CoreStrings.BROWSE),
                            download ? Messages.Startup_Download : Messages.Startup_CheckAgain },
                    0, Messages.Startup_DontAskAgain, false);
            md.setPrefKey(com.aptana.ide.debug.internal.ui.IDebugUIConstants.PREF_SKIP_FIREFOX_CHECK);
            md.setPrefStore(DebugUiPlugin.getDefault().getPreferenceStore());

            int returnCode = md.open();
            switch (returnCode) {
            case IDialogConstants.INTERNAL_ID:
                FileDialog fileDialog = new FileDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
                if (Platform.OS_WIN32.equals(Platform.getOS())) {
                    fileDialog.setFilterExtensions(new String[] { "*.exe" }); //$NON-NLS-1$
                    fileDialog.setFilterNames(new String[] { Messages.Startup_ExecutableFiles });
                }
                path[0] = fileDialog.open();
                break;
            case IDialogConstants.INTERNAL_ID + 1:
                if (download) {
                    WorkbenchHelper.launchBrowser("http://www.getfirefox.com"); //$NON-NLS-1$
                }
                path[0] = StringUtils.EMPTY;
                break;
            default:
            }
        }
    });
    return path[0];
}

From source file:com.aptana.ide.server.jetty.ShowPerspectiveClient.java

License:Open Source License

private boolean promptUser(String id) {
    Shell shell = JettyPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, Messages.ShowPerspectiveClient_1, null, // accept the default window icon
            MessageFormat.format(Messages.ShowPerspectiveClient_2, getPerspectiveName(id)),
            MessageDialogWithToggle.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0, // YES is the default
            null, false) {/* w ww  . j a  va  2 s.  c o  m*/
        @Override
        protected Control createCustomArea(Composite parent) {
            try {
                URL url = JettyPlugin.getDefault().getBundle().getEntry("/icons/animation.gif"); //$NON-NLS-1$
                url = FileLocator.toFileURL(url);
                Browser animation = new Browser(parent, SWT.NULL);
                animation.setText("<html>" + //$NON-NLS-1$
                "<body style='margin: 0; padding:0; border: 1px solid black' >" + //$NON-NLS-1$
                "<center>" + //$NON-NLS-1$
                "<img src='" + url.toExternalForm() + "' />" + //$NON-NLS-1$ //$NON-NLS-2$
                "</center>" + //$NON-NLS-1$
                "</body>" + //$NON-NLS-1$
                "</html>" //$NON-NLS-1$
                );
                GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, true, false);
                gridData.widthHint = 311 + 2; // 2 for border
                gridData.heightHint = 169 + 2; // 2 for border
                animation.setLayoutData(gridData);
                return animation;
            } catch (IOException e) {
            }
            Label animation = new Label(parent, SWT.CENTER);
            animation.setImage(JettyPlugin.getImage("/icons/animation.gif")); //$NON-NLS-1$
            GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
            animation.setLayoutData(gridData);
            return animation;
        }
    };
    dialog.setPrefStore(JettyPlugin.getDefault().getPreferenceStore());
    dialog.setPrefKey(getPrefKey(id));
    dialog.open();

    return (dialog.getReturnCode() == IDialogConstants.YES_ID);
}

From source file:com.aptana.js.debug.ui.internal.InstallDebuggerPromptStatusHandler.java

License:Open Source License

/**
 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
 *//*from www  . jav  a  2s .  co m*/
public Object handleStatus(IStatus status, Object source) throws CoreException {
    Shell shell = UIUtils.getActiveShell();
    String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension;

    if ("install".equals(source)) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit);
        return null;
    } else if ("postinstall".equals(source)) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit);
        return null;
    } else if ("nopdm".equals(source)) { //$NON-NLS-1$
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING,
                new String[] { StringUtil.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download),
                        CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP },
                0);
        switch (md.open()) {
        case 0:
            WorkbenchBrowserUtil.launchExternalBrowser(URL_INSTALL_PDM, "org.eclipse.ui.browser.ie"); //$NON-NLS-1$
            return Boolean.TRUE;
        case 1:
            return Boolean.TRUE;
        case 3:
            WorkbenchBrowserUtil.launchExternalBrowser(URL_DOCS_INSTALL_IE_DEBUGGER);
            return Boolean.TRUE;
        default:
            break;
        }
        return null;
    } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title, MessageFormat.format(
                Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, ((String) source).substring(5)));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled,
                        ((String) source).substring(10)));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$
        MessageDialog.openWarning(shell, title, ((String) source).substring(8));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                title, null,
                MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed,
                        new Object[] { ((String) source).substring(7) }),
                MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0);
        while (true) {
            switch (md.open()) {
            case IDialogConstants.OK_ID:
                return null;
            default:
                break;
            }
            String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$
                    ? URL_DOCS_INSTALL_IE_DEBUGGER
                    : URL_DOCS_INSTALL_DEBUGGER;
            WorkbenchBrowserUtil.launchExternalBrowser(urlString);
        }
    }
    IPreferenceStore store = JSDebugUIPlugin.getDefault().getPreferenceStore();

    String pref = store.getString(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER);
    if (pref != null) {
        if (pref.equals(MessageDialogWithToggle.ALWAYS)) {
            return Boolean.TRUE;
        }
    }
    String message = MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled,
            (String) source);

    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message,
            MessageDialog.INFORMATION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null,
            false);
    dialog.setPrefKey(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER);
    dialog.setPrefStore(store);

    while (true) {
        switch (dialog.open()) {
        case IDialogConstants.YES_ID:
            return Boolean.TRUE;
        case IDialogConstants.NO_ID:
            return Boolean.FALSE;
        default:
            break;
        }
        String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$
                ? URL_DOCS_INSTALL_IE_DEBUGGER
                : URL_DOCS_INSTALL_DEBUGGER;
        WorkbenchBrowserUtil.launchExternalBrowser(urlString);
    }
}

From source file:com.aptana.js.debug.ui.internal.LaunchConfigurationsHelper.java

License:Open Source License

public static String showBrowserNotFoundDialog(final boolean download) {
    final String[] path = new String[] { null };
    UIUtils.getDisplay().syncExec(new Runnable() {
        public void run() {
            MessageDialogWithToggle md = new MessageDialogWithToggle(UIUtils.getActiveShell(),
                    Messages.Startup_Notification, null, Messages.Startup_StudioRequiresFirefox,
                    MessageDialog.INFORMATION,
                    new String[] { StringUtil.ellipsify(CoreStrings.BROWSE),
                            download ? Messages.Startup_Download : Messages.Startup_CheckAgain,
                            IDialogConstants.CANCEL_LABEL },
                    0, Messages.Startup_DontAskAgain, false);
            md.setPrefKey(com.aptana.js.debug.ui.internal.IJSDebugUIConstants.PREF_SKIP_FIREFOX_CHECK);
            md.setPrefStore(JSDebugUIPlugin.getDefault().getPreferenceStore());

            int returnCode = md.open();
            switch (returnCode) {
            case IDialogConstants.INTERNAL_ID:
                FileDialog fileDialog = new FileDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
                if (Platform.OS_WIN32.equals(Platform.getOS())) {
                    fileDialog.setFilterExtensions(new String[] { "*.exe" }); //$NON-NLS-1$
                    fileDialog.setFilterNames(new String[] { Messages.Startup_ExecutableFiles });
                }/*from  www.ja v  a  2s  .c o  m*/
                path[0] = fileDialog.open();
                break;
            case IDialogConstants.INTERNAL_ID + 1:
                if (download) {
                    WorkbenchBrowserUtil.launchExternalBrowser("http://www.getfirefox.com"); //$NON-NLS-1$
                }
                path[0] = StringUtil.EMPTY;
                break;
            default:
            }
        }
    });
    return path[0];
}

From source file:com.ibm.xsp.extlib.designer.tooling.palette.applicationlayout.ApplicationLayoutDropAction.java

License:Open Source License

private boolean showWarning() {

    IPreferenceStore prefs = ExtLibToolingPlugin.getDefault().getPreferenceStore();
    boolean bHidePrompt = true;
    if (prefs != null) {
        bHidePrompt = prefs.getBoolean(ExtLibToolingPlugin.PREFKEY_HIDE_XPAGE_WARNING);
    }//from ww  w . j av  a  2  s .c  o m

    if (bHidePrompt)
        return true;

    Shell shell = getControl().getShell();

    String msg = "You are placing the Application Layout control on an XPage.\n\nThe Application Layout control is most effective when placed in a custom control, where you can configure the layout once and then use the custom control on multiple pages."; // $NLX-ApplicationLayoutDropAction.YouareplacingtheApplicationLayout-1$

    MessageDialogWithToggle dlg = new MessageDialogWithToggle(shell, "Application Layout", // $NLX-ApplicationLayoutDropAction.ApplicationLayout-1$
            null, // image 
            msg, MessageDialog.WARNING, new String[] { "Continue", "Cancel" }, // $NLX-ApplicationLayoutDropAction.Continue-1$ $NLX-ApplicationLayoutDropAction.Cancel-2$
            1, "Do not show this message again", // $NLX-ApplicationLayoutDropAction.Donotshowthismessageagain-1$
            bHidePrompt) {
        // this is necessary because "Continue" maps to IDialogConstants.INTERNAL_ID, 
        // (and prefs are stored as "always" or "never" by the dialog)
        // if "Continue" text changes, the use of IDialogConstants.INTERNAL_ID may need to change.
        protected void buttonPressed(int buttonId) {
            super.buttonPressed(buttonId);
            if (buttonId == IDialogConstants.INTERNAL_ID && getPrefStore() != null && getPrefKey() != null) {
                getPrefStore().setValue(getPrefKey(), getToggleState());
            }
        }
    };

    dlg.setPrefKey(ExtLibToolingPlugin.PREFKEY_HIDE_XPAGE_WARNING);
    dlg.setPrefStore(prefs);

    int code = dlg.open();
    boolean bShouldContinue = (code == IDialogConstants.INTERNAL_ID);

    return bShouldContinue;
}

From source file:com.mountainminds.eclemma.internal.ui.launching.InplaceInstrumentationHandler.java

License:Open Source License

public Object handleStatus(IStatus status, Object source) throws CoreException {

    ILaunchConfiguration config = (ILaunchConfiguration) source;
    Shell parent = EclEmmaUIPlugin.getInstance().getShell();
    String title = UIMessages.InstrumentationWarning_title;
    String message = NLS.bind(UIMessages.InstrumentationWarning_message, config.getName());

    IPreferenceStore store = EclEmmaUIPlugin.getInstance().getPreferenceStore();

    if (MessageDialogWithToggle.ALWAYS
            .equals(store.getString(UIPreferences.PREF_ALLOW_INPLACE_INSTRUMENTATION))) {
        return Boolean.TRUE;
    }//from  w  ww .  j  a  v a  2  s  . com

    MessageDialogWithToggle dialog = new MessageDialogWithToggle(parent, title, null, message,
            MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0,
            null, false);
    dialog.setPrefKey(UIPreferences.PREF_ALLOW_INPLACE_INSTRUMENTATION);
    dialog.setPrefStore(store);
    dialog.open();

    return Boolean.valueOf(dialog.getReturnCode() == IDialogConstants.OK_ID);
}

From source file:org.bonitasoft.studio.actors.ui.wizard.ManageOrganizationWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {/*from   www  .ja  v a  2s .c  o  m*/
        getContainer().run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(Messages.saveOrganization, IProgressMonitor.UNKNOWN);
                for (Organization organization : organizationsWorkingCopy) {
                    monitor.subTask(Messages.validatingOrganizationContent);
                    String errorMessage = isOrganizationValid(organization);
                    if (errorMessage != null) {
                        throw new InterruptedException(organization.getName() + ": " + errorMessage);
                    }
                    String fileName = organization.getName() + "."
                            + OrganizationRepositoryStore.ORGANIZATION_EXT;
                    IRepositoryFileStore file = store.getChild(fileName);
                    Organization oldOrga = null;
                    if (file == null) {
                        file = store.createRepositoryFileStore(fileName);
                    } else {
                        oldOrga = (Organization) file.getContent();
                    }
                    if (oldOrga != null) {
                        RefactorActorMappingsOperation refactorOp = new RefactorActorMappingsOperation(oldOrga,
                                organization);
                        refactorOp.run(monitor);
                    }
                    file.save(organization);
                }
                for (Organization orga : organizations) {
                    boolean exists = false;
                    for (Organization orgCopy : organizationsWorkingCopy) {
                        if (orgCopy.getName().equals(orga.getName())) {
                            exists = true;
                            break;
                        }
                    }
                    if (!exists) {
                        IRepositoryFileStore f = store
                                .getChild(orga.getName() + "." + OrganizationRepositoryStore.ORGANIZATION_EXT);
                        if (f != null) {
                            f.delete();
                        }
                    }
                }
                monitor.done();
            }
        });
    } catch (InterruptedException e) {
        openErrorStatusDialog(e.getMessage());
        return false;
    } catch (InvocationTargetException e) {
        BonitaStudioLog.error(e);
        return false;
    }
    IPreferenceStore preferenceStore = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore();
    String pref = preferenceStore.getString(ActorsPreferenceConstants.TOGGLE_STATE_FOR_PUBLISH_ORGANIZATION);
    boolean publishOrganization = preferenceStore.getBoolean(ActorsPreferenceConstants.PUBLISH_ORGANIZATION);
    if (publishOrganization && MessageDialogWithToggle.ALWAYS.equals(pref)) {
        try {
            publishOrganization(preferenceStore);
        } catch (InvocationTargetException e) {
            BonitaStudioLog.error(e);

        } catch (InterruptedException e) {
            BonitaStudioLog.error(e);
        }
    } else {
        if (MessageDialogWithToggle.NEVER.equals(pref) && activeOrganizationHasBeenModified) {
            String[] buttons = { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
            MessageDialogWithToggle mdwt = new MessageDialogWithToggle(Display.getDefault().getActiveShell(),
                    Messages.organizationHasBeenModifiedTitle, null,
                    Messages.bind(Messages.organizationHasBeenModifiedMessage, activeOrganization.getName()),
                    MessageDialog.WARNING, buttons, 0, Messages.doNotDisplayAgain, false);
            mdwt.setPrefStore(preferenceStore);
            mdwt.setPrefKey(ActorsPreferenceConstants.TOGGLE_STATE_FOR_PUBLISH_ORGANIZATION);
            int index = mdwt.open();
            if (index == 2) {
                try {
                    publishOrganization(preferenceStore);
                    if (mdwt.getToggleState()) {
                        preferenceStore.setDefault(ActorsPreferenceConstants.PUBLISH_ORGANIZATION, true);
                    }
                } catch (InvocationTargetException e) {
                    BonitaStudioLog.error(e);

                } catch (InterruptedException e) {
                    BonitaStudioLog.error(e);
                }
            } else {
                if (mdwt.getToggleState()) {
                    preferenceStore.setDefault(ActorsPreferenceConstants.PUBLISH_ORGANIZATION, false);
                    preferenceStore.setDefault(ActorsPreferenceConstants.TOGGLE_STATE_FOR_PUBLISH_ORGANIZATION,
                            MessageDialogWithToggle.ALWAYS);
                }
            }
        }

    }
    return true;
}

From source file:org.eclipse.debug.internal.ui.launchConfigurations.CompileErrorPromptStatusHandler.java

License:Open Source License

public Object handleStatus(IStatus status, Object source) throws CoreException {
    if (source instanceof ILaunchConfiguration) {
        ILaunchConfiguration config = (ILaunchConfiguration) source;
        if (DebugUITools.isPrivate(config)) {
            return Boolean.TRUE;
        }/*from  w ww.j a v a2 s  . co  m*/
    }

    Shell shell = DebugUIPlugin.getShell();
    String title = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_0;
    String message = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_1;
    IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();

    String pref = store.getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR);
    if (pref != null) {
        if (pref.equals(MessageDialogWithToggle.ALWAYS)) {
            return Boolean.TRUE;
        }
    }
    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message,
            MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1,
            LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_1, false);
    dialog.setPrefKey(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR);
    dialog.setPrefStore(store);
    dialog.open();

    int returnValue = dialog.getReturnCode();
    if (returnValue == IDialogConstants.YES_ID) {
        return Boolean.TRUE;
    }
    return Boolean.FALSE;
}

From source file:org.jboss.tools.project.examples.cheatsheet.internal.util.CheatSheetUtil.java

License:Open Source License

private static IFile promptToShowCheatsheets(List<IFile> cheatsheets) {
    IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
    String key = ProjectExamplesActivator.SHOW_CHEATSHEETS;
    String value = store.getString(key);
    if (MessageDialogWithToggle.ALWAYS.equals(value) && cheatsheets.size() == 1) {
        return cheatsheets.get(0);
    }/*from  www  . j a v  a2 s.c  o m*/
    if (MessageDialogWithToggle.NEVER.equals(value)) {
        return null;
    }
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    if (cheatsheets.size() == 1) {
        String projectName = cheatsheets.get(0).getProject().getName();
        String title = "Found cheatsheet";
        String message = "Do you wish to open the cheatsheet for the '" + projectName + "' project?";
        MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell, title, message, null,
                false, store, key);
        int result = dialog.getReturnCode();
        if (result == Window.CANCEL || result == SWT.DEFAULT) {
            throw new OperationCanceledException();
        }
        if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
            return cheatsheets.get(0);
        }
    } else {
        int kind = MessageDialog.QUESTION;
        String[] buttonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
        String title = "Found cheatsheets";
        String message = "Please select the cheatsheet you want to show:";
        MyMessageDialogWithToggle dialog = new MyMessageDialogWithToggle(shell, title, null, message, kind,
                buttonLabels, 0, null, false, cheatsheets);
        dialog.setPrefStore(store);
        dialog.setPrefKey(key);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result == Window.CANCEL || result == SWT.DEFAULT) {
            throw new OperationCanceledException();
        }
        if (dialog.getReturnCode() == IDialogConstants.OK_ID) {
            return dialog.getCheatsheet();
        }
    }
    return null;
}