Hi Tim,
Tim Hooper wrote:
I would like to build a way into the tree so that I can change the graphic when
adding a node to the tree. So, rather than calling
myNode.setChildrenSupported(false); to change the graphic between the 2 hard
coded graphics, I'd like to implement a method something like
myNode.setGraphic(graphicLocation);
You want to override the tree icon? As in the file/folders?
The Tree outputs different CSS classes depending on the state of the
node. The actual icon for a CSS class is set in the tree.css.
If you have a limited amount of icons you want to set, you can
override Tree#getIconClass(TreeNode node) and use a custom TreeNode to
pass the CSS class. Then customize the tree.css to render a different
icon for the class.
If however each TreeNode can have a different icon you probably need
to look at overriding Tree#renderIcon(HtmlStringBuffer, TreeNode) and
render a <img> tag with the specific icon.
Btw the Click jars ships the source code as well, so your IDE should
be able to show the implementations of the above mentioned methods
without you having to search through the click sources.
I haven't looked at the TreeNode code yet. I'm looking for pointers on getting
started and also is this a reasonable addition to the tree node class....is
there an easier way to do this, etc.
A per node icon seems useful. If this is indeed what you are after
could you open a JIRA[1] for this? If you have patches feel free to
upload them as well.
kind regards
bob
[1]: https://issues.apache.org/click/