Class AbstractSelectionDialog<T>
- Type Parameters:
T- which declares the type of the elements in theAbstractSelectionDialog.
- All Implemented Interfaces:
IShellProvider
setInitialSelection), and returns the final
selection (via getResult) after completion.
Clients may subclass this dialog to inherit its selection facilities.
- Since:
- 3.11
-
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, ELLIPSISFields inherited from class org.eclipse.jface.window.Window
CANCEL, OK, resizeHasOccurred -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSelectionDialog(Shell parentShell) Creates a dialog instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureShell(Shell shell) Configures the given shell in preparation for opening this window in it.protected LabelcreateMessageArea(Composite composite) Creates the message area for this dialog.protected IDialogSettingsGets the dialog settings that should be used for remembering the bounds of of the dialog, according to the dialog bounds strategy.protected intGet the integer constant that describes the strategy for persisting the dialog bounds.Returns anjava.util.Optional<T>containing the first element from the collection of selections made by the user.Returns the collection of initial element selections.protected StringReturns the message for this dialog.Returns the collection of selections made by the user.protected booleanReturns a boolean indicating whether the dialog should be considered resizable when the shell style is initially set.voidsetDialogBoundsSettings(IDialogSettings settings, int strategy) Set the dialog settings that should be used to save the bounds of this dialog.voidsetInitialSelection(Collection<T> selectedElements) Sets the initial selection in this selection dialog to the given elements.voidsetInitialSelection(T... selectedElements) Sets the initial selection in this selection dialog to the given elements.voidsetMessage(String message) Sets the message for this dialog.protected voidsetResult(Collection<T> newUserSelection) Set the selections made by the user.protected voidsetResult(ISelection selection, Class<T> target) Set the selections obtained from a viewer.protected voidSet the selections made by the user.voidSets the title for this dialog.Methods inherited from class org.eclipse.jface.dialogs.TrayDialog
closeTray, createButtonBar, createHelpControl, getLayout, getTray, handleShellCloseEvent, isDialogHelpAvailable, isHelpAvailable, openTray, setDialogHelpAvailable, setHelpAvailableMethods 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, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, okPressed, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenTextMethods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, 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 Details
-
AbstractSelectionDialog
Creates a dialog instance.- Parameters:
parentShell- the parent shell
-
-
Method Details
-
configureShell
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
-
createMessageArea
Creates the message area for this dialog.This method is provided to allow subclasses to decide where the message will appear on the screen.
- Parameters:
composite- the parent composite- Returns:
- the message label
-
getInitialSelection
Returns the collection of initial element selections.- Returns:
- Collection
-
getMessage
Returns the message for this dialog.- Returns:
- the message for this dialog
-
getResult
Returns the collection of selections made by the user.- Returns:
- the collection of selected elements, or
Collections.emptyList()if no result was set
-
getFirstResult
Returns anjava.util.Optional<T>containing the first element from the collection of selections made by the user. ReturnsOptional.empty()if no element has been selected.- Returns:
- an
java.util.Optional<T>containing the first result element if one exists. OtherwiseOptional.empty()is returned. - Since:
- 3.16
-
setInitialSelection
Sets the initial selection in this selection dialog to the given elements.- Parameters:
selectedElements- the elements to select
-
setInitialSelection
Sets the initial selection in this selection dialog to the given elements.- Parameters:
selectedElements- the List of elements to select
-
setMessage
Sets the message for this dialog.- Parameters:
message- the message
-
setResult
Set the selections made by the user.The result may be accessed using
getResult.- Parameters:
newUserSelection- collection of selected elements
-
setResult
Set the selections made by the user.The result may be accessed using
getResult.- Parameters:
newUserSelection- - the new values
-
setResult
Set the selections obtained from a viewer.- Parameters:
selection- selection obtained from a viewertarget- target type to check forinstanceof- Since:
- 3.16
-
setTitle
Sets the title for this dialog.- Parameters:
title- the title
-
setDialogBoundsSettings
Set the dialog settings that should be used to save the bounds of this dialog. This method is provided so that clients that directly use SelectionDialogs without subclassing them may specify how the bounds of the dialog are to be saved.- Parameters:
settings- theIDialogSettingsthat should be used to store the bounds of the dialogstrategy- the integer constant specifying how the bounds are saved. Specified usingDialog.DIALOG_PERSISTLOCATIONandDialog.DIALOG_PERSISTSIZE.- Since:
- 3.2
- See Also:
-
getDialogBoundsSettings
Description copied from class:DialogGets the dialog settings that should be used for remembering the bounds of of the dialog, according to the dialog bounds strategy.- Overrides:
getDialogBoundsSettingsin classDialog- Returns:
- settings the dialog settings used to store the dialog's location
and/or size, or
nullif the dialog's bounds should never be stored. - See Also:
-
getDialogBoundsStrategy
protected int getDialogBoundsStrategy()Description copied from class:DialogGet the integer constant that describes the strategy for persisting the dialog bounds. This strategy is ignored if the implementer does not also specify the dialog settings for storing the bounds in Dialog.getDialogBoundsSettings().- Overrides:
getDialogBoundsStrategyin classDialog- Returns:
- the constant describing the strategy for persisting the dialog bounds.
- See Also:
-
isResizable
protected boolean isResizable()Description copied from class:DialogReturns a boolean indicating whether the dialog should be considered resizable when the shell style is initially set.This method is used to ensure that all style bits appropriate for resizable dialogs are added to the shell style. Individual dialogs may always set the shell style to ensure that a dialog is resizable, but using this method ensures that resizable dialogs will be created with the same set of style bits.
Style bits will never be removed based on the return value of this method. For example, if a dialog returns
false, but also sets a style bit for a SWT.RESIZE border, the style bit will be honored.- Overrides:
isResizablein classDialog- Returns:
- a boolean indicating whether the dialog is resizable and should have the default style bits for resizable dialogs
-