PDA

View Full Version : Custom icons in tree Model



doughboy
21 Mar 2012, 6:13 AM
In 2.5, the documentation about the method TreePanel.getStyle().setNodeOpenIcon is:
Sets the global icon style for expanded tree items (defaults to 'tree-folder-open'). Individual tree items can override this value by setting the the item's icon style.

I'm looking all over the place but can't find a way to change my individual items icons. All my items in the tree are extending (BaseTreeModel). I assume I'm not extending (or) implementing the good classe.

Can someone shed some light on this?

Ersmarker
23 Mar 2012, 5:49 AM
You should use the iconprovider.



tree.setIconProvider(new ModelIconProvider<ModelData>() {
@Override
public AbstractImagePrototype getIcon(ModelData model) {
// return your icon
}
});

doughboy
23 Mar 2012, 11:10 AM
Thanks Ersmarker,

I use the ClientBundle to ge the icons.

Here's my code:


tree.setIconProvider(new ModelIconProvider<ModelData>() {
@Override
public AbstractImagePrototype getIcon(ModelData model) {
return AbstractImagePrototype.create(Resources.ICONS.add());
}
});