Class ErrorDialog
- All Implemented Interfaces:
IShellProvider
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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
Static to prevent opening of error dialogs for automated testing.Fields inherited from class org.eclipse.jface.dialogs.IconAndMessageDialog
imageLabel, message, messageLabel
Fields inherited from class org.eclipse.jface.dialogs.Dialog
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
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK, resizeHasOccurred
-
Constructor Summary
ConstructorDescriptionErrorDialog
(Shell parentShell, String dialogTitle, String message, IStatus status, int displayMask) Creates an error dialog. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 theDialog
framework method creates and lays out a composite.protected List
createDropDownList
(Composite parent) Create this dialog's drop-down list component.protected int
Get the number of columns in the layout of the Shell of the dialog.protected Image
getImage()
Returns the image to display beside the message in this dialog.protected boolean
Returns a boolean indicating whether the dialog should be considered resizable when the shell style is initially set.int
open()
ExtendsWindow.open()
.static int
Opens an error dialog to display the given error.static int
Opens an error dialog to display the given error.protected final void
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
Return whether the Details button should be included.protected final void
Show the details portion of the dialog if it is not already visible.Methods inherited from class org.eclipse.jface.dialogs.IconAndMessageDialog
createButtonBar, createContents, createMessageArea, getErrorImage, getInfoImage, getMessageLabelStyle, getQuestionImage, getWarningImage
Methods inherited from class org.eclipse.jface.dialogs.Dialog
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
Methods inherited from class org.eclipse.jface.window.Window
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
-
Field Details
-
AUTOMATED_MODE
public static boolean AUTOMATED_MODEStatic to prevent opening of error dialogs for automated testing.
-
-
Constructor Details
-
ErrorDialog
public ErrorDialog(Shell parentShell, String dialogTitle, String message, IStatus status, int displayMask) Creates an error dialog. Note that the dialog will have no visual representation (no widgets) until it is told to open.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 and you need to specify a mask which will be used 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.- Parameters:
parentShell
- the shell under which to create this dialogdialogTitle
- the title to use for this dialog, ornull
to indicate that the default title should be usedmessage
- the message to show in this dialog, ornull
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 perIStatus.matches
- See Also:
-
-
Method Details
-
buttonPressed
protected void buttonPressed(int id) Description copied from class:Dialog
Notifies that this dialog's button with the given id has been pressed.The
Dialog
implementation of this framework method callsokPressed
if the ok button is the pressed, andcancelPressed
if the cancel button is the pressed. All other button presses are ignored. Subclasses may override to handle other buttons, but should callsuper.buttonPressed
if the default handling of the ok and cancel buttons is desired.- Overrides:
buttonPressed
in classDialog
- Parameters:
id
- the id of the button that was pressed (seeIDialogConstants.*_ID
constants)
-
configureShell
Description copied from class:Window
Configures the given shell in preparation for opening this window in it.The default implementation of this framework method sets the shell's image and gives it a grid layout. Subclasses may extend or reimplement.
- Overrides:
configureShell
in classWindow
- Parameters:
shell
- the shell
-
createButtonsForButtonBar
Description copied from class:Dialog
Adds buttons to this dialog's button bar.The
Dialog
implementation of this framework method adds standard ok and cancel buttons using thecreateButton
framework method. These standard buttons will be accessible fromgetCancelButton
, andgetOKButton
. 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.- Overrides:
createButtonsForButtonBar
in classDialog
- Parameters:
parent
- the button bar composite
-
createDetailsButton
Create the details button if it should be included.- Parameters:
parent
- the parent composite- Since:
- 3.2
-
createDialogArea
This implementation of theDialog
framework method creates and lays out a composite. Subclasses that require a different dialog area may either override this method, or call thesuper
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.- Overrides:
createDialogArea
in classDialog
- Parameters:
parent
- the parent composite to contain the dialog area- Returns:
- the dialog area control
-
createDialogAndButtonArea
Description copied from class:IconAndMessageDialog
Create the dialog area and the button bar for the receiver.- Overrides:
createDialogAndButtonArea
in classIconAndMessageDialog
- Parameters:
parent
- the parent composite
-
getImage
Description copied from class:IconAndMessageDialog
Returns the image to display beside the message in this dialog.Subclasses may override.
- Specified by:
getImage
in classIconAndMessageDialog
- Returns:
- the image to display beside the message
-
createDropDownList
Create this dialog's drop-down list component. The list is displayed after the user presses details button. It is developer responsibility to display details button if and only if there is some content on drop down list. The visibility of the details button is controlled byshouldShowDetailsButton()
, which should also be overridden together with this method.- Parameters:
parent
- the parent composite- Returns:
- the drop-down list component
- See Also:
-
open
public int open()ExtendsWindow.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. -
openError
Opens an error dialog to display the given error. Use this method if the error object being displayed does not contain child items, or if you wish to display all such items without filtering.- Parameters:
parent
- the parent shell of the dialog, ornull
if nonedialogTitle
- the title to use for this dialog, ornull
to indicate that the default title should be usedmessage
- the message to show in this dialog, ornull
to indicate that the error's message should be shown as the primary messagestatus
- the error to show to the user- Returns:
- the code of the button that was pressed that resulted in this
dialog closing. This will be
Dialog.OK
if the OK button was pressed, orDialog.CANCEL
if this dialog's close window decoration or the ESC key was used.
-
openError
public static int openError(Shell parentShell, String title, String message, IStatus status, int displayMask) Opens an error dialog to display the given error. Use this method if the error object being displayed contains child items and you wish to specify a mask which will be used 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.- Parameters:
parentShell
- the parent shell of the dialog, ornull
if nonetitle
- the title to use for this dialog, ornull
to indicate that the default title should be usedmessage
- the message to show in this dialog, ornull
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 perIStatus.matches
- Returns:
- the code of the button that was pressed that resulted in this dialog
closing. This will be
Dialog.OK
if the OK button was pressed, orDialog.CANCEL
if this dialog's close window decoration or the ESC key was used. - See Also:
-
shouldDisplay
Returns whether the given status object should be displayed.- Parameters:
status
- a status objectmask
- a mask as perIStatus.matches
- Returns:
true
if the given status should be displayed, andfalse
otherwise- See Also:
-
close
public boolean close()Description copied from class:Window
Closes this window, disposes its shell, and removes this window from its window manager (if it has one).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 resultShellListener
s will not receive ashellClosed
event. -
showDetailsArea
protected final void showDetailsArea()Show the details portion of the dialog if it is not already visible. This method will only work when it is invoked after the control of the dialog has been set. In other words, after thecreateContents
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.- Since:
- 3.1
-
shouldShowDetailsButton
protected boolean shouldShowDetailsButton()Return whether the Details button should be included. This method is invoked once when the dialog is built. Default implementation is tight to default implementation ofcreateDropDownList(Composite)
and displays details button if there is anything on the display list.- Returns:
- whether the Details button should be included
- Since:
- 3.1
- See Also:
-
setStatus
Set the status displayed by this error dialog to the given status. This only affects the status displayed by the Details list. The message, image and title should be updated by the subclass, if desired.- Parameters:
status
- the status to be displayed in the details list- Since:
- 3.1
-
getColumnCount
protected int getColumnCount()Description copied from class:IconAndMessageDialog
Get the number of columns in the layout of the Shell of the dialog.- Overrides:
getColumnCount
in classIconAndMessageDialog
- Returns:
- int
- Since:
- 3.22
-
isResizable
protected boolean isResizable()Description copied from class:Dialog
Returns a boolean indicating whether the dialog should be considered resizable when the shell style is initially set.This method is used to ensure that all style bits appropriate for resizable dialogs are added to the shell style. Individual dialogs may always set the shell style to ensure that a dialog is resizable, but using this method ensures that resizable dialogs will be created with the same set of style bits.
Style bits will never be removed based on the return value of this method. For example, if a dialog returns
false
, but also sets a style bit for a SWT.RESIZE border, the style bit will be honored.- Overrides:
isResizable
in classDialog
- Returns:
- a boolean indicating whether the dialog is resizable and should have the default style bits for resizable dialogs
-