|
Eclipse Platform Release 3.3 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.window.Window
org.eclipse.jface.dialogs.PopupDialog
A lightweight, transient dialog that is popped up to show contextual or temporal information and is easily dismissed. Clients control whether the dialog should be able to receive input focus. An optional title area at the top and an optional info area at the bottom can be used to provide additional information.
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.
Nested Class Summary |
---|
Nested classes inherited from class org.eclipse.jface.window.Window |
---|
Window.IExceptionHandler |
Field Summary | |
---|---|
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 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). |
Fields inherited from class org.eclipse.jface.window.Window |
---|
CANCEL, OK |
Constructor Summary | |
---|---|
PopupDialog(Shell parent,
int shellStyle,
boolean takeFocusOnOpen,
boolean persistBounds,
boolean showDialogMenu,
boolean showPersistAction,
String titleText,
String infoText)
Constructs a new instance of PopupDialog . |
Method Summary | |
---|---|
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 List |
getBackgroundColorExclusions()
Return a list of controls which should never have their background color reset. |
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 List |
getForegroundColorExclusions()
Return a list of controls which should never have their foreground color reset. |
protected Point |
getInitialLocation(Point initialSize)
(non-Javadoc) |
protected Point |
getInitialSize()
Returns the initial size to use for the shell. |
protected boolean |
getPersistBounds()
Return a boolean indicating whether this dialog will persist its bounds. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
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
Constructor Detail |
public PopupDialog(Shell parent, int shellStyle, boolean takeFocusOnOpen, boolean persistBounds, boolean showDialogMenu, boolean showPersistAction, 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.persistBounds
- A boolean indicating whether the bounds 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.showPersistAction
- A boolean indicating whether an action allowing the user to
control the persisting of the dialog bounds 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()
Method Detail |
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 area
protected 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.protected boolean getPersistBounds()
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).
close
in class Window
true
if the window is (or was already) closed, and
false
if it is still openprotected 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 void adjustBounds()
protected Point getInitialLocation(Point initialSize)
getInitialLocation
in class Window
initialSize
- the initial size of the shell, as returned by
getInitialSize
.
Window.getInitialLocation(org.eclipse.swt.graphics.Point)
protected void applyForegroundColor(Color color, Control control)
PopupDialog.getForegroundColorExclusions
.
color
- the color to use as the background colorcontrol
- the control whose color is to be changedgetBackgroundColorExclusions()
protected void applyBackgroundColor(Color color, Control control)
PopupDialog.getBackgroundColorExclusions
.
color
- the color to use as the background colorcontrol
- the control whose color is to be changedgetBackgroundColorExclusions()
protected List getForegroundColorExclusions()
super.getForegroundColorExclusions
to aggregate the list.
protected List getBackgroundColorExclusions()
super.getBackgroundColorExclusions
to aggregate the list.
|
Eclipse Platform Release 3.3 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.