Eclipse Platform
Release 3.2

org.eclipse.ui.dialogs
Class PatternFilter

java.lang.Object
  extended byorg.eclipse.jface.viewers.ViewerFilter
      extended byorg.eclipse.ui.dialogs.PatternFilter

public class PatternFilter
extends ViewerFilter

A filter used in conjunction with FilteredTree. In order to determine if a node should be filtered it uses the content provider of the tree to do pattern matching on its children. This causes the entire tree structure to be realized. Note: this API is experimental and may change before 3.2 M5

Since:
3.2
See Also:
FilteredTree

Constructor Summary
PatternFilter()
           
 
Method Summary
 Object[] filter(Viewer viewer, Object parent, Object[] elements)
          Filters the given elements for the given viewer.
protected  boolean isElementMatch(Viewer viewer, Object element)
          Answers whether the given element in the given viewer matches the filter pattern.
protected  boolean isElementSelectable(Object element)
          Answers whether the given element is a valid selection in the filtered tree.
protected  boolean match(String string)
          Answers whether the given String matches the pattern.
 boolean select(Viewer viewer, Object parentElement, Object element)
          Returns whether the given element makes it through this filter.
 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.
 
Methods inherited from class org.eclipse.jface.viewers.ViewerFilter
filter, isFilterProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternFilter

public PatternFilter()
Method Detail

filter

public Object[] filter(Viewer viewer,
                       Object parent,
                       Object[] elements)
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 which select returns true.

Overrides:
filter in class ViewerFilter
Parameters:
viewer - the viewer
parent - the parent element
elements - the elements to filter
Returns:
the filtered elements

select

public boolean select(Viewer viewer,
                      Object parentElement,
                      Object element)
Description copied from class: ViewerFilter
Returns whether the given element makes it through this filter.

Specified by:
select in class ViewerFilter
Parameters:
viewer - the viewer
parentElement - the parent element
element - the element
Returns:
true if element is included in the filtered set, and false 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

public void setPattern(String patternString)
The pattern string for which this filter should select elements in the viewer.

Parameters:
patternString -

match

protected boolean match(String string)
Answers whether the given String matches the pattern.

Parameters:
string - the String to test
Returns:
whether the string matches the pattern

isElementSelectable

protected boolean isElementSelectable(Object element)
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 -
Returns:
true if this element is eligible for automatic selection

isElementMatch

protected boolean isElementMatch(Viewer viewer,
                                 Object element)
Answers whether the given element in the given viewer matches the filter pattern. This is a default implementation that will match any entry in the tree based on whether the provided filter text matches the text of the given element's text. Subclasses should override this method.

Parameters:
viewer - the tree viewer in which the element resides
element - the element in the tree to check for a match
Returns:
true if the element matches the filter pattern

Eclipse Platform
Release 3.2

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.