// construct the panel
add(new RecursivePanel("panels", l1));
// create a tree
TreeModel treeModel = convertToTreeModel(l1);
final Tree tree = new Tree("tree", treeModel)
{
protected String renderNode(TreeNode node)
{
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
Object userObject = treeNode.getUserObject();
return (userObject instanceof List) ? "<subtree>" : String.valueOf(treeNode
.getUserObject());
}
};
// disable ajax links in this example
tree.setLinkType(LinkType.REGULAR);
add(tree);
add(new Link("expandAll")
{
public void onClick()
{
tree.getTreeState().expandAll();
}
});
add(new Link("collapseAll")
{
public void onClick()
{
tree.getTreeState().collapseAll();
}
});
add(new BookmarkablePageLink("ajaxTreeLink", SimpleTreePage.class));
}