1

RowFilter examples only do text comparison, but how does one filter rows that are linked to particular properties ?

my datamodel class

class MyDataModel
{
    private ArrayList<MyFile> data; // for the rows data 

...

class Myfile
{
   private boolean error; // file name issues
   private boolean ignored; // file ignored for process
   private boolean exception; // file processed no matter other conditions
...

so how do I filter the rows where the MyFile has some property to true (or even more complex tests on these fields)

thanks

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Phil
  • 708
  • 1
  • 11
  • 22

2 Answers2

1

What do you mean by text comparision? Have you added your filter and overridden include method?

boolean include(RowFilter.Entry<? extends M,? extends I> entry) 

The API document here RowFilter itself explains how you can filter based on integer/number or based on any property type

Optional
  • 4,387
  • 4
  • 27
  • 45
  • indeed, strange the example I found only talked about regexfilter andfilter, orfilter... – Phil Oct 05 '16 at 09:59
0
    RowFilter<Object,Object> filter = new RowFilter<Object,Object>() 
    {
       public boolean include(Entry<? extends Object, ? extends Object> entry) 
       {
           int rowID=(Integer)entry.getIdentifier();
           FilesTableModel data=(FilesTableModel) entry.getModel();
           return data.isVisible(rowID);
       }
    };
    TableRowSorter<FilesTableModel> sorter = new TableRowSorter<FilesTableModel>(data);
    sorter.setRowFilter(filter);
    table.setRowSorter(sorter);
Phil
  • 708
  • 1
  • 11
  • 22