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

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

Introduction

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

Prototype

int QUESTION_WITH_CANCEL

To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION_WITH_CANCEL.

Click Source Link

Document

Constant for a simple dialog with the question image and Yes/No/Cancel buttons (value 6).

Usage

From source file:org.jboss.tools.common.ui.marker.AddSuppressWarningsMarkerResolution.java

License:Open Source License

private void disablePreference() {
    String value = preferences.getProjectPreference(file.getProject(), PROBLEM_ID);
    if (!SeverityPreferences.IGNORE.equals(value)) {

        IEclipsePreferences projectPreferences = preferences.getProjectPreferences(file.getProject());
        String projectValue = null;
        if (projectPreferences != null) {
            projectValue = projectPreferences.get(PROBLEM_ID, null);
        }/*ww  w.ja v  a2  s  .  c  o  m*/

        if (projectValue != null) {
            MessageDialog dialog = new MessageDialog(getShell(), label, null,
                    CommonUIMessages.ADD_SUPPRESS_WARNINGS_MESSAGE
                            + CommonUIMessages.ADD_SUPPRESS_WARNINGS_QUESTION1,
                    MessageDialog.QUESTION_WITH_CANCEL,
                    new String[] { CommonUIMessages.ADD_SUPPRESS_WARNINGS_CANCEL,
                            CommonUIMessages.ADD_SUPPRESS_WARNINGS_DISABLE },
                    0);
            int result = dialog.open();
            if (result == 1) {
                IEclipsePreferences ePrefs = preferences.getProjectPreferences(file.getProject());
                ePrefs.put(PROBLEM_ID, SeverityPreferences.IGNORE);
                try {
                    ePrefs.flush();
                } catch (BackingStoreException e) {
                    CommonUIPlugin.getDefault().logError(e);
                }
            }
        } else {
            MessageDialog dialog = new MessageDialog(getShell(), label, null,
                    CommonUIMessages.ADD_SUPPRESS_WARNINGS_MESSAGE + NLS.bind(
                            CommonUIMessages.ADD_SUPPRESS_WARNINGS_QUESTION2, file.getProject().getName()),
                    MessageDialog.QUESTION_WITH_CANCEL,
                    new String[] { CommonUIMessages.ADD_SUPPRESS_WARNINGS_CANCEL,
                            CommonUIMessages.ADD_SUPPRESS_WARNINGS_WORKSPACE,
                            CommonUIMessages.ADD_SUPPRESS_WARNINGS_PROJECT },
                    0);
            int result = dialog.open();
            if (result == 1) {
                IEclipsePreferences ePrefs = preferences.getInstancePreferences();
                ePrefs.put(PROBLEM_ID, SeverityPreferences.IGNORE);
                try {
                    ePrefs.flush();
                } catch (BackingStoreException e) {
                    CommonUIPlugin.getDefault().logError(e);
                }
            } else if (result == 2) {
                IEclipsePreferences ePrefs = preferences.getProjectPreferences(file.getProject());
                ePrefs.put(PROBLEM_ID, SeverityPreferences.IGNORE);
                try {
                    ePrefs.flush();
                } catch (BackingStoreException e) {
                    CommonUIPlugin.getDefault().logError(e);
                }
            }
        }
    }
}

From source file:org.jboss.tools.jsf.ui.marker.DisableFaceletHTMLValidatorMarkerResolution.java

License:Open Source License

public void run(IMarker marker) {
    MessageDialog dialog = null;// www .  j a v  a  2s.  c  o m
    dialog = new MessageDialog(getShell(), label, null,
            NLS.bind(JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_MESSAGE, file.getName())
                    + NLS.bind(JsfUIMessages.DISABLE_FACELET_HTML_VALIDATOR_MARKER_RESOLUTION_PROJECT_QUESTION,
                            file.getProject().getName()),
            MessageDialog.QUESTION_WITH_CANCEL,
            new String[] { "Cancel", "Workspace", file.getProject().getName() }, 0);
    int result = dialog.open();
    if (result == 1) {
        disableOnWorkspace();
    } else if (result == 2) {
        disableOnProject();
    }
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.wspm.PdbWspmProject.java

License:Open Source License

/**
 * Checks if the data should be save, and asks the user what to do.<br/>
 * Show a 'Yes', 'No', 'Cancel' dialog./*from ww w.  ja va2s .co  m*/
 * 
 * @param If
 *          set to <code>true</code>, the data will be reloaded if the user chooses 'NO'.
 * @return <code>false</code>, if the user cancels the operation.
 */
public boolean askForProjectSave() {
    if (m_provider == null)
        return true;

    final boolean dirty = m_provider.isDirty();
    if (!dirty)
        return true;

    final Shell shell = m_window.getShell();
    final String message = Messages.getString("PdbWspmProject.2"); //$NON-NLS-1$
    final String[] buttonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
            IDialogConstants.CANCEL_LABEL };
    final MessageDialog dialog = new MessageDialog(shell, STR_SAVE_LOCAL_DATA_TITLE, null, message,
            MessageDialog.QUESTION_WITH_CANCEL, buttonLabels, 0);
    final int result = dialog.open();

    if (result == 0) {
        final ICoreRunnableWithProgress operation = new ICoreRunnableWithProgress() {
            @Override
            public IStatus execute(final IProgressMonitor monitor) throws CoreException {
                doSave(monitor);
                return Status.OK_STATUS;
            }
        };

        return busyCursorWhile(operation, STR_SAVE_LOCAL_DATA_TITLE, Messages.getString("PdbWspmProject.3")); //$NON-NLS-1$
    } else if (result == 1)
        return true;
    else if (result == 2 || result == -1)
        return false;

    throw new IllegalStateException();
}

From source file:org.opentravel.schemas.actions.UnlockLibraryAction.java

License:Apache License

private UnlockOperation askUser() {
    List<UnlockOperation> operations = Arrays.asList(UnlockOperation.values());
    String[] labels = toStringArray(operations);
    MessageDialog dialog = new MessageDialog(OtmRegistry.getActiveShell(),
            Messages.getString("action.library.unlock.title"), null,
            Messages.getString("action.library.unlock.message"), MessageDialog.QUESTION_WITH_CANCEL, labels,
            operations.indexOf(UnlockOperation.CANCEL));

    int ret = dialog.open();
    return operations.get(ret);
}

From source file:org.opentravel.schemas.stl2developer.DialogUserNotifier.java

License:Apache License

public static int openQuestionWithCancel(final String title, final String question) {
    if (!OtmRegistry.getMainWindow().hasDisplay())
        return 2;
    final MessageDialog dg = new MessageDialog(OtmRegistry.getActiveShell(), title, null, question,
            MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0);/*  w w  w . j av a2 s.  c o  m*/
    return dg.open();
}

From source file:tubame.knowhow.plugin.ui.dialog.ConfirmDialog.java

License:Apache License

/**
 * Confirmation dialog for constructor.<br/>
 * Confirmation dialog with "Yes" "No" "Cancel" button.<br/>
 * //from   w  ww.java 2s  .  c  o m
 * @param parentShell
 *            Shell to be displayed screen
 * @param dialogTitle
 *            Title of the dialog
 * @param dialogMessage
 *            Messages that are displayed in the dialog
 * @param dialogType
 *            Type of dialog
 */
public ConfirmDialog(Shell parentShell, String dialogTitle, String dialogMessage, int dialogType) {

    super(parentShell, dialogTitle, null, dialogMessage, dialogType, null, 1);

    LOGGER.debug("shell:" + parentShell + "message" + dialogMessage);
    if (dialogType == MessageDialog.QUESTION_WITH_CANCEL) {
        super.setButtonLabels(new String[] { "Yes", "No", "Cancel" });
    } else if (dialogType == MessageDialog.INFORMATION) {
        super.setButtonLabels(new String[] { "Yes" });
    } else {
        super.setButtonLabels(new String[] { "Yes", "No" });
    }
}