You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Doug Leeper <do...@yahoo.com> on 2007/10/18 18:46:21 UTC
Simple Tree question
How does one get a Tree node that allows children but has no children display
as a folder rather than a leaf node?
I thought if allowsChildren was true it would always default to a folder
icon.
--
View this message in context: http://www.nabble.com/Simple-Tree-question-tf4648222.html#a13278582
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Simple Tree question
Posted by James McLaughlin <jo...@gmail.com>.
Hi Doug,
You need to set up the TreeState when the tree first renders. You can
do this by overriding newTreeState.
Below is a snippet that shows one way of accomplishing this:
@Override
protected ITreeState newTreeState()
{
ITreeState state = new DefaultTreeState();
state.collapseAll();
TreeModel treeModel = (TreeModel) getModelObject();
RealTimeTreeNode root = (RealTimeTreeNode) treeModel.getRoot();
checkNodeForExpansion(root, state);
return state;
}
protected void checkNodeForExpansion(RealTimeTreeNode root,
ITreeState state)
{
state.expandNode(root);
Enumeration e = root.children();
while (e.hasMoreElements()) {
Object node = e.nextElement();
if (node instanceof RealTimeTreeNode) {
RealTimeTreeNode rtnode = (RealTimeTreeNode) node;
SWTree tree = rtnode.getNode();
switch (tree.getSWTreeType()) {
case Provider:
case Account:
case Site:
case Gateway:
case System:
checkNodeForExpansion(rtnode, state);
break;
case Device:
case Card:
case Meter:
break;
}
}
}
}
best,
jim
On 10/18/07, Doug Leeper <do...@yahoo.com> wrote:
>
> How does one get a Tree node that allows children but has no children display
> as a folder rather than a leaf node?
>
> I thought if allowsChildren was true it would always default to a folder
> icon.
> --
> View this message in context: http://www.nabble.com/Simple-Tree-question-tf4648222.html#a13278582
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Simple Tree question
Posted by Matej Knopp <ma...@gmail.com>.
I believe the isLeaf() method of TreeNode is what determines whether
the node displays as leaf or not.
-Matej
On 10/18/07, Doug Leeper <do...@yahoo.com> wrote:
>
> How does one get a Tree node that allows children but has no children display
> as a folder rather than a leaf node?
>
> I thought if allowsChildren was true it would always default to a folder
> icon.
> --
> View this message in context: http://www.nabble.com/Simple-Tree-question-tf4648222.html#a13278582
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org