Package org.eclipse.ui.dialogs
Class FilteredList
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.ui.dialogs.FilteredList
- All Implemented Interfaces:
Drawable
A composite widget which holds a list of elements for user selection. The
elements are sorted alphabetically. Optionally, the elements can be filtered
and duplicate entries can be hidden (folding).
- Since:
- 2.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
The FilterMatcher is the interface used to check filtering criterea. -
Field Summary
Fields inherited from class org.eclipse.swt.widgets.Widget
nativeZoom
-
Constructor Summary
ConstructorDescriptionFilteredList
(Composite parent, int style, ILabelProvider labelProvider, boolean ignoreCase, boolean allowDuplicates, boolean matchEmptyString) Constructs a new filtered list. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSelectionListener
(SelectionListener listener) Adds a selection listener to the list.Returns the accessible object for the receiver.boolean
Returns whether or not duplicates are allowed.Returns the filter pattern.Object[]
getFoldedElements
(int index) Returns all elements which are folded together to one entry in the list.boolean
Returns whether or not case should be ignored.Returns the label provider for the items.boolean
Returns whether empty filter strings should filter everything or nothing.Object[]
Returns an array of the selected elements.int
Returns the selection of the list.int[]
Returns the selection of the list.boolean
isEmpty()
Tests if the list (before folding and filtering) is empty.void
removeSelectionListener
(SelectionListener listener) Removes a selection listener from the list.void
setAllowDuplicates
(boolean allowDuplicates) Sets whether or not duplicates are allowed.void
setComparator
(Comparator comparator) Sets a custom comparator for sorting the list.void
setElements
(Object[] elements) Sets the list of elements.void
Sets the filter pattern.void
setFilterMatcher
(FilteredList.FilterMatcher filterMatcher) Sets the filter matcher.void
setIgnoreCase
(boolean ignoreCase) Sets whether or not case should be ignored If this value is set the items should be set again for this value to take effect.void
setLabelProvider
(ILabelProvider labelProvider) Sets the label provider.void
setMatchEmptyString
(boolean matchEmptyString) Sets whether empty filter strings should filter everything or nothing.void
setSelection
(int[] selection) Sets the selection of the list.void
setSelection
(Object[] elements) Sets the selection of the list.Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, setScrollbarsMode
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, addTypedListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, removeTypedListener, reskin, setData, setData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.swt.graphics.Drawable
isAutoScalable
-
Constructor Details
-
FilteredList
public FilteredList(Composite parent, int style, ILabelProvider labelProvider, boolean ignoreCase, boolean allowDuplicates, boolean matchEmptyString) Constructs a new filtered list.- Parameters:
parent
- the parent compositestyle
- the widget stylelabelProvider
- the label rendererignoreCase
- specifies whether sorting and folding is case sensitiveallowDuplicates
- specifies whether folding of duplicates is desiredmatchEmptyString
- specifies whether empty filter strings should filter everything or nothing
-
-
Method Details
-
setElements
Sets the list of elements.- Parameters:
elements
- the elements to be shown in the list.
-
isEmpty
public boolean isEmpty()Tests if the list (before folding and filtering) is empty.- Returns:
- returns
true
if the list is empty,false
otherwise.
-
setFilterMatcher
Sets the filter matcher.- Parameters:
filterMatcher
- theFilteredList.FilterMatcher
to set.
-
setComparator
Sets a custom comparator for sorting the list.- Parameters:
comparator
- theComparator
to set.
-
addSelectionListener
Adds a selection listener to the list.- Parameters:
listener
- the selection listener to be added.
-
removeSelectionListener
Removes a selection listener from the list.- Parameters:
listener
- the selection listener to be removed.
-
setSelection
public void setSelection(int[] selection) Sets the selection of the list. Empty or null array removes selection.- Parameters:
selection
- an array of indices specifying the selection.
-
getSelectionIndices
public int[] getSelectionIndices()Returns the selection of the list.- Returns:
- returns an array of indices specifying the current selection.
-
getSelectionIndex
public int getSelectionIndex()Returns the selection of the list. This is a convenience function forgetSelectionIndices()
.- Returns:
- returns the index of the selection, -1 for no selection.
-
setSelection
Sets the selection of the list. Empty or null array removes selection.- Parameters:
elements
- the array of elements to be selected.
-
getSelection
Returns an array of the selected elements. The type of the elements returned in the list are the same as the ones passed withsetElements
. The array does not contain the rendered strings.- Returns:
- returns the array of selected elements.
-
setFilter
Sets the filter pattern. Current only prefix filter patterns are supported.- Parameters:
filter
- the filter pattern.
-
getFilter
Returns the filter pattern.- Returns:
- returns the filter pattern.
-
getFoldedElements
Returns all elements which are folded together to one entry in the list.- Parameters:
index
- the index selecting the entry in the list.- Returns:
- returns an array of elements folded together,
null
if index is out of range.
-
getAllowDuplicates
public boolean getAllowDuplicates()Returns whether or not duplicates are allowed.- Returns:
true
indicates duplicates are allowed
-
setAllowDuplicates
public void setAllowDuplicates(boolean allowDuplicates) Sets whether or not duplicates are allowed. If this value is set the items should be set again for this value to take effect.- Parameters:
allowDuplicates
-true
indicates duplicates are allowed
-
getIgnoreCase
public boolean getIgnoreCase()Returns whether or not case should be ignored.- Returns:
true
if case should be ignored
-
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase) Sets whether or not case should be ignored If this value is set the items should be set again for this value to take effect.- Parameters:
ignoreCase
-true
if case should be ignored
-
getMatchEmptyString
public boolean getMatchEmptyString()Returns whether empty filter strings should filter everything or nothing.- Returns:
true
for the empty string to match all items,false
to match none
-
setMatchEmptyString
public void setMatchEmptyString(boolean matchEmptyString) Sets whether empty filter strings should filter everything or nothing. If this value is set the items should be set again for this value to take effect.- Parameters:
matchEmptyString
-true
for the empty string to match all items,false
to match none
-
getLabelProvider
Returns the label provider for the items.- Returns:
- the label provider
-
setLabelProvider
Sets the label provider. If this value is set the items should be set again for this value to take effect.- Parameters:
labelProvider
- the label provider
-
getAccessible
Returns the accessible object for the receiver. If this is the first time this object is requested, then the object is created and returned.- Overrides:
getAccessible
in classControl
- Returns:
- the accessible object
- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- Since:
- 3.3
- See Also:
-