Class ExceptionDetailsErrorDialog

All Implemented Interfaces:
IShellProvider

public class ExceptionDetailsErrorDialog extends IconAndMessageDialog
A dialog to display one or more errors to the user, as contained in an 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.

Taken from http://rubenlaguna.com/wp/2007/07/25/eclipse-error-reporting-exception-stacktrace-details/ and modified.

  • Field Details

    • AUTOMATED_MODE

      public static boolean AUTOMATED_MODE
      Static to prevent opening of error dialogs for automated testing.
  • Constructor Details

    • ExceptionDetailsErrorDialog

      public ExceptionDetailsErrorDialog(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.

      Parameters:
      parentShell - the shell under which to create this dialog
      dialogTitle - the title to use for this dialog, or null to indicate that the default title should be used
      message - the message to show in this dialog, or null to indicate that the error's message should be shown as the primary message
      status - the error to show to the user
      displayMask - the mask to use to filter the displaying of child items, as per IStatus.matches
  • Method Details

    • isResizable

      protected boolean isResizable()
      Allow resize
      Overrides:
      isResizable in class Dialog
    • buttonPressed

      protected void buttonPressed(int id)
      Overrides:
      buttonPressed in class Dialog
    • configureShell

      protected void configureShell(Shell shell)
      Overrides:
      configureShell in class Window
    • createButtonsForButtonBar

      protected void createButtonsForButtonBar(Composite parent)
      Overrides:
      createButtonsForButtonBar in class Dialog
    • createDetailsButton

      protected void createDetailsButton(Composite parent)
      Create the details button if it should be included.
    • createDialogArea

      protected Control createDialogArea(Composite parent)
      This implementation of the Dialog framework method creates and lays out a composite and calls createMessageArea and createCustomArea to populate it. Subclasses should override createCustomArea to add contents below the message.
      Overrides:
      createDialogArea in class Dialog
    • createDialogAndButtonArea

      protected void createDialogAndButtonArea(Composite parent)
      Overrides:
      createDialogAndButtonArea in class IconAndMessageDialog
    • getImage

      protected Image getImage()
      Specified by:
      getImage in class IconAndMessageDialog
    • createDropDownList

      protected Text createDropDownList(Composite parent)
      Create this dialog's drop-down list component.
      Parameters:
      parent - the parent composite
      Returns:
      the drop-down list component
    • open

      public int open()
      Extends 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.
      Overrides:
      open in class Window
    • openError

      public static int openError(Shell parent, String dialogTitle, String message, IStatus status)
      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, or null if none
      dialogTitle - the title to use for this dialog, or null to indicate that the default title should be used
      message - the message to show in this dialog, or null to indicate that the error's message should be shown as the primary message
      status - 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, or Dialog.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, or null if none
      title - the title to use for this dialog, or null to indicate that the default title should be used
      message - the message to show in this dialog, or null to indicate that the error's message should be shown as the primary message
      status - the error to show to the user
      displayMask - the mask to use to filter the displaying of child items, as per IStatus.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, or Dialog.CANCEL if this dialog's close window decoration or the ESC key was used.
    • shouldDisplay

      protected static boolean shouldDisplay(IStatus status, int mask)
      Returns whether the given status object should be displayed.
      Parameters:
      status - a status object
      mask - a mask as per IStatus.matches
      Returns:
      true if the given status should be displayed, and false otherwise
    • close

      public boolean close()
      Overrides:
      close in class Dialog
    • showDetailsArea

      protected 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 the 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.
    • shouldShowDetailsButton

      protected boolean shouldShowDetailsButton()
      Return whether the Details button should be included. This method is invoked once when the dialog is built. By default, the Details button is only included if the status used when creating the dialog was a multi-status or if the status contains an exception. Subclasses may override.
    • setStatus

      protected void setStatus(IStatus status)
      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
    • openError

      public static int openError(Shell shell, String title, Exception ex)
    • openError

      public static int openError(Shell shell, String title, String message, Exception ex)