[REVIEW REQUEST] Improvements to TableView sorting

Richard Bair richard.bair at oracle.com
Mon Feb 18 13:54:42 PST 2013


>> This is not very clear to me. It seems that you indicate there are two scenarios:
>> 
>> A) The list you provide to TableView is a SortedList.
>> 
>> B) The list you provide to TableView is not a SortedList.
>> 
>> So in A), TableView will not do any sorting of its own, and it will not modify its comparator (or are you talking about SortedList's comparator?), but you can still bind the comparator to your SortedList?
> 
> Right. To clarify: when a SortedList is set in the TableView items list the TableView _will not_ sort it (either by actually performing a sort or by modifying the Comparator on the SortedList). The TableView _will_ modify the TableView.comparator property to represent what the user has requested, but this is not necessarily the guaranteed visual state.
> 
> And yes, you can bind the SortedList comparator to the TableView comparator to get the expected sorting support.

And the reason for this is that the SortedList is unmodifiable (but mutable). So the add / remove methods etc throw unsupported operation exception, so from the table's perspective, it cannot be sorted. So if you use such a list, then you have to take one more step to wire up the comparator of the sorted list to the comparator on the table view, so that whenever the comparator changes the sorted list is notified of it and can do its own sorting internally.

Richard


More information about the openjfx-dev mailing list