Example usage for org.eclipse.jface.dialogs IDialogConstants NO_LABEL

List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_LABEL

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.

Prototype

String NO_LABEL

To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.

Click Source Link

Document

The label for no buttons.

Usage

From source file:org.eclipse.ui.ide.examples.projectsnapshot.ProjectRefreshSnapshotImportWizardPage.java

License:Open Source License

/**
 * The <code>WizardDataTransfer</code> implementation of this
 * <code>IOverwriteQuery</code> method asks the user whether the existing
 * resource at the given path should be overwritten.
 * //from w  w  w  . j av a2  s  . c o m
 * @param pathString
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
 *         <code>"ALL"</code>, or <code>"CANCEL"</code>
 */
public String queryOverwrite(String pathString) {

    Path path = new Path(pathString);

    String messageString;
    // Break the message up if there is a file name and a directory
    // and there are at least 2 segments.
    if (path.getFileExtension() == null || path.segmentCount() < 2) {
        messageString = NLS.bind(Messages.ProjectRefreshSnapshotImportWizardPage_overwrite, pathString);
    } else {
        messageString = NLS.bind(Messages.ProjectRefreshSnapshotImportWizardPage_overwriteInFolder,
                path.lastSegment(), path.removeLastSegments(1).toOSString());
    }

    final MessageDialog dialog = new MessageDialog(getContainer().getShell(),
            Messages.ProjectRefreshSnapshotImportWizardPage_question, null, messageString,
            MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0);
    String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
    // run in syncExec because callback is from an operation,
    // which is probably not running in the UI thread.
    getControl().getDisplay().syncExec(new Runnable() {
        public void run() {
            dialog.open();
        }
    });
    return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}

From source file:org.eclipse.ui.ide.IDE.java

License:Open Source License

/**
 * Prompt the user to inform them of the possible side effects of an
 * operation on resources. Do not prompt for side effects from ignored model
 * providers. A model provider can be ignored if it is the client calling
 * this API. Any message from the provided model provider id or any model
 * providers it extends will be ignored.
 * //from  w  w w .  j  a  v  a 2  s. c  o  m
 * @param shell
 *            the shell to parent the prompt dialog
 * @param title
 *            the title of the dialog
 * @param message
 *            the message for the dialog
 * @param delta
 *            a delta built using an
 *            {@link IResourceChangeDescriptionFactory}
 * @param ignoreModelProviderIds
 *            model providers to be ignored
 * @param syncExec
 *            prompt in a sync exec (required when called from a non-UI
 *            thread)
 * @return whether the user chose to continue
 * @since 3.2
 */
public static boolean promptToConfirm(final Shell shell, final String title, String message,
        IResourceDelta delta, String[] ignoreModelProviderIds, boolean syncExec) {
    IStatus status = ResourceChangeValidator.getValidator().validateChange(delta, null);
    if (status.isOK()) {
        return true;
    }
    final IStatus displayStatus;
    if (status.isMultiStatus()) {
        List result = new ArrayList();
        IStatus[] children = status.getChildren();
        for (int i = 0; i < children.length; i++) {
            IStatus child = children[i];
            if (!isIgnoredStatus(child, ignoreModelProviderIds)) {
                result.add(child);
            }
        }
        if (result.isEmpty()) {
            return true;
        }
        if (result.size() == 1) {
            displayStatus = (IStatus) result.get(0);
        } else {
            displayStatus = new MultiStatus(status.getPlugin(), status.getCode(),
                    (IStatus[]) result.toArray(new IStatus[result.size()]), status.getMessage(),
                    status.getException());
        }
    } else {
        if (isIgnoredStatus(status, ignoreModelProviderIds)) {
            return true;
        }
        displayStatus = status;
    }

    if (message == null) {
        message = IDEWorkbenchMessages.IDE_sideEffectWarning;
    }
    final String dialogMessage = NLS.bind(IDEWorkbenchMessages.IDE_areYouSure, message);

    final boolean[] result = new boolean[] { false };
    Runnable runnable = new Runnable() {
        public void run() {
            ErrorDialog dialog = new ErrorDialog(shell, title, dialogMessage, displayStatus,
                    IStatus.ERROR | IStatus.WARNING | IStatus.INFO) {
                protected void createButtonsForButtonBar(Composite parent) {
                    createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
                    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
                    createDetailsButton(parent);
                }

                /*
                 * (non-Javadoc)
                 * 
                 * @see org.eclipse.jface.dialogs.ErrorDialog#buttonPressed(int)
                 */
                protected void buttonPressed(int id) {
                    if (id == IDialogConstants.YES_ID) {
                        super.buttonPressed(IDialogConstants.OK_ID);
                    } else if (id == IDialogConstants.NO_ID) {
                        super.buttonPressed(IDialogConstants.CANCEL_ID);
                    }
                    super.buttonPressed(id);
                }

                protected int getShellStyle() {
                    return super.getShellStyle() | SWT.SHEET;
                }
            };
            int code = dialog.open();
            result[0] = code == 0;
        }
    };
    if (syncExec) {
        shell.getDisplay().syncExec(runnable);
    } else {
        runnable.run();
    }
    return result[0];
}

From source file:org.eclipse.ui.ide.undo.WorkspaceUndoUtil.java

License:Open Source License

private static int queryDeleteOutOfSync(IResource resource, IAdaptable uiInfo) {
    Shell shell = getShell(uiInfo);//from   w  w  w.ja  v  a  2s.  c  o m
    final MessageDialog dialog = new MessageDialog(shell,
            UndoMessages.AbstractResourcesOperation_deletionMessageTitle, null,
            NLS.bind(UndoMessages.AbstractResourcesOperation_outOfSyncQuestion, resource.getName()),
            MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0) {
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    shell.getDisplay().syncExec(new Runnable() {
        public void run() {
            dialog.open();
        }
    });
    int result = dialog.getReturnCode();
    if (result == 0) {
        return IDialogConstants.YES_ID;
    }
    if (result == 1) {
        return IDialogConstants.YES_TO_ALL_ID;
    }
    if (result == 2) {
        return IDialogConstants.NO_ID;
    }
    return IDialogConstants.CANCEL_ID;
}

From source file:org.eclipse.ui.internal.dialogs.SavePerspectiveDialog.java

License:Open Source License

/**
 * Notifies that the ok button of this dialog has been pressed.
 * <p>/*w ww  . jav a  2s  . co m*/
 * The default implementation of this framework method sets
 * this dialog's return code to <code>Window.OK</code>
 * and closes the dialog. Subclasses may override.
 * </p>
 */
protected void okPressed() {
    perspName = text.getText();
    persp = perspReg.findPerspectiveWithLabel(perspName);
    if (persp != null) {
        // Confirm ok to overwrite
        String message = NLS.bind(WorkbenchMessages.SavePerspective_overwriteQuestion, perspName);
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
        MessageDialog d = new MessageDialog(this.getShell(), WorkbenchMessages.SavePerspective_overwriteTitle,
                null, message, MessageDialog.QUESTION, buttons, 0) {
            protected int getShellStyle() {
                return super.getShellStyle() | SWT.SHEET;
            }
        };

        switch (d.open()) {
        case 0: //yes
            break;
        case 1: //no
            return;
        case 2: //cancel
            cancelPressed();
            return;
        default:
            return;
        }
    }

    super.okPressed();
}

From source file:org.eclipse.ui.internal.editors.text.SpellingConfigurationBlock.java

License:Open Source License

private ComboViewer createProviderViewer() {
    /* list viewer */
    final ComboViewer viewer = new ComboViewer(fProviderCombo);
    viewer.setContentProvider(new IStructuredContentProvider() {

        /*//from  w w  w.j a  va 2s.  c om
         * @see org.eclipse.jface.viewers.IContentProvider#dispose()
         */
        public void dispose() {
        }

        /*
         * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
         */
        public void inputChanged(Viewer v, Object oldInput, Object newInput) {
        }

        /*
         * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
         */
        public Object[] getElements(Object inputElement) {
            return fProviderDescriptors.values().toArray();
        }
    });
    viewer.setLabelProvider(new LabelProvider() {
        /*
         * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
         */
        public Image getImage(Object element) {
            return null;
        }

        /*
         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
         */
        public String getText(Object element) {
            return ((SpellingEngineDescriptor) element).getLabel();
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            if (sel.isEmpty())
                return;
            if (fCurrentBlock != null && fStatusMonitor.getStatus() != null
                    && fStatusMonitor.getStatus().matches(IStatus.ERROR))
                if (isPerformRevert()) {
                    ISafeRunnable runnable = new ISafeRunnable() {
                        public void run() throws Exception {
                            fCurrentBlock.performRevert();
                        }

                        public void handleException(Throwable x) {
                        }
                    };
                    SafeRunner.run(runnable);
                } else {
                    revertSelection();
                    return;
                }
            fStore.setValue(SpellingService.PREFERENCE_SPELLING_ENGINE,
                    ((SpellingEngineDescriptor) sel.getFirstElement()).getId());
            updateListDependencies();
        }

        private boolean isPerformRevert() {
            Shell shell = viewer.getControl().getShell();
            MessageDialog dialog = new MessageDialog(shell,
                    TextEditorMessages.SpellingConfigurationBlock_error_title, null,
                    TextEditorMessages.SpellingConfigurationBlock_error_message, MessageDialog.QUESTION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1);
            return dialog.open() == 0;
        }

        private void revertSelection() {
            try {
                viewer.removeSelectionChangedListener(this);
                SpellingEngineDescriptor desc = EditorsUI.getSpellingService()
                        .getActiveSpellingEngineDescriptor(fStore);
                if (desc != null)
                    viewer.setSelection(new StructuredSelection(desc), true);
            } finally {
                viewer.addSelectionChangedListener(this);
            }
        }
    });
    viewer.setInput(fProviderDescriptors);
    viewer.refresh();

    return viewer;
}

From source file:org.eclipse.ui.internal.ide.dialogs.ResourceInfoPage.java

License:Open Source License

private boolean shouldPerformRecursiveChanges(List/*<IResourceChange>*/ changes) {
    if (!changes.isEmpty()) {
        String message = IDEWorkbenchMessages.ResourceInfo_recursiveChangesSummary + "\n"; //$NON-NLS-1$
        for (int i = 0; i < changes.size(); i++) {
            message += ((IResourceChange) changes.get(i)).getMessage();
        }/*from  w  w w.j  a  v a2s. co m*/
        message += IDEWorkbenchMessages.ResourceInfo_recursiveChangesQuestion;

        MessageDialog dialog = new MessageDialog(getShell(),
                IDEWorkbenchMessages.ResourceInfo_recursiveChangesTitle, null, message, MessageDialog.QUESTION,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1);

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

From source file:org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler.java

License:Open Source License

private FatalErrorDialog openInternalQuestionDialog(Shell parent, String title, String message,
        Throwable detail, int defaultIndex) {
    String[] labels;//  w  w w.j av a2s.c  o  m
    if (detail == null) {
        labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
    } else {
        labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.SHOW_DETAILS_LABEL };
    }

    FatalErrorDialog dialog = new FatalErrorDialog(parent, title, null, // accept
            // the
            // default
            // window
            // icon
            message, detail, MessageDialog.QUESTION, labels, defaultIndex);
    if (detail != null) {
        dialog.setDetailButton(2);
    }
    return dialog;
}

From source file:org.eclipse.ui.internal.operations.AdvancedValidationUserApprover.java

License:Open Source License

private IStatus reportAndInterpretStatus(IStatus status, IAdaptable uiInfo, IUndoableOperation operation,
        int doing) {
    // Nothing to report if we are running automated tests.  We will treat
    // warnings as if they were authorized by the user.
    if (AUTOMATED_MODE) {
        if (status.getSeverity() == IStatus.WARNING) {
            return Status.OK_STATUS;
        }/*from  www . j av a2s .c om*/
        return status;
    }

    // CANCEL status is assumed to be initiated by the user, so there
    // is nothing to report.
    if (status.getSeverity() == IStatus.CANCEL) {
        return status;
    }

    // Other status severities are reported with a message dialog.
    // First obtain a shell and set up the dialog title.
    boolean createdShell = false;
    IStatus reportedStatus = status;

    Shell shell = getShell(uiInfo);
    if (shell == null) {
        createdShell = true;
        shell = new Shell();
    }

    // Set up the dialog. For non-error statuses, we use a warning dialog
    // that allows the user to proceed or to cancel out of the operation.

    if (!(status.getSeverity() == IStatus.ERROR)) {
        String warning, title;
        switch (doing) {
        case UNDOING:
            warning = WorkbenchMessages.Operations_proceedWithNonOKUndoStatus;
            if (status.getSeverity() == IStatus.INFO) {
                title = WorkbenchMessages.Operations_undoInfo;
            } else {
                title = WorkbenchMessages.Operations_undoWarning;
            }
            break;
        case REDOING:
            warning = WorkbenchMessages.Operations_proceedWithNonOKRedoStatus;
            if (status.getSeverity() == IStatus.INFO) {
                title = WorkbenchMessages.Operations_redoInfo;
            } else {
                title = WorkbenchMessages.Operations_redoWarning;
            }
            break;
        default: // EXECUTING
            warning = WorkbenchMessages.Operations_proceedWithNonOKExecuteStatus;
            if (status.getSeverity() == IStatus.INFO) {
                title = WorkbenchMessages.Operations_executeInfo;
            } else {
                title = WorkbenchMessages.Operations_executeWarning;
            }
            break;
        }

        String message = NLS.bind(warning, new Object[] { status.getMessage(), operation.getLabel() });
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
        MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING, buttons,
                0);
        int dialogAnswer = dialog.open();
        // The user has been given the specific status and has chosen
        // to proceed or to cancel. The user choice determines what
        // the status should be at this point, OK or CANCEL.
        if (dialogAnswer == Window.OK) {
            reportedStatus = Status.OK_STATUS;
        } else {
            reportedStatus = Status.CANCEL_STATUS;
        }
    } else {
        String title, stopped;
        switch (doing) {
        case UNDOING:
            title = WorkbenchMessages.Operations_undoProblem;
            stopped = WorkbenchMessages.Operations_stoppedOnUndoErrorStatus;
            break;
        case REDOING:
            title = WorkbenchMessages.Operations_redoProblem;
            stopped = WorkbenchMessages.Operations_stoppedOnRedoErrorStatus;
            break;
        default: // EXECUTING
            title = WorkbenchMessages.Operations_executeProblem;
            stopped = WorkbenchMessages.Operations_stoppedOnExecuteErrorStatus;

            break;
        }

        // It is an error condition. The user has no choice to proceed, so
        // we only report what has gone on. We use a warning icon instead of
        // an error icon since there has not yet been a failure.

        String message = NLS.bind(stopped, status.getMessage(), operation.getLabel());

        MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING,
                new String[] { IDialogConstants.OK_LABEL }, 0); // ok
        dialog.open();
    }

    if (createdShell) {
        shell.dispose();
    }

    return reportedStatus;

}

From source file:org.eclipse.ui.internal.SaveableHelper.java

License:Open Source License

/**
 * Saves the workbench part./*from  w ww  . ja  va 2s. c o m*/
 * 
 * @param saveable the part
 * @param part the same part
 * @param window the workbench window
 * @param confirm request confirmation
 * @return <code>true</code> for continue, <code>false</code> if the operation
 * was canceled.
 */
public static boolean savePart(final ISaveablePart saveable, IWorkbenchPart part, IWorkbenchWindow window,
        boolean confirm) {
    // Short circuit.
    if (!saveable.isDirty()) {
        return true;
    }

    // If confirmation is required ..
    if (confirm) {
        int choice = AutomatedResponse;
        if (choice == USER_RESPONSE) {
            if (saveable instanceof ISaveablePart2) {
                choice = ((ISaveablePart2) saveable).promptToSaveOnClose();
            }
            if (choice == USER_RESPONSE || choice == ISaveablePart2.DEFAULT) {
                String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, part.getTitle());
                // Show a dialog.
                String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                        IDialogConstants.CANCEL_LABEL };
                MessageDialog d = new MessageDialog(window.getShell(), WorkbenchMessages.Save_Resource, null,
                        message, MessageDialog.QUESTION, buttons, 0) {
                    protected int getShellStyle() {
                        return super.getShellStyle() | SWT.SHEET;
                    }
                };
                choice = d.open();
            }
        }

        // Branch on the user choice.
        // The choice id is based on the order of button labels above.
        switch (choice) {
        case ISaveablePart2.YES: //yes
            break;
        case ISaveablePart2.NO: //no
            return true;
        default:
        case ISaveablePart2.CANCEL: //cancel
            return false;
        }
    }

    if (saveable instanceof ISaveablesSource) {
        return saveModels((ISaveablesSource) saveable, window, confirm);
    }

    // Create save block.
    IRunnableWithProgress progressOp = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            IProgressMonitor monitorWrap = new EventLoopProgressMonitor(monitor);
            saveable.doSave(monitorWrap);
        }
    };

    // Do the save.
    return runProgressMonitorOperation(WorkbenchMessages.Save, progressOp, window);
}

From source file:org.eclipse.ui.internal.SaveablesList.java

License:Open Source License

/**
 * Prompt the user to save the given saveables.
 * @param modelsToSave the saveables to be saved
 * @param shellProvider the provider used to obtain a shell in prompting is
 *            required. Clients can use a workbench window for this.
 * @param runnableContext a runnable context that will be used to provide a
 *            progress monitor while the save is taking place. Clients can
 *            use a workbench window for this.
 * @param canCancel whether the operation can be canceled
 * @param stillOpenElsewhere whether the models are referenced by open parts
 * @return true if the user canceled//from w ww.ja  va  2s  . co  m
 */
public boolean promptForSaving(List modelsToSave, final IShellProvider shellProvider,
        IRunnableContext runnableContext, final boolean canCancel, boolean stillOpenElsewhere) {
    // Save parts, exit the method if cancel is pressed.
    if (modelsToSave.size() > 0) {
        boolean canceled = SaveableHelper.waitForBackgroundSaveJobs(modelsToSave);
        if (canceled) {
            return true;
        }

        IPreferenceStore apiPreferenceStore = PrefUtil.getAPIPreferenceStore();
        boolean dontPrompt = stillOpenElsewhere && !apiPreferenceStore
                .getBoolean(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN);

        if (dontPrompt) {
            modelsToSave.clear();
            return false;
        } else if (modelsToSave.size() == 1) {
            Saveable model = (Saveable) modelsToSave.get(0);
            // Show a dialog.
            String[] buttons;
            if (canCancel) {
                buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                        IDialogConstants.CANCEL_LABEL };
            } else {
                buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
            }

            // don't save if we don't prompt
            int choice = ISaveablePart2.NO;

            MessageDialog dialog;
            if (stillOpenElsewhere) {
                String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesOptionallyQuestion,
                        model.getName());
                MessageDialogWithToggle dialogWithToggle = new MessageDialogWithToggle(shellProvider.getShell(),
                        WorkbenchMessages.Save_Resource, null, message, MessageDialog.QUESTION, buttons, 0,
                        WorkbenchMessages.EditorManager_closeWithoutPromptingOption, false) {
                    protected int getShellStyle() {
                        return (canCancel ? SWT.CLOSE : SWT.NONE) | SWT.TITLE | SWT.BORDER
                                | SWT.APPLICATION_MODAL | SWT.SHEET | getDefaultOrientation();
                    }
                };
                dialog = dialogWithToggle;
            } else {
                String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, model.getName());
                dialog = new MessageDialog(shellProvider.getShell(), WorkbenchMessages.Save_Resource, null,
                        message, MessageDialog.QUESTION, buttons, 0) {
                    protected int getShellStyle() {
                        return (canCancel ? SWT.CLOSE : SWT.NONE) | SWT.TITLE | SWT.BORDER
                                | SWT.APPLICATION_MODAL | SWT.SHEET | getDefaultOrientation();
                    }
                };
            }

            choice = SaveableHelper.testGetAutomatedResponse();
            if (SaveableHelper.testGetAutomatedResponse() == SaveableHelper.USER_RESPONSE) {
                choice = dialog.open();

                if (stillOpenElsewhere) {
                    // map value of choice back to ISaveablePart2 values
                    switch (choice) {
                    case IDialogConstants.YES_ID:
                        choice = ISaveablePart2.YES;
                        break;
                    case IDialogConstants.NO_ID:
                        choice = ISaveablePart2.NO;
                        break;
                    case IDialogConstants.CANCEL_ID:
                        choice = ISaveablePart2.CANCEL;
                        break;
                    default:
                        break;
                    }
                    MessageDialogWithToggle dialogWithToggle = (MessageDialogWithToggle) dialog;
                    if (choice != ISaveablePart2.CANCEL && dialogWithToggle.getToggleState()) {
                        apiPreferenceStore
                                .setValue(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN, false);
                    }
                }
            }

            // Branch on the user choice.
            // The choice id is based on the order of button labels
            // above.
            switch (choice) {
            case ISaveablePart2.YES: // yes
                break;
            case ISaveablePart2.NO: // no
                modelsToSave.clear();
                break;
            default:
            case ISaveablePart2.CANCEL: // cancel
                return true;
            }
        } else {
            MyListSelectionDialog dlg = new MyListSelectionDialog(shellProvider.getShell(), modelsToSave,
                    new ArrayContentProvider(), new WorkbenchPartLabelProvider(),
                    stillOpenElsewhere ? WorkbenchMessages.EditorManager_saveResourcesOptionallyMessage
                            : WorkbenchMessages.EditorManager_saveResourcesMessage,
                    canCancel, stillOpenElsewhere);
            dlg.setInitialSelections(modelsToSave.toArray());
            dlg.setTitle(WorkbenchMessages.EditorManager_saveResourcesTitle);

            // this "if" statement aids in testing.
            if (SaveableHelper.testGetAutomatedResponse() == SaveableHelper.USER_RESPONSE) {
                int result = dlg.open();
                // Just return null to prevent the operation continuing
                if (result == IDialogConstants.CANCEL_ID)
                    return true;

                if (dlg.getDontPromptSelection()) {
                    apiPreferenceStore.setValue(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN,
                            false);
                }

                modelsToSave = Arrays.asList(dlg.getResult());
            }
        }
    }
    // Create save block.
    return saveModels(modelsToSave, shellProvider, runnableContext);
}