public class PopupDialog extends Window
Because the dialog is short-lived, most of the configuration of the dialog is done in the constructor. Set methods are only provided for those values that are expected to be dynamically computed based on a particular instance's internal state.
Clients are expected to override the creation of the main dialog area, and may optionally override the creation of the title area and info area in order to add content. In general, however, the creation of stylistic features, such as the dialog menu, separator styles, and fonts, is kept private so that all popup dialogs will have a similar appearance.
Window.IExceptionHandler
Modifier and Type | Field and Description |
---|---|
static int |
HOVER_SHELLSTYLE
Shell style appropriate for a simple hover popup that cannot get focus.
|
static int |
INFOPOPUP_SHELLSTYLE
Shell style appropriate for an info popup that can get focus.
|
static int |
INFOPOPUPRESIZE_SHELLSTYLE
Shell style appropriate for a resizable info popup that can get focus.
|
static int |
POPUP_HORIZONTALSPACING
Vertical spacing (in pixels) between cells in the layouts inside popup
dialogs (value is 1).
|
static String |
POPUP_IMG_MENU
Image registry key for menu image.
|
static String |
POPUP_IMG_MENU_DISABLED
Image registry key for disabled menu image.
|
static int |
POPUP_MARGINHEIGHT
Margin height (in pixels) to be used in layouts inside popup dialogs
(value is 0).
|
static int |
POPUP_MARGINWIDTH
Margin width (in pixels) to be used in layouts inside popup dialogs
(value is 0).
|
static int |
POPUP_VERTICALSPACING
Vertical spacing (in pixels) between cells in the layouts inside popup
dialogs (value is 1).
|
CANCEL, OK, resizeHasOccurred
Constructor and Description |
---|
PopupDialog(Shell parent,
int shellStyle,
boolean takeFocusOnOpen,
boolean persistSize,
boolean persistLocation,
boolean showDialogMenu,
boolean showPersistActions,
String titleText,
String infoText)
Constructs a new instance of
PopupDialog . |
PopupDialog(Shell parent,
int shellStyle,
boolean takeFocusOnOpen,
boolean persistBounds,
boolean showDialogMenu,
boolean showPersistActions,
String titleText,
String infoText)
Deprecated.
As of 3.4, replaced by
PopupDialog(Shell, int, boolean, boolean, boolean, boolean, boolean, String, String) |
Modifier and Type | Method and Description |
---|---|
protected void |
adjustBounds()
Adjust the bounds of the popup as necessary prior to opening the dialog.
|
protected void |
applyBackgroundColor(Color color,
Control control)
Set the specified background color for the specified control and all of
its children.
|
protected void |
applyForegroundColor(Color color,
Control control)
Set the specified foreground color for the specified control and all of
its children.
|
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 Control |
createContents(Composite parent)
The
PopupDialog implementation of this Window
method creates and lays out the top level composite for the dialog. |
protected Control |
createDialogArea(Composite parent)
Creates and returns the contents of the dialog (the area below the title
area and above the info text area.
|
protected Control |
createInfoTextArea(Composite parent)
Creates the optional info text area.
|
protected Control |
createTitleControl(Composite parent)
Creates the control to be used to represent the dialog's title text.
|
protected Control |
createTitleMenuArea(Composite parent)
Creates the title and menu area.
|
protected void |
fillDialogMenu(IMenuManager dialogMenu)
Fill the dialog's menu.
|
protected Color |
getBackground()
Get the background color that should be used for this popup.
|
protected List<Control> |
getBackgroundColorExclusions()
Return a list of controls which should never have their background color
reset.
|
protected Point |
getDefaultLocation(Point initialSize)
Returns the default location to use for the shell.
|
protected Point |
getDefaultSize()
Return the default size to use for the shell.
|
protected IDialogSettings |
getDialogSettings()
Gets the dialog settings that should be used for remembering the bounds
of the dialog.
|
protected Control |
getFocusControl()
Returns the control that should get initial focus.
|
protected Color |
getForeground()
Get the foreground color that should be used for this popup.
|
protected List<Control> |
getForegroundColorExclusions()
Return a list of controls which should never have their foreground color
reset.
|
protected Point |
getInitialLocation(Point initialSize)
Returns the initial location to use for the shell.
|
protected Point |
getInitialSize()
Returns the initial size to use for the shell.
|
protected boolean |
getPersistBounds()
Deprecated.
As of 3.4, please use
getPersistLocation() or
getPersistSize() to determine separately whether size or
location should be persisted. |
protected boolean |
getPersistLocation()
Return a boolean indicating whether this dialog will persist its
location.
|
protected boolean |
getPersistSize()
Return a boolean indicating whether this dialog will persist its size.
|
protected boolean |
hasInfoArea()
Returns a boolean indicating whether the popup should have an info area
at the bottom of the dialog.
|
protected boolean |
hasTitleArea()
Returns a boolean indicating whether the popup should have a title area
at the top of the dialog.
|
int |
open()
Opens this window, creating it first if it has not yet been created.
|
protected void |
saveDialogBounds(Shell shell)
Saves the bounds of the shell in the appropriate dialog settings.
|
protected void |
setInfoText(String text)
Set the text to be shown in the popup's info area.
|
protected void |
setTabOrder(Composite composite)
Sets the tab order for the popup.
|
protected void |
setTitleText(String text)
Set the text to be shown in the popup's title area.
|
protected void |
showDialogMenu()
Show the dialog's menu.
|
canHandleShellCloseEvent, constrainShellSize, create, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, initializeBounds, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
public static final int HOVER_SHELLSTYLE
public static final int INFOPOPUP_SHELLSTYLE
public static final int INFOPOPUPRESIZE_SHELLSTYLE
public static final int POPUP_MARGINWIDTH
public static final int POPUP_MARGINHEIGHT
public static final int POPUP_VERTICALSPACING
public static final int POPUP_HORIZONTALSPACING
public static final String POPUP_IMG_MENU
public static final String POPUP_IMG_MENU_DISABLED
@Deprecated public PopupDialog(Shell parent, int shellStyle, boolean takeFocusOnOpen, boolean persistBounds, boolean showDialogMenu, boolean showPersistActions, String titleText, String infoText)
PopupDialog(Shell, int, boolean, boolean, boolean, boolean, boolean, String, String)
PopupDialog
.parent
- The parent shell.shellStyle
- The shell style.takeFocusOnOpen
- A boolean indicating whether focus should be
taken by this popup when it opens.persistBounds
- A boolean indicating whether the bounds (size
and location) of the dialog should be persisted
upon close of the dialog. The bounds can only
be persisted if the dialog settings for
persisting the bounds are also specified. If a
menu action will be provided that allows the
user to control this feature, then the last
known value of the user's setting will be used
instead of this flag.showDialogMenu
- A boolean indicating whether a menu for moving
and resizing the popup should be provided.showPersistActions
- A boolean indicating whether actions allowing
the user to control the persisting of the
dialog size and location should be shown in the
dialog menu. This parameter has no effect if
showDialogMenu
is
false
.titleText
- Text to be shown in an upper title area, or
null
if there is no title.infoText
- Text to be shown in a lower info area, or
null
if there is no info area.getDialogSettings()
public PopupDialog(Shell parent, int shellStyle, boolean takeFocusOnOpen, boolean persistSize, boolean persistLocation, boolean showDialogMenu, boolean showPersistActions, String titleText, String infoText)
PopupDialog
.parent
- The parent shell.shellStyle
- The shell style.takeFocusOnOpen
- A boolean indicating whether focus should be taken by this
popup when it opens.persistSize
- A boolean indicating whether the size should be persisted upon
close of the dialog. The size can only be persisted if the
dialog settings for persisting the bounds are also specified.
If a menu action will be provided that allows the user to
control this feature and the user hasn't changed that setting,
then this flag is used as initial default for the menu.persistLocation
- A boolean indicating whether the location should be persisted
upon close of the dialog. The location can only be persisted
if the dialog settings for persisting the bounds are also
specified. If a menu action will be provided that allows the
user to control this feature and the user hasn't changed that
setting, then this flag is used as initial default for the
menu. default for the menu until the user changed it.showDialogMenu
- A boolean indicating whether a menu for moving and resizing
the popup should be provided.showPersistActions
- A boolean indicating whether actions allowing the user to
control the persisting of the dialog bounds and location
should be shown in the dialog menu. This parameter has no
effect if showDialogMenu
is false
.titleText
- Text to be shown in an upper title area, or null
if there is no title.infoText
- Text to be shown in a lower info area, or null
if there is no info area.getDialogSettings()
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 Control createContents(Composite parent)
PopupDialog
implementation of this Window
method creates and lays out the top level composite for the dialog. It
then calls the createTitleMenuArea
,
createDialogArea
, and createInfoTextArea
methods to create an optional title and menu area on the top, a dialog
area in the center, and an optional info text area at the bottom.
Overriding createDialogArea
and (optionally)
createTitleMenuArea
and createTitleMenuArea
are recommended rather than overriding this method.createContents
in class Window
parent
- the composite used to parent the contents.protected Control createDialogArea(Composite parent)
The PopupDialog
implementation of this framework method
creates and returns a new Composite
with standard margins
and spacing.
The returned control's layout data must be an instance of
GridData
. This method must not modify the parent's
layout.
Subclasses must override this method but may call super
as
in the following example:
Composite composite = (Composite) super.createDialogArea(parent); //add controls to composite as necessary return composite;
parent
- the parent composite to contain the dialog areaprotected Control getFocusControl()
protected void setTabOrder(Composite composite)
composite
- the composite in which all content, including the title area
and info area, was created. This composite's parent is the
shell.protected boolean hasTitleArea()
true
if a title area should be created,
false
if it should not.protected boolean hasInfoArea()
true
if a title area should be created,
false
if it should not.protected Control createTitleMenuArea(Composite parent)
showDialogMenu
and showPersistAction
to
indicate whether a menu should be shown, and
createTitleControl
to to customize the presentation of the
title.
If this method is overridden, the returned control's layout data must be
an instance of GridData
. This method must not modify the
parent's layout.
parent
- The parent composite.protected Control createTitleControl(Composite parent)
If this method is overridden, the returned control's layout data must be
an instance of GridData
. This method must not modify the
parent's layout.
parent
- The parent composite.protected Control createInfoTextArea(Composite parent)
hasInfoArea()
method returns true. Subclasses typically
need not override this method, but may do so.
If this method is overridden, the returned control's layout data must be
an instance of GridData
. This method must not modify the
parent's layout.
parent
- The parent composite.hasInfoArea()
,
createTitleControl(Composite)
protected void fillDialogMenu(IMenuManager dialogMenu)
dialogMenu
- The dialog's menu.protected void showDialogMenu()
protected void setInfoText(String text)
text
- the text to be shown when the info area is displayed.protected void setTitleText(String text)
text
- the text to be shown when the title area is displayed.@Deprecated protected boolean getPersistBounds()
getPersistLocation()
or
getPersistSize()
to determine separately whether size or
location should be persisted.true
if the dialog's bounds will be persisted,
false
if it will not.protected boolean getPersistLocation()
true
if the dialog's location will be persisted,
false
if it will not.getPersistSize()
protected boolean getPersistSize()
true
if the dialog's size will be persisted,
false
if it will not.getPersistLocation()
public int open()
This method is reimplemented for special configuration of PopupDialogs.
It never blocks on open, immediately returning OK
if the
open is successful, or CANCEL
if it is not. It provides
framework hooks that allow subclasses to set the focus and tab order, and
avoids the use of shell.open()
in cases where the focus
should not be given to the shell initially.
open
in class Window
Window.open()
public boolean close()
This method is extended to save the dialog bounds and initialize widget
state so that the widgets can be recreated if the dialog is reopened.
This method may be extended (super.close
must be called).
protected IDialogSettings getDialogSettings()
null
if the dialog's bounds should
never be stored.protected void saveDialogBounds(Shell shell)
super.saveDialogBounds
if additional bounds information
should be stored. Clients may also call this method to persist the bounds
at times other than closing the dialog.shell
- The shell whose bounds are to be storedprotected Point getInitialSize()
Window
Shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true)
.getInitialSize
in class Window
protected Point getDefaultSize()
getInitialSize()
.getPersistSize()
protected Point getDefaultLocation(Point initialSize)
Window.getInitialLocation(Point)
.
Subclasses should override this method when an alternate default location
is desired, rather than overriding getInitialLocation(Point)
.initialSize
- the initial size of the shell, as returned by
getInitialSize
.getPersistLocation()
protected void adjustBounds()
protected Point getInitialLocation(Point initialSize)
Window
getInitialLocation
in class Window
initialSize
- the initial size of the shell, as returned by
getInitialSize
.protected Color getForeground()
null
.getForegroundColorExclusions()
protected Color getBackground()
null
.getBackgroundColorExclusions()
protected void applyForegroundColor(Color color, Control control)
getForegroundColorExclusions()
.color
- the color to use as the foreground colorcontrol
- the control whose color is to be changedgetForegroundColorExclusions()
protected void applyBackgroundColor(Color color, Control control)
getBackgroundColorExclusions()
color
- the color to use as the background colorcontrol
- the control whose color is to be changedgetBackgroundColorExclusions()
protected List<Control> getForegroundColorExclusions()
super.getForegroundColorExclusions
to aggregate the list.protected List<Control> getBackgroundColorExclusions()
super.getBackgroundColorExclusions
to aggregate the list.
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.