Class TrayDialog
- java.lang.Object
-
- org.eclipse.jface.window.Window
-
- org.eclipse.jface.dialogs.Dialog
-
- org.eclipse.jface.dialogs.TrayDialog
-
- All Implemented Interfaces:
IShellProvider
- Direct Known Subclasses:
AbstractSelectionDialog,org.eclipse.ui.views.markers.internal.DialogMarkerProperties,FormDialog,ImportTypeDialog,PreferenceDialog,SaveablePartDialog,SelectionDialog,StatusDialog,TitleAreaDialog
public abstract class TrayDialog extends Dialog
ATrayDialogis a specializedDialogthat can contain a tray on its side. The tray's content is provided as aDialogTray.It is recommended to subclass this class instead of
Dialogin all cases except where the dialog should never show a tray. For example, dialogs which are very short, simple, and quick to dismiss (e.g. a message dialog with an OK button) should subclassDialog.Note: Trays are not supported on dialogs that use a custom layout on the
Shellby overridingWindow#getLayout().- Since:
- 3.2
- See Also:
DialogTray,Window.getLayout()
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
-
-
Field Summary
-
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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTrayDialog(IShellProvider parentShell)Creates a tray dialog with the given parent.protectedTrayDialog(Shell shell)Creates a tray dialog instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseTray()Closes this dialog's tray, disposing its widgets.protected ControlcreateButtonBar(Composite parent)Creates and returns the contents of this dialog's button bar.protected ControlcreateHelpControl(Composite parent)Creates a new help control that provides access to context help.protected LayoutgetLayout()The tray dialog's default layout is a modified version of the defaultWindowlayout that can accomodate a tray, however it still conforms to the description of theWindowdefault layout.DialogTraygetTray()Returns the tray currently shown in the dialog, ornullif there is no tray.protected voidhandleShellCloseEvent()Notifies that the window's close button was pressed, the close menu was selected, or the ESCAPE key pressed.static booleanisDialogHelpAvailable()Tests if dialogs that have help control should show it all the time or only when explicitly requested for each dialog instance.booleanisHelpAvailable()Returns whether or not context help is available for this dialog.voidopenTray(DialogTray tray)Constructs the tray's widgets and displays the tray in this dialog.static voidsetDialogHelpAvailable(boolean helpAvailable)Sets whether JFace dialogs that support help control should show the control by default.voidsetHelpAvailable(boolean helpAvailable)Sets whether or not context help is available for this dialog.-
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, buttonPressed, cancelPressed, close, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButton, createButtonsForButtonBar, createContents, createDialogArea, 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, configureShell, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
-
-
-
-
Constructor Detail
-
TrayDialog
protected TrayDialog(Shell shell)
Creates a tray dialog instance. Note that the window will have no visual representation (no widgets) until it is told to open.- Parameters:
shell- the parent shell, ornullto create a top-level shell
-
TrayDialog
protected TrayDialog(IShellProvider parentShell)
Creates a tray dialog with the given parent.- Parameters:
parentShell- the object that returns the current parent shell
-
-
Method Detail
-
closeTray
public void closeTray() throws IllegalStateExceptionCloses this dialog's tray, disposing its widgets.- Throws:
IllegalStateException- if the tray was not open
-
handleShellCloseEvent
protected void handleShellCloseEvent()
Description copied from class:WindowNotifies that the window's close button was pressed, the close menu was selected, or the ESCAPE key pressed.The default implementation of this framework method sets the window's return code to
CANCELand closes the window usingclose. Subclasses may extend or reimplement.- Overrides:
handleShellCloseEventin classWindow
-
createButtonBar
protected Control createButtonBar(Composite parent)
Description copied from class:DialogCreates and returns the contents of this dialog's button bar.The
Dialogimplementation of this framework method lays out a button bar and calls thecreateButtonsForButtonBarframework method to populate it. Subclasses may override.The returned control's layout data must be an instance of
GridData.- Overrides:
createButtonBarin classDialog- Parameters:
parent- the parent composite to contain the button bar- Returns:
- the button bar control
-
createHelpControl
protected Control createHelpControl(Composite parent)
Creates a new help control that provides access to context help.The
TrayDialogimplementation of this method creates the control, registers it for selection events including selection, Note that the parent's layout is assumed to be aGridLayoutand the number of columns in this layout is incremented. Subclasses may override.- Parameters:
parent- the parent composite- Returns:
- the help control
-
isHelpAvailable
public boolean isHelpAvailable()
Returns whether or not context help is available for this dialog. This can affect whether or not the dialog will display additional help mechanisms such as a help control in the button bar.- Returns:
- whether or not context help is available for this dialog
-
getLayout
protected Layout getLayout()
The tray dialog's default layout is a modified version of the defaultWindowlayout that can accomodate a tray, however it still conforms to the description of theWindowdefault layout.Note: Trays may not be supported with all custom layouts on the dialog's Shell. To avoid problems, use a single outer
Compositefor your dialog area, and set your custom layout on thatComposite.- Overrides:
getLayoutin classWindow- Returns:
- a newly created layout or
nullfor no layout - See Also:
Window.getLayout()
-
getTray
public DialogTray getTray()
Returns the tray currently shown in the dialog, ornullif there is no tray.- Returns:
- the dialog's current tray, or
nullif there is none
-
openTray
public void openTray(DialogTray tray) throws IllegalStateException, UnsupportedOperationException
Constructs the tray's widgets and displays the tray in this dialog. The dialog's size will be adjusted to accommodate the tray.- Parameters:
tray- the tray to show in this dialog- Throws:
IllegalStateException- if the dialog already has a tray openUnsupportedOperationException- if the dialog does not support trays, for example if it uses a custom layout.
-
setHelpAvailable
public void setHelpAvailable(boolean helpAvailable)
Sets whether or not context help is available for this dialog. This can affect whether or not the dialog will display additional help mechanisms such as a help control in the button bar.- Parameters:
helpAvailable- whether or not context help is available for the dialog
-
isDialogHelpAvailable
public static boolean isDialogHelpAvailable()
Tests if dialogs that have help control should show it all the time or only when explicitly requested for each dialog instance.- Returns:
trueif dialogs that support help control should show it by default,falseotherwise.- Since:
- 3.2
-
setDialogHelpAvailable
public static void setDialogHelpAvailable(boolean helpAvailable)
Sets whether JFace dialogs that support help control should show the control by default. If set tofalse, help control can still be shown on a per-dialog basis.- Parameters:
helpAvailable-trueto show the help control,falseotherwise.- Since:
- 3.2
-
-