FilteredList/SortedList
Martin Sladecek
martin.sladecek at oracle.com
Fri Jan 4 01:16:26 PST 2013
On 01/04/2013 05:08 AM, Jonathan Giles wrote:
>
> Once you start having view models and data models you end up with all
> kinds of ugliness. For a long time TableView actually did this (before
> being released in 2.0). You inevitably end up with API to convert
> between view and data indices, and it all becomes quite painful and
> confusing really quickly. This was why we decided to simplify the
> approach, by 1) saying that, by default, the view model is the data
> model, and 2) moving to an approach where the separation of data and
> view is handled at the data structure level (e.g.
> ObservableList/TransformationList/SortedList/FilteredList/etc), rather
> than the UI control level. It was unfortunate we couldn't get the
> special collections into 2.0, but I'm pleased they're on their way
> into 8.0.
I'm afraid having view and data model is inevitable for column sorting,
otherwise you'd have to modify user data directly. Filtering and
different kinds of sort can be done on data structure level, but for
column sorting, which is a feature of TableView, you'd have to expose
something like view (a TransformationList?) or and API to convert from
view index to model (items) index (which would internally just call
getSourceIndexFor(items, index).
I understand that if you want to be backward-compatible, you have to
modify "items" in place (sigh), so deprecating items and introducing
set/getModel() and getView() (or index querying or whatnot...) might be
necessary to get the things right.
-Martin
More information about the openjfx-dev
mailing list