Created
April 20, 2018 11:29
-
-
Save peteruhnak/6824170bce0c883c9bc338a46323a35c to your computer and use it in GitHub Desktop.
FastTree expansion save/load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ds := FTTreeDataSource | |
roots: (1 to: 6) | |
children: [ :data :item | | |
2 to: data - 1 ]. | |
save := nil. | |
save := [ :item :exp | |d| | |
d := Dictionary new. | |
exp at: item data put: d. | |
item isExpanded ifTrue: [ | |
item children do: [ :each | save value: each value: d ] | |
]. | |
]. | |
expansion := Dictionary new. | |
ds rootItem children do: [ :each | | |
save value: each value: expansion. | |
]. | |
load := nil. | |
load := [ :item :exp | | |
exp at: item data ifPresent: [ :d | | |
d ifNotEmpty: [ | |
item expand. | |
item refreshTable. | |
item children do: [ :each | | |
load value: each value: d | |
] | |
] | |
] | |
]. | |
ds rootItem children do: [ :each | | |
load value: each value: expansion. | |
]. | |
(morph := FTTableMorph new) | |
extent: 200 @ 400; | |
dataSource: ds; | |
openInWindow. | |
morph dataSource: ds. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment