Class PatternFilter
java.lang.Object
org.eclipse.jface.viewers.ViewerFilter
org.eclipse.e4.ui.dialogs.filteredtree.PatternFilter
Based on org.eclipse.ui.dialogs.PatternFilter.
- Since:
- 1.2
-
Constructor Summary
ConstructorDescriptionPatternFilter
(boolean includeLeadingWildcard) Constructor to specify the includeLeadingWildcard flag. -
Method Summary
Modifier and TypeMethodDescriptionfinal Object[]
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 criteria.Methods inherited from class org.eclipse.jface.viewers.ViewerFilter
filter, isFilterProperty
-
Constructor Details
-
PatternFilter
public PatternFilter() -
PatternFilter
public PatternFilter(boolean includeLeadingWildcard) Constructor to specify the includeLeadingWildcard flag.- Parameters:
includeLeadingWildcard
- flag- Since:
- 1.1.0
-
-
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. -
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.- 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 criteria.- Parameters:
text
- the text to match- Returns:
- boolean
true
if one of the words in text satisfies the match criteria.
-