Sadly, it is not possible to use tree>>#displayBlock: directly because the tree is initialized with:
columns := { TreeColumnModel new
displayBlock: [:node | (self wrapItem: node content) ] } asValueHolder.

TreeModel>>#wrapItem: anItem
^ displayBlock value cull: anItem cull: self

As you can see, it is then impossible to get a reference to the node. You only get the node content and a reference to the tree itself.

Le 2 juil. 2015 � 14:01, Peter Uhn�k a �crit :

Or you can use displayBlock: (and root: and children:) directly on the TreeModel.

    tree := self newTree.

    tree
roots: { root1 root2 };
displayBlock: [ :node | node label ];
childrenBlock: [ :node | node children ];
iconBlock: [ :node | node icon ].

I'm not sure if direct creation of TreeColumnModel/TreeNodeModel is advised considering TreeModel is trying to hide it.

Peter

On Thu, Jul 2, 2015 at 1:33 PM, Christophe Demarey <Christophe.Demarey@inria.fr> wrote:

Le 30 juin 2015 � 16:01, Christophe Demarey a �crit :

> Hi,
>
> I have a TreeModel with different kinds of TreeNodeModel and I would like to get a customizable display string depending on the node type.
> It looks like it is not possible to dispatch on nodes in a display block because it only takes the item (node content) and the tree as parameter.
> It is strange as I expect that to be a standard feature. Do I miss something?

I found a workaround and it looks like a missing feature in Spec TreeModel.
You can customize the display by settings columns on the tree like this:

self newTree
        columns: { TreeColumnModel new
                displayBlock: [:node | node label ] };