FilteredList/SortedList
Knut Arne Vedaa
knut.arne.vedaa at broadpark.no
Tue Jan 8 09:54:27 PST 2013
Richard Bair wrote:
> WrappedList items = new WrappedList(original);
> tableView.setItems(items);
Disregarding technicalities / implementation details, conceptually this
could be ok, but in terms of API-friendliness I don't think it's an
improvement over Martin's suggestion, rather the opposite.
The needed knowledge for the API user would be "TableView may mutate
your list, if you don't want that to happen, simply wrap your list in a
WrappedList, but be aware that any index you get from TableView will be
relative to the wrapped list and not your original list, but you can use
the getOriginalIndex() method on WrappedList to convert between them".
While on the other hand, if the logic is internally on TableView, it
would be "just give your list to TableView, but be aware that (due to
possible sorting) viewIndex will be relative to the displayed list,
while modelIndex will be relative to your original list (which will
remain untouced)".
Which one has the least cognitive tax? IMO clearly the latter.
Knut Arne Vedaa
More information about the openjfx-dev
mailing list