Another quick question on TreeViews (and models, I guess).
I have a TreeView, and an external Tree model I use to manipulate some data. Periodically, I synchronize things by updating the TreeView's default model with the data I'm working with. This works fine, but at each synchronization, the TreeView refreshes and expands all nodes -even the one's I've collapsed explicitly. Is there a way to turn off "auto expansion" when updating a Tree's model from an external source? Thanks, KeithB |
Keith,
> I have a TreeView, and an external Tree model I use to manipulate some > data. Periodically, I synchronize things by updating the TreeView's > default model with the data I'm working with. This works fine, but at > each synchronization, the TreeView refreshes and expands all nodes How are you doing the synchronisation ? One of my complaints about TreeView is that it /collapses/ itself too often, I haven't noticed a tendency to open up when I don't want it to. -- chris |
Hi Chris,
I've written a tree adaptor that I use to assist in synchronization on demand, then essentially replacing the tree's model when I'm ready. I guess I probably should have used the VirtualTree, but.... Anyway, I don't have any problems with the TreeView collapsing at all. Everything works nicely *except* when I update the model, everything expands (which kind of defeats the purpose of collapsing some nodes). Keith Chris Uppal wrote: > Keith, > > > I have a TreeView, and an external Tree model I use to manipulate some > > data. Periodically, I synchronize things by updating the TreeView's > > default model with the data I'm working with. This works fine, but at > > each synchronization, the TreeView refreshes and expands all nodes > > How are you doing the synchronisation ? One of my complaints about TreeView is > that it /collapses/ itself too often, I haven't noticed a tendency to open up > when I don't want it to. > > -- chris |
Keith,
> I've written a tree adaptor that I use to assist in synchronization on > demand, then essentially replacing the tree's model when I'm ready. Yes, but /how/ do you do that ? Something like: treePresenter model: newTree. ? Or do you clear out the old tree (in place) and then iterate over the new one, using #add:asChildOf: for each node ? Or is your adaptor more like a VirtualTreeModel ? Or what ? -- chris |
Hey Chris,
As Homer Simpson would say "D'oh!" Sorry for my brain-cramp in not fully getting your question before...I guess my brain was only on 3 cylinders :-) Yes, I use treePresenter model: newTree where the newTree has been adapted from an OrderedCollection one of my other components owns and manipulates. I played a bit with the VirtualTree last night, but my results were about the same. Every element add expanded the tree. I'm convinced I'm missing something (probably something small), but don't know what... Keith Chris Uppal wrote: > Keith, > > > I've written a tree adaptor that I use to assist in synchronization on > > demand, then essentially replacing the tree's model when I'm ready. > > Yes, but /how/ do you do that ? > > Something like: > treePresenter model: newTree. > ? Or do you clear out the old tree (in place) and then iterate over the new > one, using #add:asChildOf: for each node ? Or is your adaptor more like a > VirtualTreeModel ? Or what ? > > -- chris |
Keith,
> Yes, I use > treePresenter model: newTree Hmm, I think there must be something else that you are doing (some event handler perhaps ?) which is causing the expansion. An ordinary TreeView doesn't do that. For instance. tp := TreePresenter show. I can now evaluate either of the following as often as I want, and in each case the tree closes itself up completely when the model is changed (even if the replacement model contains the old selected node). tp model: ClassHierarchyModel withAllClasses. tp model: PackageSelector defaultModel. Is that what you see ? -- chris |
Hey Chris,
Thanks for all your help. As it turns out, I wasn't setting the hasLinesAtRoot attribute for my view, so the #basicRefreshContents: method in the TreeView automatically expanded the nodes every time. I missed that detail, but it was the source of my problems. Thanks again, Keith Chris Uppal wrote: > Keith, > > > Yes, I use > > treePresenter model: newTree > > Hmm, I think there must be something else that you are doing (some event > handler perhaps ?) which is causing the expansion. An ordinary TreeView > doesn't do that. For instance. > > tp := TreePresenter show. > > I can now evaluate either of the following as often as I want, and in each case > the tree closes itself up completely when the model is changed (even if the > replacement model contains the old selected node). > > tp model: ClassHierarchyModel withAllClasses. > tp model: PackageSelector defaultModel. > > Is that what you see ? > > -- chris |
Keith,
> As it turns out, I wasn't setting the > hasLinesAtRoot attribute for my view, Well, well, well... I had no idea #hasLinesAtRoot = false had that effect! Live and learn. Cheers! -- chris |
Free forum by Nabble | Edit this page |