Package org.eclipse.ui.dialogs
Class PatternFilter
java.lang.Object
org.eclipse.jface.viewers.ViewerFilter
org.eclipse.ui.dialogs.PatternFilter
A filter used in conjunction with
FilteredTree
. In order to
determine if a node should be filtered it uses the content and label provider
of the tree to do pattern matching on its children. This causes the entire
tree structure to be realized. Note that the label provider must implement
ILabelProvider.- Since:
- 3.2
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionObject[]
Filters the given elements for the given viewer.boolean
isElementSelectable
(Object element) Answers whether the given element is a valid selection in the filtered tree.boolean
isElementVisible
(Viewer viewer, Object element) Answers whether the given element in the given viewer matches the filter pattern.protected boolean
isLeafMatch
(Viewer viewer, Object element) Check if the current (leaf) element is a match with the filter text.protected boolean
isParentMatch
(Viewer viewer, Object element) Check if the parent (category) is a match to the filter text.final boolean
Returns whether the given element makes it through this filter.final void
setIncludeLeadingWildcard
(boolean includeLeadingWildcard) Sets whether a leading wildcard should be attached to each pattern string.void
setPattern
(String patternString) The pattern string for which this filter should select elements in the viewer.protected boolean
wordMatches
(String text) Return whether or not if any of the words in text satisfy the match critera.Methods inherited from class org.eclipse.jface.viewers.ViewerFilter
filter, isFilterProperty
-
Constructor Details
-
PatternFilter
public PatternFilter()
-
-
Method Details
-
filter
Description copied from class:ViewerFilter
Filters the given elements for the given viewer. The input array is not modified.The default implementation of this method calls
select
on each element in the array, and returns only those elements for whichselect
returnstrue
.- Overrides:
filter
in classViewerFilter
- Parameters:
viewer
- the viewerparent
- the parent elementelements
- the elements to filter- Returns:
- the filtered elements
-
select
Description copied from class:ViewerFilter
Returns whether the given element makes it through this filter.- Specified by:
select
in classViewerFilter
- Parameters:
viewer
- the viewerparentElement
- the parent elementelement
- the element- Returns:
true
if element is included in the filtered set, andfalse
if excluded
-
setIncludeLeadingWildcard
public final void setIncludeLeadingWildcard(boolean includeLeadingWildcard) Sets whether a leading wildcard should be attached to each pattern string.- Parameters:
includeLeadingWildcard
- Whether a leading wildcard should be added.
-
setPattern
The pattern string for which this filter should select elements in the viewer.- Parameters:
patternString
- the pattern string.
-
isElementSelectable
Answers whether the given element is a valid selection in the filtered tree. For example, if a tree has items that are categorized, the category itself may not be a valid selection since it is used merely to organize the elements.- Parameters:
element
- the element to check- Returns:
- true if this element is eligible for automatic selection
-
isElementVisible
Answers whether the given element in the given viewer matches the filter pattern. This is a default implementation that will show a leaf element in the tree based on whether the provided filter text matches the text of the given element's text, or that of it's children (if the element has any). Subclasses may override this method.- Parameters:
viewer
- the tree viewer in which the element resideselement
- the element in the tree to check for a match- Returns:
- true if the element matches the filter pattern
-
isParentMatch
Check if the parent (category) is a match to the filter text. The default behavior returns true if the element has at least one child element that is a match with the filter text. Subclasses may override this method.- Parameters:
viewer
- the viewer that contains the elementelement
- the tree element to check- Returns:
- true if the given element has children that matches the filter text
-
isLeafMatch
Check if the current (leaf) element is a match with the filter text. The default behavior checks that the label of the element is a match. Subclasses should override this method.- Parameters:
viewer
- the viewer that contains the elementelement
- the tree element to check- Returns:
- true if the given element's label matches the filter text
-
wordMatches
Return whether or not if any of the words in text satisfy the match critera.- Parameters:
text
- the text to match- Returns:
- boolean
true
if one of the words in text satisifes the match criteria.
-