Class PlainMessageDialog
- java.lang.Object
-
- org.eclipse.jface.window.Window
-
- org.eclipse.jface.dialogs.Dialog
-
- org.eclipse.jface.dialogs.IconAndMessageDialog
-
- org.eclipse.jface.dialogs.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 methodgetBuilder(Shell, String)This class has to be favored over
MessageDialog, which has an evolved, non-clear API.- Since:
- 3.23
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlainMessageDialog.BuilderThe Builder to create PlainMessageDialog instances.-
Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
-
-
Field Summary
-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuttonPressed(int buttonId)Notifies that this dialog's button with the given id has been pressed.protected voidconfigureShell(Shell shell)Configures the given shell in preparation for opening this window in it.protected ButtoncreateButton(Composite parent, int id, String label, boolean defaultButton)Creates a new button with the given id.protected voidcreateButtonsForButtonBar(Composite parent)Adds buttons to this dialog's button bar.protected ControlcreateCustomArea(Composite parent)Creates and returns the contents of an area of the dialog which appears below the message and above the button bar.protected ControlcreateDialogArea(Composite parent)This implementation of theDialogframework method creates and lays out a composite and callscreateMessageAreaandcreateCustomAreato populate it.static PlainMessageDialog.BuildergetBuilder(Shell shell, String dialogTitle)Creates a new Builder instance.protected ImagegetImage()Returns the image to display beside the message in this dialog.protected voidhandleShellCloseEvent()Handle the shell close.intopen(int style)Open-
Methods inherited from class org.eclipse.jface.dialogs.IconAndMessageDialog
createButtonBar, createContents, createDialogAndButtonArea, createMessageArea, getColumnCount, getErrorImage, getInfoImage, getMessageLabelStyle, getQuestionImage, getWarningImage
-
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, cancelPressed, close, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getDialogBoundsSettings, getDialogBoundsStrategy, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, isResizable, 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, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
-
-
-
-
Method Detail
-
getBuilder
public static PlainMessageDialog.Builder getBuilder(Shell shell, String dialogTitle)
Creates a new Builder instance.- Parameters:
shell- the parent shelldialogTitle- the shell title- Returns:
- the builder
-
buttonPressed
protected void buttonPressed(int buttonId)
Description copied from class:DialogNotifies that this dialog's button with the given id has been pressed.The
Dialogimplementation of this framework method callsokPressedif the ok button is the pressed, andcancelPressedif the cancel button is the pressed. All other button presses are ignored. Subclasses may override to handle other buttons, but should callsuper.buttonPressedif the default handling of the ok and cancel buttons is desired.- Overrides:
buttonPressedin classDialog- Parameters:
buttonId- the id of the button that was pressed (seeIDialogConstants.*_IDconstants)
-
configureShell
protected void configureShell(Shell shell)
Description copied from class:WindowConfigures 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:
configureShellin classWindow- Parameters:
shell- the shell
-
createButtonsForButtonBar
protected void createButtonsForButtonBar(Composite parent)
Description copied from class:DialogAdds buttons to this dialog's button bar.The
Dialogimplementation of this framework method adds standard ok and cancel buttons using thecreateButtonframework 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:
createButtonsForButtonBarin classDialog- 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 theDialogframework method creates and lays out a composite and callscreateMessageAreaandcreateCustomAreato populate it. Subclasses should overridecreateCustomAreato add contents below the message.- Overrides:
createDialogAreain classDialog- 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 toSWT.DEFAULTas there has been no explicit close by the user.- Overrides:
handleShellCloseEventin classWindow- See Also:
Window.handleShellCloseEvent()
-
open
public int open(int style)
Open
-
createButton
protected Button createButton(Composite parent, int id, String label, boolean defaultButton)
Description copied from class:DialogCreates a new button with the given id.The
Dialogimplementation 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 isIDialogConstants.CANCEL_ID, the new button will be accessible fromgetCancelButton(). If the button id isIDialogConstants.OK_ID, the new button will be accesible fromgetOKButton(). Note that the parent's layout is assumed to be aGridLayoutand 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:
createButtonin classDialog- Parameters:
parent- the parent compositeid- the id of the button (seeIDialogConstants.*_IDconstants for standard dialog button ids)label- the label from the buttondefaultButton-trueif the button is to be the default button, andfalseotherwise- Returns:
- the new button
- See Also:
Dialog.getCancelButton(),Dialog.getOKButton()
-
getImage
protected Image getImage()
Description copied from class:IconAndMessageDialogReturns the image to display beside the message in this dialog.Subclasses may override.
- Specified by:
getImagein classIconAndMessageDialog- Returns:
- the image to display beside the message
-
-