scala-swing
scala-swing copied to clipboard
Tree view improvements
Hi Ingo, Sorry for my long inactivity this last year -- I've now improved the Tree-view design in a number of respects. TreeDemo contains examples of most of the desired use cases.
-
Internal/External model split. TreeModels are now either External (virtual descriptions of some arbitrary external structure) or Internal (an eagerly-initialised internally stored tree structure copied from some external structure).
-
A way to update, edit, add and remove nodes, for external and internal models. All models have update(), remove(), insertUnder(), insertAfter() and insertBefore() methods.
Using an internal representation gives you these for free, whereas an external model needs them provided with the makeUpdatableWith(), makeInsertableWith() and makeRemovableWith() methods.
-
Tree.Path is now IndexedSeq instead of List.
-
map and filter methods for TreeModels. Currently the ExternalTreeModel has to turn itself into an InternalTreeModel to do a map, which is not very satisfactory.
-
ListView has been integrated into the CellView abstraction. There is unfortunately a minor backwards-compat problem -- the componentFor method in existing subclasses of ListView.Renderer would need to be marked "override". I'm not sure how much of a problem this is, but this is as close as I can get without jettisoning the (IMHO beneficial) CellInfo abstraction.
The ListView integration is in a separate commit to the Tree stuff, so it can be safely left out if you think it's a bit hairy at this stage.
NB Table hasn't been integrated yet; it can't have a straight renderer method, it needs to be per-row/column. I suspect that RenderableCells and EditableCells will have to be snipped or eliminated to fit Table into the system.