remove data when table is sorted [message #1087320] |
Thu, 15 August 2013 09:15  |
Eclipse User |
|
|
|
Hello,
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);
emfObject.eAdapters().add(this);
}
@Override
public void notifyChanged(Notification notification) {
if (notification.getEventType() == Notification.REMOVE) {
if (notification.getOldValue() instanceof MyObject) {
this.list.remove(notification.getOldValue());
}
}
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 11:30  |
Eclipse User |
|
|
|
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?
|
|
|
Powered by
FUDForum. Page generated in 0.29514 seconds