public class ErrorDialog extends IconAndMessageDialog
IStatus
object. If an error contains additional detailed
information then a Details button is automatically supplied, which shows or
hides an error details viewer when pressed by the user.
This dialog should be considered being a "local" way of error handling. It
cannot be changed or replaced by "global" error handling facility (
org.eclipse.ui.statushandler.StatusManager
). If product defines
its own way of handling errors, this error dialog may cause UI inconsistency,
so until it is absolutely necessary, StatusManager
should be
used.
IStatus
Window.IExceptionHandler
Modifier and Type | Field and Description |
---|---|
static boolean |
AUTOMATED_MODE
Static to prevent opening of error dialogs for automated testing.
|
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
CANCEL, OK, resizeHasOccurred
Constructor and Description |
---|
ErrorDialog(Shell parentShell,
String dialogTitle,
String message,
IStatus status,
int displayMask)
Creates an error dialog.
|
Modifier and Type | Method and Description |
---|---|
protected void |
buttonPressed(int id)
Notifies that this dialog's button with the given id has been pressed.
|
boolean |
close()
Closes this window, disposes its shell, and removes this window from its
window manager (if it has one).
|
protected void |
configureShell(Shell shell)
Configures the given shell in preparation for opening this window in it.
|
protected void |
createButtonsForButtonBar(Composite parent)
Adds buttons to this dialog's button bar.
|
protected void |
createDetailsButton(Composite parent)
Create the details button if it should be included.
|
protected void |
createDialogAndButtonArea(Composite parent)
Create the dialog area and the button bar for the receiver.
|
protected Control |
createDialogArea(Composite parent)
This implementation of the
Dialog framework method creates
and lays out a composite. |
protected List |
createDropDownList(Composite parent)
Create this dialog's drop-down list component.
|
protected Image |
getImage()
Returns the image to display beside the message in this dialog.
|
protected boolean |
isResizable()
Returns a boolean indicating whether the dialog should be
considered resizable when the shell style is initially
set.
|
int |
open()
Extends
Window.open() . |
static int |
openError(Shell parent,
String dialogTitle,
String message,
IStatus status)
Opens an error dialog to display the given error.
|
static int |
openError(Shell parentShell,
String title,
String message,
IStatus status,
int displayMask)
Opens an error dialog to display the given error.
|
protected void |
setStatus(IStatus status)
Set the status displayed by this error dialog to the given status.
|
protected static boolean |
shouldDisplay(IStatus status,
int mask)
Returns whether the given status object should be displayed.
|
protected boolean |
shouldShowDetailsButton()
Return whether the Details button should be included.
|
protected void |
showDetailsArea()
Show the details portion of the dialog if it is not already visible.
|
createButtonBar, createContents, createMessageArea, getErrorImage, getInfoImage, getMessageLabelStyle, getQuestionImage, getWarningImage
applyDialogFont, cancelPressed, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButton, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getDialogBoundsSettings, getDialogBoundsStrategy, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, okPressed, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
public static boolean AUTOMATED_MODE
public ErrorDialog(Shell parentShell, String dialogTitle, String message, IStatus status, int displayMask)
Normally one should use openError
to create and open one
of these. This constructor is useful only if the error object being
displayed contains child items
parentShell
- the shell under which to create this dialogdialogTitle
- the title to use for this dialog, or null
to
indicate that the default title should be usedmessage
- the message to show in this dialog, or null
to
indicate that the error's message should be shown as the
primary messagestatus
- the error to show to the userdisplayMask
- the mask to use to filter the displaying of child items, as
per IStatus.matches
IStatus.matches(int)
protected void buttonPressed(int id)
Dialog
The Dialog
implementation of this framework method calls
okPressed
if the ok button is the pressed, and
cancelPressed
if the cancel button is the pressed. All
other button presses are ignored. Subclasses may override to handle other
buttons, but should call super.buttonPressed
if the
default handling of the ok and cancel buttons is desired.
buttonPressed
in class Dialog
id
- the id of the button that was pressed (see
IDialogConstants.*_ID
constants)protected void configureShell(Shell shell)
Window
The default implementation of this framework method sets the shell's image and gives it a grid layout. Subclasses may extend or reimplement.
configureShell
in class Window
shell
- the shellprotected void createButtonsForButtonBar(Composite parent)
Dialog
The Dialog
implementation of this framework method adds
standard ok and cancel buttons using the createButton
framework method. These standard buttons will be accessible from
getCancelButton
, and getOKButton
.
Subclasses may override.
Note: The common button order is: {other buttons}, OK, Cancel.
On some platforms, Dialog.initializeBounds()
will move the default button to the right.
createButtonsForButtonBar
in class Dialog
parent
- the button bar compositeprotected void createDetailsButton(Composite parent)
parent
- the parent compositeprotected Control createDialogArea(Composite parent)
Dialog
framework method creates
and lays out a composite. Subclasses that require a different dialog area
may either override this method, or call the super
implementation and add controls to the created composite.
Note: Since 3.4, the created composite no longer grabs excess vertical space.
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=72489.
If the old behavior is desired by subclasses, get the returned composite's
layout data and set grabExcessVerticalSpace to true.createDialogArea
in class Dialog
parent
- the parent composite to contain the dialog areaprotected void createDialogAndButtonArea(Composite parent)
IconAndMessageDialog
createDialogAndButtonArea
in class IconAndMessageDialog
protected Image getImage()
IconAndMessageDialog
Subclasses may override.
getImage
in class IconAndMessageDialog
protected List createDropDownList(Composite parent)
shouldShowDetailsButton()
, which should also be overridden
together with this method.parent
- the parent compositeshouldShowDetailsButton()
public int open()
Window.open()
. Opens an error dialog to display
the error. If you specified a mask to filter the displaying of these
children, the error dialog will only be displayed if there is at least
one child status matching the mask.open
in class Window
Window.create()
public static int openError(Shell parent, String dialogTitle, String message, IStatus status)
parent
- the parent shell of the dialog, or null
if nonedialogTitle
- the title to use for this dialog, or null
to
indicate that the default title should be usedmessage
- the message to show in this dialog, or null
to
indicate that the error's message should be shown as the
primary messagestatus
- the error to show to the userDialog.OK
if the OK
button was pressed, or Dialog.CANCEL
if this
dialog's close window decoration or the ESC key was used.public static int openError(Shell parentShell, String title, String message, IStatus status, int displayMask)
parentShell
- the parent shell of the dialog, or null
if nonetitle
- the title to use for this dialog, or null
to
indicate that the default title should be usedmessage
- the message to show in this dialog, or null
to
indicate that the error's message should be shown as the
primary messagestatus
- the error to show to the userdisplayMask
- the mask to use to filter the displaying of child items, as
per IStatus.matches
Dialog.OK
if the OK
button was pressed, or Dialog.CANCEL
if this
dialog's close window decoration or the ESC key was used.IStatus.matches(int)
protected static boolean shouldDisplay(IStatus status, int mask)
status
- a status objectmask
- a mask as per IStatus.matches
true
if the given status should be displayed, and
false
otherwiseIStatus.matches(int)
public boolean close()
Window
This framework method may be extended (super.close
must
be called).
Note that in order to prevent recursive calls to this method
it does not call Shell#close()
. As a result ShellListener
s
will not receive a shellClosed
event.
close
in class Dialog
true
if the window is (or was already) closed, and
false
if it is still openWindow.close()
protected final void showDetailsArea()
createContents
method has been invoked and has returned the control for the content area
of the dialog. Invoking the method before the content area has been set
or after the dialog has been disposed will have no effect.protected boolean shouldShowDetailsButton()
createDropDownList(Composite)
and
displays details button if there is anything on the display list.createDropDownList(Composite)
protected final void setStatus(IStatus status)
status
- the status to be displayed in the details listprotected boolean isResizable()
Dialog
false
, but also sets a style bit for a
SWT.RESIZE border, the style bit will be honored.isResizable
in class Dialog
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.