// Adding menu tree node
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(
new SiteTreeNode("Root", "/", FileType.Folder, false));
retrieveCopyFolders("/", rootNode);
copyTreeNode = new DefaultTreeModel(rootNode);
final LinkTree copyTree = new LinkTree("copyTree",
new PropertyModel(this, "copyTreeNode"))
{
@Override
protected void onNodeLinkClicked(Object node, BaseTree tree,
AjaxRequestTarget target)
{
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
SiteTreeNode siteNode = (SiteTreeNode) treeNode
.getUserObject();
if (!tree.getTreeState().isNodeExpanded(treeNode))
{
if (siteNode.getDocType() == SiteTreeNode.FileType.Folder
&& !siteNode.isLoaded())
{
retrieveCopyFolders(siteNode.getNodePath(),
treeNode);
siteNode.setLoaded(false);
this.updateTree();
}
this.getTreeState().expandNode(treeNode);
} else
{
tree.getTreeState().collapseNode(treeNode);
}
setDocPath(siteNode.getNodePath());
}
};
copyTree.getTreeState().expandNode(copyTreeNode);
add(copyTree);
add(copyForm);
}