public class SaveConfirmation extends MessageDialog
Helper that asks the user to save unsaved editors.
Clients can add filters to ask only for selected editors.Window.IExceptionHandler
CONFIRM, ERROR, INFORMATION, NONE, QUESTION, QUESTION_WITH_CANCEL, WARNING
imageLabel, message, messageLabel
blockedHandler, buttonBar, DIALOG_DEFAULT_BOUNDS, DIALOG_PERSISTLOCATION, DIALOG_PERSISTSIZE, dialogArea, DLG_IMG_ERROR, DLG_IMG_HELP, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS
Constructor and Description |
---|
SaveConfirmation(Shell parentShell,
String dialogMessage)
Creates a new save confirmation.
|
Modifier and Type | Method and Description |
---|---|
SaveConfirmation |
addFilter(com.google.common.base.Predicate<IEditorReference> filter)
Adds a filter that decides whether a specific editor reference should be
handled by this dialog or not.
|
boolean |
ask()
Asks the user whether the editors are to be saved.
|
protected void |
buttonPressed(int buttonId) |
protected Control |
createCustomArea(Composite parent) |
configureShell, createButton, createButtonsForButtonBar, createDialogArea, customShouldTakeFocus, getButton, getButtonLabels, getDefaultButtonIndex, getImage, getMinimumMessageWidth, handleShellCloseEvent, open, open, openConfirm, openError, openInformation, openQuestion, openWarning, setButtonLabels, setButtons
createButtonBar, createContents, createDialogAndButtonArea, createMessageArea, getErrorImage, getInfoImage, getMessageLabelStyle, getQuestionImage, getWarningImage
applyDialogFont, cancelPressed, close, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, dialogFontIsDefault, getBlockedHandler, getButtonBar, getCancelButton, getDialogArea, getDialogBoundsSettings, getDialogBoundsStrategy, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, isResizable, okPressed, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
public SaveConfirmation addFilter(com.google.common.base.Predicate<IEditorReference> filter)
protected Control createCustomArea(Composite parent)
createCustomArea
in class MessageDialog
protected void buttonPressed(int buttonId)
buttonPressed
in class MessageDialog
public boolean ask()
This method first calculates which editors are to be handled by the
dialog by retrieving all open editors that are
dirty and pass the
filters. When this list is empty, no
dialog is shown and true
is returned.
Otherwise, we present the user a checkable list of editors to be saved.
The user can either cancel the operation—in this case ask()
returns false
. Or the user can select to continue, in this
case the method saves all editors from which the user has not removed the
check mark in the dialog and returns true
.
true
to continue, false
to cancel. Note
that a return value of true
does not
guarantee that all dirty editors have been saved.Copyright © 2013 TextGrid. All Rights Reserved.