Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to use static filters (how to reapply a static filter in case data change)
How to use static filters [message #1771393] Thu, 24 August 2017 15:55 Go to next message
Chris Lewold is currently offline Chris LewoldFriend
Messages: 13
Registered: July 2017
Junior Member
I created a static filiter similar to this code

class MyBean {
  public boolean displayBean;
  // ... and more of course
}

List<MyBean> myBeans=MyDataInitializer.fetchData(); 
EventList<MyBean> myEventList=GlazedLists.eventList(myBeans);
FilterList<MyBean> myFilterList=new FilterList(myEventList);
myFilterList.setMatcher(bean->bean.displayBean);

DataLayer bodyDataLayer=new GroupByDataLayer(groupByModel, myFilterList, columnAccessor); 
GlazedListEventLayer gel=new GlazedListsEventLayer<>(bodyDataLayer, filterList);
ColumnHideShowLayer hsl=new ColumnHideShowLayer(gel);
GridLayer gl=new GridLayer( hsl, ....); 
NatTable table=new NatTable(parent, gridLayer, true); 


... above is obviously incomplete pseudocode. Basiallly I want the beans with "displayBean==true" to be shown. This flag changes during calculation steps in a wizard like view. On the last tab I show a NatTable which shall only display the requested beans. (it is initialized at the start when the whole window gets opened - in the meantime the bean values change on the previous pages).

-) when the tab activates I do a natTable.refresh(), but the beans with "displayBean==false" still are visible.
-) when I use the grouping feature they suddenly vanish.


I'm sure I do something very basic wrong - so: how to I get the filter applied once the data in the underlying beans change?

Thanks,
Chris

Re: How to use static filters [message #1771428 is a reply to message #1771393] Fri, 25 August 2017 05:38 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
The first thing to understand is that GlazedLists and NatTable are not the same project. NatTable is making use of GlazedLists in several scenarios if the extension is used.

You are applying a static filter on the FilterList. NatTable is only showing the FilterList. If the content of the list items change, the FilterList does not get informed about that. Therefore the FilterList does not change, which also means the visualization in NatTable does not change.

You need to tell the FilterList that it needs to refresh. This can be done by re-applying the Matcher.
Re: How to use static filters [message #1771434 is a reply to message #1771428] Fri, 25 August 2017 05:56 Go to previous message
Chris Lewold is currently offline Chris LewoldFriend
Messages: 13
Registered: July 2017
Junior Member
Well I was aware of that - my misunderstanding obviously was, that I thought "NatTable.refresh" (which in turn fires a StructuralRefreshCommand) is sufficient - obviously I was wrong there.

I will try to reapply the matcher, thanks a lot for the hint.
Previous Topic:Is it possible to implement something similar to merged cells in Excel?
Next Topic:Is it possible to use RowSelectionModel in combination with GroupByLayer ?
Goto Forum:
  


Current Time: Thu Apr 25 22:58:01 GMT 2024

Powered by FUDForum. Page generated in 0.03353 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top