Class PlainMessageDialog

All Implemented Interfaces:
IShellProvider

public class PlainMessageDialog extends IconAndMessageDialog
The PlainMessageDialog represents a message dialog with a clear, simple API to create dialogs with message, buttons and image.

Instances of this class can be created using the PlainMessageDialog.Builder. An instance of the builder can be retrieved by calling the static method getBuilder(Shell, String)

This class has to be favored over MessageDialog, which has an evolved, non-clear API.

Since:
3.23
  • Method Details

    • getBuilder

      public static PlainMessageDialog.Builder getBuilder(Shell shell, String dialogTitle)
      Creates a new Builder instance.
      Parameters:
      shell - the parent shell
      dialogTitle - the shell title
      Returns:
      the builder
    • buttonPressed

      protected void buttonPressed(int buttonId)
      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 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.

      Overrides:
      buttonPressed in class Dialog
      Parameters:
      buttonId - the id of the button that was pressed (see IDialogConstants.*_ID constants)
    • configureShell

      protected void configureShell(Shell shell)
      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 class Window
      Parameters:
      shell - the shell
    • createButtonsForButtonBar

      protected void createButtonsForButtonBar(Composite parent)
      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 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.

      Overrides:
      createButtonsForButtonBar in class Dialog
      Parameters:
      parent - the button bar composite
    • createCustomArea

      protected Control createCustomArea(Composite parent)
      Creates and returns the contents of an area of the dialog which appears below the message and above the button bar.

      The default implementation of this framework method returns null. Subclasses may override.

      Parameters:
      parent - parent composite to contain the custom area
      Returns:
      the custom area control, or null
    • 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
      Parameters:
      parent - the parent composite to contain the dialog area
      Returns:
      the dialog area control
    • handleShellCloseEvent

      protected void handleShellCloseEvent()
      Handle the shell close. Set the return code to SWT.DEFAULT as there has been no explicit close by the user.
      Overrides:
      handleShellCloseEvent in class Window
      See Also:
    • open

      public int open(int style)
      Open
      Parameters:
      style - SWT.NONE for a default dialog, or SWT.SHEET for a dialog with sheet behavior
      Returns:
      true if the user presses the OK or Yes button, false otherwise
      Since:
      3.23
    • createButton

      protected Button createButton(Composite parent, int id, String label, boolean defaultButton)
      Description copied from class: Dialog
      Creates a new button with the given id.

      The Dialog implementation of this framework method creates a standard push button, registers it for selection events including button presses, and registers default buttons with its shell. The button id is stored as the button's client data. If the button id is IDialogConstants.CANCEL_ID, the new button will be accessible from getCancelButton(). If the button id is IDialogConstants.OK_ID, the new button will be accesible from getOKButton(). Note that the parent's layout is assumed to be a GridLayout and the number of columns in this layout is incremented. 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:
      createButton in class Dialog
      Parameters:
      parent - the parent composite
      id - the id of the button (see IDialogConstants.*_ID constants for standard dialog button ids)
      label - the label from the button
      defaultButton - true if the button is to be the default button, and false otherwise
      Returns:
      the new button
      See Also:
    • getImage

      protected Image getImage()
      Description copied from class: IconAndMessageDialog
      Returns the image to display beside the message in this dialog.

      Subclasses may override.

      Specified by:
      getImage in class IconAndMessageDialog
      Returns:
      the image to display beside the message