How to refresh EventList when underlying source is changed by model

Hi there,

I have a problem with using the Glazedlist Add-On. I have a model (EMF) which create objects (kind of List objects). They are calculated and updated inside the model, but used in an EventList to present them in a table. The problem is, that I am not able to refresh the display automatically when the model changes the underlying values of the EventList. The EventList contains objects of:

[code]
public class EventListObjects implements Serializable {
private static final long serialVersionUID = 1L;
int rowIndex = 0;
Map<String, Object> columnMap = new HashMap<String, Object>();

// CustomClass itself is based on List
public EventListObjects (int rowIndex, List dataList, List columNames)[
this.rowIndex = rowIndex;
for (int i = 0; i < columnNames.size(); i++){
columnMap.put(columnMap.get(i), dataList.get(i));
}
}

public double getValue(String columnName){
return columnMap.get(columnName).get(rowIndex);
}

public void setValue(double value, String columnName){
columnMap.get(columnName).set(rowIndex, value);
}
[/code]The dataList Objects are the one containing the calculated data. When I observe the value at runtime the EventListObjects already contains the (by the model) updated value, but it is not shown in the table. Glazedlist FAQ (
http://www.glazedlists.com/documentation/faq
) tells one to do .set(.get) which works fine, but I would prefer an automatic (eventbased) refresh of the displayed data. As there is no method used in EvenListObjects class while the model changes the dataList values, I also have no idea how to implement the second recommendation of Glazedlist-FAQ because therefore I need a method which fires the events.

Hast anyone an idea if there is a way for Glazedlist to recognize a change in the underlying source?

Thanks in advance

Patric

Sorry, I’m the add-on author and just noticed this thread. You may be way past this by now, but here are some notes for posterity.

The way GlazedLists itself and the add-on model work at that it’s concerned about the EventList, not the data inside the event list. It doesn’t really have a way to know that the content of your objects have changed. So, for example, I assume you have something like this:

EventList<EventListObjects> list = ... In this example, adding and removing items from the list will fire GL events which are handled by the EventListContainer and subsequently cause a Table/Grid update.

If, on the other hand, you call setValue on a specific element inside the list, the EventListContainer will not know about the change and so you will see no change.

The notable exception is when
ObservableElementList
is used. In this case, the list registers as a listener to each element and fires events when they update. You can use this to work around the issue. The other “hack” is something like this:

EventListObject obj = list.get( 0 );
obj.setValue( 1 );
list.set( 0, obj );

Something like this is often done to “kick” the list chain when there’s a domain object value update. This should correctly update your Table/Grid when using the EventListContainer as well.