Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » remove data when table is sorted
remove data when table is sorted [message #1087320] Thu, 15 August 2013 13:15 Go to next message
David Hein is currently offline David HeinFriend
Messages: 3
Registered: May 2013
Junior Member

I have a Nattable which is based on a EMF model. If something is added or removed from the model then I got a notification via EMF and I add or remove this object from my EventList in the Nattable. This is working fine, but only for not sorted tables.

If I sort a column and remove then a object then I got strange row indexes in my IConfigLabelAccumulator. The index is then -1. Thats only happens when a column is sorted.

My implementation looks like:

//The three lists I need for my table
TransformedList<MyObject, MyObject> baseEventList = GlazedLists.threadSafeList(GlazedLists.eventList(myObjects));
FilterList<MyObject> filterList = new FilterList<MyObject>(baseEventList);
SortedList<MyObject> sortedList = new SortedList<MyObject>(filterList, null);

//My data provider, which implements Adapter from EMF to get notifications about the model change. If something is changed in the model I do the specific modification on the list.
public class MyRowDataProvider extends GlazedListsDataProvider<MyObject> implements Adapter {

	public CSMInstanceRowDataProvider(EventList<MyObject> eventList,
		IColumnPropertyAccessor<MyObject> columnPropertyAccessor, EMFObject emfObject) {
		super(eventList, columnPropertyAccessor);

	public void notifyChanged(Notification notification) {
		if (notification.getEventType() == Notification.REMOVE) {
			if (notification.getOldValue() instanceof MyObject) {
		else if (notification.getEventType() == Notification.ADD) {
			if (notification.getNewValue() instanceof MyObject) {
				this.list.add((MyObject) notification.getNewValue());

What happens if a column is sorted? Is it correct that nattable will react automatically if there are changes on the Eventlist? I also tried to do a nattable.refresh(), but this also did not work.

Thanks, David
Re: remove data when table is sorted [message #1087400 is a reply to message #1087320] Thu, 15 August 2013 15:30 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2824
Registered: July 2012
Senior Member
Several facts:

I suggest to create the FilterList on top of the SortedList.
You need to use the GlazedListsEventLayer or DetailGlazedListsEventLayer if you want to get automatically refreshes when changes to the EventList occur.
Over which data is your IConfigLabelAccumulator iterating if you get an index of -1. Maybe you are trying to access something that is not yet updated?
Previous Topic:State saving is buggy...
Next Topic:Automatic row resizing
Goto Forum:

Current Time: Fri Sep 17 01:03:40 GMT 2021

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

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

Back to the top