Class FilteredItemsSelectionDialog
- All Implemented Interfaces:
IShellProvider
- Direct Known Subclasses:
FilteredResourcesSelectionDialog
- Since:
- 3.3
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
An interface to content providers forFilterItemsSelectionDialog
.protected class
Filters elements using SearchPattern by comparing the names of items with the filter pattern.protected static class
History stores a list of key, object pairs.Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Pattern input field selection where caret is at the beginning (used only for initial pattern).static final int
Represents a full selection in the pattern input field (used only for initial pattern).static final int
Represents an empty selection in the pattern input field (used only for initial pattern).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
ConstructorDescriptionCreates a new instance of the class.FilteredItemsSelectionDialog
(Shell shell, boolean multi) Creates a new instance of the class. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
accessedHistoryItem
(Object item) Adds item to history.protected void
addListFilter
(ViewerFilter filter) Adds viewer filter to the dialog items list.protected void
Applies the filter created bycreateFilter()
method to the items list.boolean
close()
Closes this window, disposes its shell, and removes this window from its window manager (if it has one).protected void
Compute the result and return it.void
create()
Creates this window's widgetry in a new top-level shell.protected Control
createDialogArea
(Composite parent) Creates and returns the contents of the upper part of this dialog (above the button bar).protected abstract Control
createExtendedContentArea
(Composite parent) Creates an extra content area, which will be located above the details.protected abstract FilteredItemsSelectionDialog.ItemsFilter
Creates an instance of a filter.protected abstract void
fillContentProvider
(FilteredItemsSelectionDialog.AbstractContentProvider contentProvider, FilteredItemsSelectionDialog.ItemsFilter itemsFilter, IProgressMonitor progressMonitor) Fills the content provider with matching items.protected void
fillContextMenu
(IMenuManager menuManager) Hook that allows to add actions to the context menu.protected void
fillViewMenu
(IMenuManager menuManager) Fills the menu of the dialog.protected IDialogSettings
Gets the dialog settings that should be used for remembering the bounds of the dialog, according to the dialog bounds strategy.protected abstract IDialogSettings
Returns the dialog settings.abstract String
getElementName
(Object item) Returns name for then given object.protected String
Gets initial pattern.protected abstract Comparator
Returns comparator to sort items inside content provider.Get the control where the search pattern is entered.protected StructuredSelection
Returns the current selection.Returns the history of selected elements.protected void
This method is a hook for subclasses to override default dialog behavior.protected void
handleSelected
(StructuredSelection selection) Handle selection in the items list by updating labels of selected and unselected items and refresh the details field using the selection.boolean
isDuplicateElement
(Object item) Indicates whether the given item is a duplicate.boolean
isHistoryElement
(Object item) Indicates whether the given item is a history item.protected void
Notifies that the ok button of this dialog has been pressed.void
refresh()
Refreshes the dialog - has to be called in UI thread.void
reloadCache
(boolean checkDuplicates, IProgressMonitor monitor) Notifies the content provider - fires filtering of content provider elements.protected Object
removeHistoryItem
(Object item) Removes an item from history.protected void
restoreDialog
(IDialogSettings settings) Restores dialog using persisted settings.void
Schedules progress message refresh.void
Schedule refresh job.void
setDetailsLabelProvider
(ILabelProvider detailsLabelProvider) Sets label provider for the details field.void
setInitialPattern
(String text) Sets the initial pattern used by the filter.void
setInitialPattern
(String text, int selectionMode) Sets the initial pattern used by the filter.void
setListLabelProvider
(ILabelProvider listLabelProvider) Sets a new label provider for items in the list.void
setListSelectionLabelDecorator
(ILabelDecorator listSelectionLabelDecorator) Sets the label decorator for selected items in the list.protected void
setSelectionHistory
(FilteredItemsSelectionDialog.SelectionHistory selectionHistory) Sets new history.void
setSeparatorLabel
(String separatorLabel) Sets separator labelvoid
setStyledStringHighlighter
(IStyledStringHighlighter styledStringHighlighter) protected void
storeDialog
(IDialogSettings settings) Stores dialog settings.void
Deprecated.protected void
updateStatus
(IStatus status) Update the dialog's status line to reflect the given status.protected abstract IStatus
validateItem
(Object item) Validates the item.Methods inherited from class org.eclipse.ui.dialogs.SelectionStatusDialog
configureShell, createButtonBar, getFirstResult, setImage, setResult, setStatusLineAboveButtons, updateButtonsEnableState
Methods inherited from class org.eclipse.ui.dialogs.SelectionDialog
createButtonsForButtonBar, createMessageArea, getDialogBoundsStrategy, getInitialElementSelections, getInitialSelections, getMessage, getOkButton, getResult, isResizable, setDialogBoundsSettings, setInitialElementSelections, setInitialSelections, setMessage, setResult, setSelectionResult, setTitle
Methods inherited from class org.eclipse.jface.dialogs.TrayDialog
closeTray, createHelpControl, getLayout, getTray, handleShellCloseEvent, isDialogHelpAvailable, isHelpAvailable, openTray, setDialogHelpAvailable, setHelpAvailable
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, buttonPressed, cancelPressed, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, createButton, createContents, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
Methods 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
-
Field Details
-
NONE
public static final int NONERepresents an empty selection in the pattern input field (used only for initial pattern).- See Also:
-
CARET_BEGINNING
public static final int CARET_BEGINNINGPattern input field selection where caret is at the beginning (used only for initial pattern).- See Also:
-
FULL_SELECTION
public static final int FULL_SELECTIONRepresents a full selection in the pattern input field (used only for initial pattern).- See Also:
-
-
Constructor Details
-
FilteredItemsSelectionDialog
Creates a new instance of the class.- Parameters:
shell
- shell to parent the dialog onmulti
- indicates whether dialog allows to select more than one position in its list of items
-
FilteredItemsSelectionDialog
Creates a new instance of the class. Created dialog won't allow to select more than one item.- Parameters:
shell
- shell to parent the dialog on
-
-
Method Details
-
addListFilter
Adds viewer filter to the dialog items list.- Parameters:
filter
- the new filter
-
setListLabelProvider
Sets a new label provider for items in the list. If the label provider also implements.IStyledLabelProvider
, the style text labels provided by it will be used provided that the corresponding preference is set.- Parameters:
listLabelProvider
- the label provider for items in the list- See Also:
-
setListSelectionLabelDecorator
Sets the label decorator for selected items in the list.- Parameters:
listSelectionLabelDecorator
- the label decorator for selected items in the list
-
setDetailsLabelProvider
Sets label provider for the details field. For a single selection, the element sent toILabelProvider.getImage(Object)
andILabelProvider.getText(Object)
is the selected object, for multiple selection aString
with amount of selected items is the element.- Parameters:
detailsLabelProvider
- the label provider for the details field- See Also:
-
create
public void create()Description copied from class:Window
Creates this window's widgetry in a new top-level shell.The default implementation of this framework method creates this window's shell (by calling
createShell
), and its controls (by callingcreateContents
), then initializes this window's shell bounds (by callinginitializeBounds
).- Overrides:
create
in classSelectionStatusDialog
-
restoreDialog
Restores dialog using persisted settings. The default implementation restores the status of the details line and the selection history.- Parameters:
settings
- settings used to restore dialog
-
close
public boolean close()Description copied from class:Window
Closes this window, disposes its shell, and removes this window from its window manager (if it has one).This framework method may be extended (
super.close
must be called).Note that in order to prevent recursive calls to this method it does not call
Shell#close()
. As a resultShellListener
s will not receive ashellClosed
event. -
storeDialog
Stores dialog settings.- Parameters:
settings
- settings used to store dialog
-
fillViewMenu
Fills the menu of the dialog.- Parameters:
menuManager
- the menu manager
-
fillContextMenu
Hook that allows to add actions to the context menu.Subclasses may extend in order to add other actions.
- Parameters:
menuManager
- the context menu manager- Since:
- 3.5
-
createExtendedContentArea
Creates an extra content area, which will be located above the details.- Parameters:
parent
- parent to create the dialog widgets in- Returns:
- an extra content area
-
createDialogArea
Description copied from class:Dialog
Creates and returns the contents of the upper part of this dialog (above the button bar).The
Dialog
implementation of this framework method creates and returns a newComposite
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;
- Overrides:
createDialogArea
in classDialog
- Parameters:
parent
- the parent composite to contain the dialog area- Returns:
- the dialog area control
-
handleDoubleClick
protected void handleDoubleClick()This method is a hook for subclasses to override default dialog behavior. ThehandleDoubleClick()
method handles double clicks on the list of filtered elements.Current implementation makes double-clicking on the list do the same as pressing
OK
button on the dialog. -
handleSelected
Handle selection in the items list by updating labels of selected and unselected items and refresh the details field using the selection.- Parameters:
selection
- the new selection
-
getDialogBoundsSettings
Description copied from class:SelectionDialog
Gets the dialog settings that should be used for remembering the bounds of the dialog, according to the dialog bounds strategy. Overridden to provide the dialog settings that were set usingSelectionDialog.setDialogBoundsSettings(IDialogSettings, int)
.- Overrides:
getDialogBoundsSettings
in classSelectionDialog
- Returns:
- the dialog settings used to store the dialog's location and/or size,
or
null
if the dialog's bounds should not be stored. - See Also:
-
getDialogSettings
Returns the dialog settings. Returned object can't be null.- Returns:
- return dialog settings for this dialog
-
refresh
public void refresh()Refreshes the dialog - has to be called in UI thread. -
updateProgressLabel
Deprecated.Updates the progress label. -
reloadCache
Notifies the content provider - fires filtering of content provider elements. During the filtering, a separator between history and workspace matches is added.This is a long running operation and should be called in a job.
- Parameters:
checkDuplicates
-true
if data concerning elements duplication should be computed - it takes much more time than the standard filteringmonitor
- a progress monitor ornull
if no monitor is available
-
scheduleRefresh
public void scheduleRefresh()Schedule refresh job. -
scheduleProgressMessageRefresh
public void scheduleProgressMessageRefresh()Schedules progress message refresh. -
computeResult
protected void computeResult()Description copied from class:SelectionStatusDialog
Compute the result and return it.- Specified by:
computeResult
in classSelectionStatusDialog
-
updateStatus
Description copied from class:SelectionStatusDialog
Update the dialog's status line to reflect the given status. It is safe to call this method before the dialog has been opened.- Overrides:
updateStatus
in classSelectionStatusDialog
- Parameters:
status
- theIStatus
to use for updating the status line.
-
okPressed
protected void okPressed()Description copied from class:Dialog
Notifies that the ok button of this dialog has been pressed.The
Dialog
implementation of this framework method sets this dialog's return code toWindow.OK
and closes the dialog. Subclasses may override.- Overrides:
okPressed
in classSelectionStatusDialog
-
setInitialPattern
Sets the initial pattern used by the filter. This text is copied into the selection input on the dialog. A full selection is used in the pattern input field.- Parameters:
text
- initial pattern for the filter- See Also:
-
setInitialPattern
Sets the initial pattern used by the filter. This text is copied into the selection input on the dialog. TheselectionMode
is used to choose selection type for the input field.- Parameters:
text
- initial pattern for the filterselectionMode
- one of:NONE
,CARET_BEGINNING
,FULL_SELECTION
-
getInitialPattern
Gets initial pattern.- Returns:
- initial pattern, or
null
if initial pattern is not set
-
getSelectedItems
Returns the current selection.- Returns:
- the current selection
-
validateItem
Validates the item. When items on the items list are selected or deselected, it validates each item in the selection and the dialog status depends on all validations.- Parameters:
item
- an item to be checked- Returns:
- status of the dialog to be set
-
createFilter
Creates an instance of a filter.- Returns:
- a filter for items on the items list. Can be
null
, no filtering will be applied then, causing no item to be shown in the list.
-
applyFilter
protected void applyFilter()Applies the filter created bycreateFilter()
method to the items list. When new filter is different than previous one it will cause refiltering. -
getItemsComparator
Returns comparator to sort items inside content provider. Returned object will be probably created as an anonymous class. Parameters passed to thecompare(java.lang.Object, java.lang.Object)
are going to be the same type as the one used in the content provider.- Returns:
- comparator to sort items content provider
-
fillContentProvider
protected abstract void fillContentProvider(FilteredItemsSelectionDialog.AbstractContentProvider contentProvider, FilteredItemsSelectionDialog.ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException Fills the content provider with matching items.- Parameters:
contentProvider
- collector to add items to.FilteredItemsSelectionDialog.AbstractContentProvider.add(Object, FilteredItemsSelectionDialog.ItemsFilter)
only adds items that pass the givenitemsFilter
.itemsFilter
- the items filterprogressMonitor
- must be used to report search progress. The state of this progress monitor reflects the state of the filtering process.- Throws:
CoreException
- Something went wrong.
-
removeHistoryItem
Removes an item from history.- Parameters:
item
- an item to remove- Returns:
- removed item
-
accessedHistoryItem
Adds item to history.- Parameters:
item
- the item to be added
-
getSelectionHistory
Returns the history of selected elements.- Returns:
- history of selected elements, or
null
if it is not set
-
setSelectionHistory
Sets new history.- Parameters:
selectionHistory
- the history
-
isHistoryElement
Indicates whether the given item is a history item.- Parameters:
item
- the item to be investigated- Returns:
true
if the given item exists in history,false
otherwise
-
isDuplicateElement
Indicates whether the given item is a duplicate.- Parameters:
item
- the item to be investigated- Returns:
true
if the item is duplicate,false
otherwise
-
setSeparatorLabel
Sets separator label- Parameters:
separatorLabel
- the label showed on separator
-
getElementName
Returns name for then given object.- Parameters:
item
- an object from the content provider. Subclasses should pay attention to the passed argument. They should either only pass objects of a known type (one used in content provider) or make sure that passed parameter is the expected one (by type checking likeinstanceof
inside the method).- Returns:
- name of the given item
-
getPatternControl
Get the control where the search pattern is entered. Any filtering should be done using anFilteredItemsSelectionDialog.ItemsFilter
. This control should only be accessed for listeners that wish to handle events that do not affect filtering such as custom traversal.- Returns:
- Control or
null
if the pattern control has not been created.
-
getStyledStringHighlighter
- Returns:
- Returns the styledStringHighlighter.
- Since:
- 3.115
-
setStyledStringHighlighter
- Parameters:
styledStringHighlighter
- The styledStringHighlighter to set.- Since:
- 3.115
-