Question

I looked up how to use multiple filters on here with a regular table and the answers all pointed to GlazedLists. However, the answers didn't specify how to use it. I was able to get one filter to work but do not know how to get more than one. For one filter I used:

  // nameE is a BasicEventList containing classes (name) which 
  // contain the table values
  TextFilterList filtered = new TextFilterList(nameE);
  JTextField filterEdit = filtered.getFilterEdit();

  // Inside the table value class (name) there is a filter for myName
  public void getFilterStrings(List baseList) {
      baseList.add(myName);
  }

Duplicating the code and creating another JTextField does not work. I looked this problem up and it appears CompositeMatcherEditor may work. The problem is I do not know how to implement this.

Also, I am using Eclipse. I downloaded GlazedLists 1.8.0 and dropped it into Eclipse. However, I can't use it. I have red squares all over (except for the source folder)! I even added the jar file.

I hope I have explained myself correctly. Please let me know if I need to expand.

My Pastebin: Name, Browser, TableFormat, TableModel

Was it helpful?

Solution

TextFilterList is deprecated - see the javadocs - but that's a side issue.

There are several approaches you can use here - if you want really simple, then just wrap your filter list in another filter list:

EventList filtered = new FilterList(new FilterList(nameE, myFirstMatcherEditor), mySecondMatcherEditor);

A better way is to use multiple matcher editors to create a CompositeMatcherEditor:

EventList filtered = new FilterList(nameE, new CompositeMatcherEditor(myFirstMatcherEditor, mySecondMatcherEditor));

you can use setMode to control whether your editors are combined using AND or OR behavior.

Here's Must Read info on using filter lists.

The screencasts available here are also worth the few minutes investment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top