I have a list which is used to monitor arrival of certain entities in a strictly ascending numeric sequence and want to display an entry where there is an apparent break in the sequence.
Is there any way to highlight an entry in GlazeLists?
I have a list which is used to monitor arrival of certain entities in a strictly ascending numeric sequence and want to display an entry where there is an apparent break in the sequence.
Is there any way to highlight an entry in GlazeLists?
Copyright © 2021 Jogjafile Inc.
It's difficult to be certain about whether you're asking about how to highlight new elements within a list, or literally highlight a row in a UI component backed by a GlazedLists
EventList.For now I'll assume the former but feel free to clarify.
There is the notion of ListEvents within the GlazedLists package that allows one to get a small peak into changes that affect a list. It's not something I've played with much, and it seems rather rudimentary, but it's possible to use this mechanism given the right circumstances.
Here's a sample class which has a
BasicEventListcontaining some integers. I've created aListEventListenerand attached it to theEventList. The ListEvents tell you where the element was inserted. It also contains a reference to the eventlist, so it's possible to get the newly inserted value, and also the value of the element preceding it. I do a quick comparison to see whether they're out of sequence.Of course there are some major caveats here. The event handling is asynchronous, so it's entirely possible that the underlying list will changed considerably between the time of the original trigger and the time at which the listener is processing the event. In my sample it's ok because I'm only using append operations. Also I'm only using a
BasicEventList; if it were aSortedListthen the items would be inserted in different indexes, so the method I use for getting the current and previous values would be extremely unreliable. (There may be ways around this but I haven't applied myself to this problem in all honesty.)At the very least you can use the listener to at least alert you to a list change and have another method outside of the listener class perform a scan of your list to determine whether there are items out of order.
Note: I've only tested against GlazedLists v1.8.