Skip to content

Instantly share code, notes, and snippets.

@peteruhnak
Created April 20, 2018 11:29
Show Gist options
  • Save peteruhnak/6824170bce0c883c9bc338a46323a35c to your computer and use it in GitHub Desktop.
Save peteruhnak/6824170bce0c883c9bc338a46323a35c to your computer and use it in GitHub Desktop.
FastTree expansion save/load
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