Previous Page
Next Page

5.1.4. Viewer filters

A viewer filter (see Figure 5-6 for the ViewerFilter hierarchy) is used to display a subset of the elements provided by the content provider (see Figure 5-1). If a view does not have a viewer filter, all the elements are displayed. A viewer filter is associated with a viewer using the setFilter() method.

Figure 5-6. ViewerFilter hierarchy.


Useful APIs defined by ViewFilter are listed next. Simple viewer filters need only to override the select(Viewer, Object, Object) method to determine whether an object should be visible in the viewer.

filter(Viewer, Object, Object[]) Filters the given elements for the given viewer. The default implementation of this method calls the following select(Viewer, Object, Object) method.

isFilterProperty(Object, String) Returns whether this viewer filter would be affected by a change to the given property of the given element. The default implementation of this method returns false.

select(Viewer, Object, Object) Returns whether the given element makes it through this filter.


Previous Page
Next Page