« Return to Thread: Tracking changes in EventLists

re: Tracking changes in EventLists

by Kevin Day-7 :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
I may be wrong, but my understanding is that this is probably the biggest outstanding issue with GL...  I've run up against it a number of times trying to sync different data structures to EventList...  Knowing what item was actually removed is just absolutely critical for a large number of use-cases.
 
The workaround that I've seen posted (you may want to search the list archives) has been to keep a local cache of the list that can be queried for the removed element.  That certainly doesn't meet the 'efficient' requirement.
 
I know that a bit of work has been done to make delete events hold the removed element reference, but my understanding is that there are some challenges with getting this shoe-horned into the existing API.
 
Personally, I'd love to know what the issues are, and maybe take a crack at solving them - lack of reference to the removed element causes us all sorts of problems.
 
Does anyone with a bit more history with GL know what the issues are?
 
- K
 
----------------------- Original Message -----------------------
  
From: Witold Szczerba pljosh.mail@...
To: users@...
Cc: 
Date: Tue, 7 Jul 2009 11:07:45 +0200
Subject: Tracking changes in EventLists
  
Hi there,
I am working with BeansBinding framework in my recent project, there
is a list implementation: ObservableList. I want to use EventLists in
few places, but what stops me right now is the problem with
ListEventListener. What I need is the object which can track changes
on list. I have created a simple tracker for ObservableList. One
tracker can be used for many ObservableLists. It works like this:

ObservableListTracker tracker = new ObservableListTracker();
ObservableList list = ObservableCollections.observableList(new ArrayList());
list.add("1");
list.add("2");
list.add("3");
list.addObservableListListener(tracker);

assertTrue(tracker.isEmpty());

list.add("a");
assertTrue(tracker.getAddedTo(list).contains("a"));
assertFalse(tracker.isEmpty());

list.remove("a");
assertTrue(tracker.getDeletedFrom(list).isEmpty());
assertTrue(tracker.getAddedTo(list).isEmpty());
assertTrue(tracker.isEmpty());

list.remove("3");
assertTrue(tracker.getDeletedFrom(list).contains("3"));
assertFalse(tracker.isEmpty());

list.clearAll();
assertTrue(tracker.getDeletedFrom(list).contains("3"));
assertTrue(tracker.getDeletedFrom(list).contains("2"));
assertTrue(tracker.getDeletedFrom(list).contains("1"));
assertFalse(tracker.isEmpty());

tracker.reset();
assertTrue(tracker.getDeletedFrom(list).isEmpty());
assertTrue(tracker.getAddedTo(list).isEmpty());
assertTrue(tracker.isEmpty());


I was trying to create such a tracker for EventList, but it is not
that easy, because when elements are removed from EventList, the
ListEvent is unable to tell me what element was removed. All it tells
me is: there was _something_ on index X - but that is not enough.

My question is: maybe some of you have created such an object I could
use to track changes?
Or maybe you have some ideas how to implement this efficiently?

Regards,
Witold Szczerba

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@...

 « Return to Thread: Tracking changes in EventLists