// construct the panel
add(new RecursivePanel("panels", l1));
// create a tree
TreeModel treeModel = convertToTreeModel(l1);
final Tree tree = new Tree("tree", treeModel)
{
@Override
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<Void>("expandAll")
{
@Override
public void onClick()
{
tree.getTreeState().expandAll();
}
});
add(new Link<Void>("collapseAll")
{
@Override
public void onClick()
{
tree.getTreeState().collapseAll();
}
});
add(new BookmarkablePageLink("ajaxTreeLink", SimpleTreePage.class));
}