[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform] Re: ObservabelList question and databinding
|
"Joel Gregoire" <joelgreg@xxxxxxxxx> wrote in message
news:eab73a79d102c7a08d3d51168fdca717$1@xxxxxxxxxxxxxxxxxx
> I've been playing with Observables for a while and I'm wondering if I'm
> missing something. Is it possible to detect a change in one of the items
> within an ObservableList?? I can surely detect additions and removals but
> I can't detect a change of an item.
> targetObservableList.addListChangeListener( new ListChangeListener() );
>stephane.setMonth( new Month("50") );
An observable list only notifies about changes to itself (the list), not
about changes to objects contained in the list. You could try the following:
IObservableSet targetAsSet = new ListToSetAdapter(targetObservableList);
IObservableMap monthMap = BeansObservables.observeMap(targetAsSet,
Person.class, "month");
monthMap.addMapChangeListener(new IMapChangeListener(){
public void handleMapChange(MapChangeEvent event) {
for(Iterator it = event.diff.getChangedKeys().iterator();
it.hasNext(); ) {
Object key = it.next();
System.out.println("changed month of " + key + " from " +
event.diff.getOldValue(key) + " to " + event.diff.getNewValue(key));
}
}
});
Boris