Le 19 mai 2015 à 18:04, webwarrior a écrit :
I want to make a tree using TreeModel that reacts to changes in underlying data - when an item changes, tree node for that item should update its state (recompute its children, etc.).
Rebuilding the whole tree is ok, as long as selections and collapsed/expanded state of nodes are preserved.
yes but not very efficient if you have a big tree
Using #updateTree however resets all these things. And there is no easy way to save/load them either - #selectedItems/#selectedItems: work with TreeNode instances that get reset, and collapsed/expanded states of nodes are simply unaccessible from TreeModel.
did you check the implementation of Komitter? It keeps the state of your tree (selected items, collapsed/expanded). So maybe it is doable.
I also tried subclassing TreeNodeModel. But I found no way to update underlying UI widget. There is a huge mess involving TreeNodeModel, MorphicTreeNodeAdapter, SpecTreeNodeModel, and MorphTreeNodeMorph.
The only option left is to extract all needed information from TreeNodeModel hierarchy (preserving the tree structure) before update, and then try to reapply it to newly created hierarchy.
Or is there an easier way?
-- View this message in context: http://forum.world.st/Spec-TreeModel-dynamic-contents-tp4827440.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.