Using a TreePresenter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using a TreePresenter

Prof. Andrew P. Black
I'm trying to use a (subclass of a) TreePresenter that is populated with FileReferences. I see that the current selection is, reasonably enough, a TreeNodePresenter, so I'm assuming that to set a selection programatically, I'm going to have to find the right TreeNodePresenter. 

So I've assumed a method allItemsDo: that I'm trying to write on my subclass of TreePresenter that will iterate through all of the TreeNodes and let me do stuff, such as looking at their #content to see if this is a node that I'm interested in.

But I can't! The #roots method of TreePresenter doesn't give me the root TreeNodePresenters; it gives me the file references that they contain. How do I iterate over the TreeNodePresenters? Or am I going about this in entirely the wrong way?

Andrew

Reply | Threaded
Open this post in threaded view
|

Re: Using a TreePresenter

Nicolai Hess-3-2


2017-11-27 20:40 GMT+01:00 Prof. Andrew P. Black <[hidden email]>:
I'm trying to use a (subclass of a) TreePresenter that is populated with FileReferences. I see that the current selection is, reasonably enough, a TreeNodePresenter, so I'm assuming that to set a selection programatically, I'm going to have to find the right TreeNodePresenter. 

So I've assumed a method allItemsDo: that I'm trying to write on my subclass of TreePresenter that will iterate through all of the TreeNodes and let me do stuff, such as looking at their #content to see if this is a node that I'm interested in.

But I can't! The #roots method of TreePresenter doesn't give me the root TreeNodePresenters; it gives me the file references that they contain. How do I iterate over the TreeNodePresenters? Or am I going about this in entirely the wrong way?

I find the way the TreeNodeModel (or TreeNodePresenter) is used strange too.
I think it is to tightly bound to the underlaying morphic tree ui.
(seems a TreeNode is only created during morphic interaction).

What I have seen on some other projects (pharo launcher for example). They are creating a TreeNode when building the root of the tree itself.

tree roots: (something that creates the root "raw nodes") collect:[:item | build a TreeNode with this content].

But this does not fully work, as for example

tree root last selected:[true] "< really selects the item"

tree root last selectAllChildren "< still does not change the selection of the nodes in the tree morph."


 

Andrew