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

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

Introduction

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

Prototype

int QUESTION

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

Click Source Link

Document

Constant for the question image, or a simple dialog with the question image and Yes/No buttons (value 3).

Usage

From source file:org.eclipse.sirius.common.ui.tools.api.util.SWTUtil.java

License:Open Source License

private static MessageDialog createSaveDialog(String label, final boolean canCancel,
        Map<String, Integer> buttons, boolean stillOpenElsewhere, final IWorkbenchWindow window) {
    final MessageDialog dialog;
    if (canCancel) {
        buttons.put(IDialogConstants.CANCEL_LABEL, IDialogConstants.CANCEL_ID);
    }/*ww w .  j a  v a2s  .  co m*/

    // Provide a dialog allowing the user to change the
    // preference if several editors are opened
    Object[] bindings = null;
    if (stillOpenElsewhere) {
        bindings = new Object[] { label, OPEN_ELSEWHERE_MESSAGE, OPEN_ELSEWHERE_QUESTION };
    } else {
        bindings = new Object[] { label, "", "" };
    }
    final String message = NLS.bind(SAVE_CHANGES_QUESTION, bindings);
    dialog = new SiriusMessageDialogWithToggle(window.getShell(), "Save", null, message, MessageDialog.QUESTION,
            buttons, 0, WorkbenchMessages.EditorManager_closeWithoutPromptingOption, false,
            stillOpenElsewhere) {
        protected int getShellStyle() {
            return getSaveDialogStyle(canCancel);
        }
    };
    return dialog;
}

From source file:org.eclipse.sirius.ui.tools.internal.actions.repair.RepresentationFilesRepairValidator.java

License:Open Source License

/**
 * @param dirtySessionsName/*from  ww w  .j  a va  2 s  . c o m*/
 *            The dirty sessions names
 * @return true if the dirty sessions must be saved, false otherwise
 * @throws CoreException
 *             If the user cancel the process
 */
private boolean userValidation(Collection<String> dirtySessionsName) throws CoreException {
    // Get the active shell
    Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
    if (shell == null) {
        shell = new Shell();
    }

    boolean saveSessions = false;
    String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel");
    StringBuffer message = new StringBuffer("It's impossible to launch the \"" + repairActionLabel
            + "\" action with opened representations file. So they will be closed before the repair process.");
    if (dirtySessionsName.size() > 0) {
        message.append(" The following representations file");
        if (dirtySessionsName.size() == 1) {
            message.append(" has");
        } else {
            message.append("s have");
        }
        message.append(" been modified : ");
        for (String dirtySessionName : dirtySessionsName) {
            message.append("\n\t- '");
            message.append(dirtySessionName);
            message.append("'");
            message.append(", ");
        }
        message.delete(message.length() - 2, message.length() - 1);
        message.append("\n\nSave changes?");
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
        final MessageDialog dialog = new MessageDialog(shell, MESSAGE_TITLE, null, message.toString(),
                MessageDialog.QUESTION, buttons, 0);
        int result = dialog.open();
        if (result == SWT.DEFAULT || buttons[result].equals(IDialogConstants.CANCEL_LABEL)) {
            throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID,
                    RepresentationFilesRepairValidator.OPERATION_CANCELED, "Migration canceled by user.",
                    null));
        }
        if (buttons[result].equals(IDialogConstants.YES_LABEL)) {
            saveSessions = true;
        }
    } else {
        message.append("\nDo you want to continue?");
        if (!MessageDialog.openConfirm(shell, MESSAGE_TITLE, message.toString())) {
            throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID,
                    RepresentationFilesRepairValidator.OPERATION_CANCELED, "Migration canceled by user.",
                    null));
        }
    }
    return saveSessions;
}

From source file:org.eclipse.tcf.te.launch.ui.handler.LaunchDialogHandler.java

License:Open Source License

protected void doLaunch(LaunchNode node) {
    if (node != null && node.getLaunchConfiguration() != null) {
        final String[] modes = LaunchConfigHelper.getLaunchConfigTypeModes(node.getLaunchConfigurationType(),
                false);/*from   w w w. j  a  v  a  2s  . co  m*/
        List<String> modeLabels = new ArrayList<String>();
        int defaultIndex = 0;
        for (String mode : modes) {
            if (LaunchManager.getInstance().validate(node.getLaunchConfiguration(), mode)) {
                ILaunchMode launchMode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(mode);
                modeLabels.add(launchMode.getLabel());
                if (mode.equals(ILaunchManager.DEBUG_MODE)) {
                    defaultIndex = modeLabels.size() - 1;
                }
            }
        }
        if (modeLabels.size() >= 1) {
            modeLabels.add(IDialogConstants.CANCEL_LABEL);
            OptionalMessageDialog dialog = new OptionalMessageDialog(
                    UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                    Messages.LaunchDialogHandler_dialog_title, null,
                    NLS.bind(Messages.LaunchDialogHandler_dialog_message,
                            node.getLaunchConfigurationType().getName(),
                            node.getLaunchConfiguration().getName()),
                    MessageDialog.QUESTION, modeLabels.toArray(new String[modeLabels.size()]), defaultIndex,
                    null, null);
            int result = dialog.open();
            if (result >= IDialogConstants.INTERNAL_ID) {
                DebugUITools.launch(node.getLaunchConfiguration(),
                        modes[result - IDialogConstants.INTERNAL_ID]);
            }
        }
    }
}

From source file:org.eclipse.tcf.te.launch.ui.viewer.dnd.CommonDnD.java

License:Open Source License

private String askForLaunchMode(ILaunchConfigurationType type, String[] modes) {
    List<String> modeLabels = new ArrayList<String>();
    int defaultIndex = 0;
    for (String mode : modes) {
        ILaunchMode launchMode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(mode);
        modeLabels.add(launchMode.getLabel());
        if (mode.equals(ILaunchManager.DEBUG_MODE)) {
            defaultIndex = modeLabels.size() - 1;
        }//w  ww. j av a  2  s .c om
    }
    if (modeLabels.size() > 0) {
        modeLabels.add(IDialogConstants.CANCEL_LABEL);
        OptionalMessageDialog dialog = new OptionalMessageDialog(
                UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.CommonDnD_launchMode_dialog_title, null,
                NLS.bind(Messages.CommonDnD_launchMode_dialog_message, type.getName()), MessageDialog.QUESTION,
                modeLabels.toArray(new String[modeLabels.size()]), defaultIndex, null, null);
        int result = dialog.open();
        if (result >= IDialogConstants.INTERNAL_ID) {
            return modes[result - IDialogConstants.INTERNAL_ID];
        }
    }
    return null;
}

From source file:org.eclipse.tcf.te.tcf.filesystem.ui.internal.dnd.CommonDnD.java

License:Open Source License

@Override
public int confirms(final Object object) {
    final int[] results = new int[1];
    Display display = PlatformUI.getWorkbench().getDisplay();
    display.syncExec(new Runnable() {
        @Override/*from   w w w.  ja v a 2 s.  c o m*/
        public void run() {
            Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            String title = Messages.FSUpload_OverwriteTitle;
            String message = NLS.bind(Messages.FSUpload_OverwriteConfirmation, getName(object));
            final Image titleImage = UIPlugin.getImage(ImageConsts.DELETE_READONLY_CONFIRM);
            MessageDialog qDialog = new MessageDialog(parent, title, null, message, MessageDialog.QUESTION,
                    new String[] { Messages.FSUpload_Yes, Messages.FSUpload_YesToAll, Messages.FSUpload_No,
                            Messages.FSUpload_Cancel },
                    0) {
                @Override
                public Image getQuestionImage() {
                    return titleImage;
                }
            };
            results[0] = qDialog.open();
        }
    });
    return results[0];
}

From source file:org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.MoveCopyCallback.java

License:Open Source License

@Override
public int confirms(Object object) {
    final boolean isDirectory = isDirectory(object);
    final String name = getName(object);
    final int[] results = new int[1];
    Display display = PlatformUI.getWorkbench().getDisplay();
    display.syncExec(new Runnable() {
        @Override//  ww  w  . ja  v  a2  s.co m
        public void run() {
            Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            String title = isDirectory ? Messages.FSOperation_ConfirmFolderReplaceTitle
                    : Messages.FSOperation_ConfirmFileReplace;
            String message = NLS.bind(isDirectory ? Messages.FSOperation_ConfirmFolderReplaceMessage
                    : Messages.FSOperation_ConfirmFileReplaceMessage, name);
            final Image titleImage = UIPlugin.getImage(ImageConsts.REPLACE_FOLDER_CONFIRM);
            MessageDialog qDialog = new MessageDialog(parent, title, null, message, MessageDialog.QUESTION,
                    new String[] { Messages.FSOperation_ConfirmDialogYes,
                            Messages.FSOperation_ConfirmDialogYesToAll, Messages.FSOperation_ConfirmDialogNo,
                            Messages.FSOperation_ConfirmDialogCancel },
                    0) {
                @Override
                public Image getQuestionImage() {
                    return titleImage;
                }
            };
            results[0] = qDialog.open();
        }
    });
    return results[0];
}

From source file:org.eclipse.team.internal.ccvs.ui.CVSHistoryPage.java

License:Open Source License

private boolean confirmOverwrite() {
    if (file != null && file.getIResource().exists()) {
        try {//from   w w w. j a v a  2 s  . co m
            if (file.isModified(null)) {
                String title = CVSUIMessages.HistoryView_overwriteTitle;
                String msg = CVSUIMessages.HistoryView_overwriteMsg;
                IHistoryPageSite parentSite = getHistoryPageSite();
                final MessageDialog dialog = new MessageDialog(parentSite.getShell(), title, null, msg,
                        MessageDialog.QUESTION,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
                final int[] result = new int[1];
                parentSite.getShell().getDisplay().syncExec(new Runnable() {
                    public void run() {
                        result[0] = dialog.open();
                    }
                });
                if (result[0] != 0) {
                    // cancel
                    return false;
                }
            }
        } catch (CVSException e) {
            CVSUIPlugin.log(e);
        }
    }
    return true;
}

From source file:org.eclipse.team.internal.ccvs.ui.CVSProjectSetSerializer.java

License:Open Source License

private int confirmOverwrite(IProject project, boolean yesToAll, Shell shell) {
    if (yesToAll)
        return 2;
    if (!project.exists())
        return 0;
    final MessageDialog dialog = new MessageDialog(shell,
            CVSUIMessages.CVSProjectSetSerializer_Confirm_Overwrite_Project_8, null,
            NLS.bind(//from   w ww .j a  v  a  2 s  .c om
                    CVSUIMessages.CVSProjectSetSerializer_The_project__0__already_exists__Do_you_wish_to_overwrite_it__9,
                    new String[] { project.getName() }),
            MessageDialog.QUESTION, // 
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL },
            0);
    final int[] result = new int[1];
    shell.getDisplay().syncExec(new Runnable() {
        public void run() {
            result[0] = dialog.open();
        }
    });
    return result[0];
}

From source file:org.eclipse.team.internal.ccvs.ui.mappings.ModelReplaceOperation.java

License:Open Source License

protected boolean promptForOverwrite() {
    if (hasPrompted)
        return true;
    final int[] result = new int[] { 1 };
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.ModelReplaceOperation_0, null, // accept
                    // the
                    // default
                    // window
                    // icon
                    CVSUIMessages.ModelReplaceOperation_1, MessageDialog.QUESTION,
                    new String[] { CVSUIMessages.ModelReplaceOperation_2, CVSUIMessages.ModelReplaceOperation_3,
                            IDialogConstants.CANCEL_LABEL },
                    result[0]); // preview is the default

            result[0] = dialog.open();/*  w  ww . ja va  2  s  . c  o  m*/

        };
    });
    if (result[0] == 2)
        throw new OperationCanceledException();
    hasPrompted = true;
    return result[0] == 0;
}

From source file:org.eclipse.team.internal.ccvs.ui.operations.DiffOperation.java

License:Open Source License

protected boolean shouldRun() {
    if (super.shouldRun() == false) {
        return false;
    }/*  w ww .  ja  va  2 s . co m*/
    Job[] jobs = Job.getJobManager().find(destination);
    if (jobs.length != 0) {
        MessageDialog question = new MessageDialog(getShell(),
                CVSUIMessages.DiffOperation_CreatePatchConflictTitle, null,
                NLS.bind(CVSUIMessages.DiffOperation_CreatePatchConflictMessage, destination.toString()),
                MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL },
                1);
        if (question.open() == 0) {
            Job.getJobManager().cancel(destination);
        } else {
            return false;
        }
    }
    return true;
}