Chapter 3. Text Filtering

Table of Contents

TextFilterList, TextFilterable and TextFilterator
Adding the TextFilterList and its filter widget
So What?

In part three of this tutorial we add a widget to filter the list of issues. This widget is a simple JTextField and is inspired by a similar widget found in Apple iTunes. As the user types text into the field, only rows that contain that text are shown. This is a fast and easy way to find a needle in a haystack!

TextFilterList, TextFilterable and TextFilterator

To add filtering to our issues browser, we first need to access the filter text for each list element. We can do this by implementing either the TextFilterable interface or the TextFilterator interface. TextFilterable requires the filtered objects to include the method getFilterStrings(). Alternatively, the Filterator interface can be used to externally specify filter strings. For our issues browser, we will implement TextFilterator for our Issue class.

import java.util.List;
// glazed lists
import ca.odell.glazedlists.TextFilterator;
// a simple issues library
import ca.odell.issuezilla.*;

 * Get the Strings to filter against for a given Issue.
 * @author <a href="">Jesse Wilson</a>
public class IssueTextFilterator implements TextFilterator {
  public void getFilterStrings(List baseList, Object element) {
    Issue issue = (Issue)element;