Chapter 4. TransformedList and UniqueList

Table of Contents

ListEvents and ListEventAssembler
TransformedList and ListEvents
Eliminating duplicates with UniqueList
So What?

In part four of this tutorial, we compose a list of users derived from the list of issues. Each issue has a user, so we extract all users from all issues to form a new list. The derived list is also a EventList so we can apply filtering and sorting to it in turn. In part five we use our derived users list to filter for issues belonging to a selected user.

ListEvents and ListEventAssembler

Earlier in the tutorial we discussed how Glazed Lists uses events to propagate changes to TransformedLists and widgets. Although this had been significant in understanding how EventLists work, it was not necessary to interact with the event and listener code directly. In this stage we create a custom transformation and require some of the event and listener code in the process.

ListEvents are sophisticated event objects. Each event notification may contain information on hundreds of inserts, updates and deletes within a list. To simplify the process, the ListEventAssembler class assembles and manages ListEvents and their listeners. The ListEventAssembler has methods addInsert(index), addUpdate(index) and addDelete(index) to be called with each list add(), set() and remove(), respectively. Finally it has a pair of methods beginEvent() and commitEvent() that prepare for and fire the event to listeners. To fire an event that is identical to the event received, the forwardEvent() method may be used.