}
public void init(final TreeTablePanel page, final TreeTableNode treeNode)
{
this.treeNode = treeNode;
final ContextImage spacerImage = new PresizedImage("spacer", WebConstants.IMAGE_SPACER);
final boolean showExploreIcon = treeNode.hasChilds();
int spacerWidth;
if (showExploreIcon == true)
spacerWidth = treeNode.getIndent() * WebConstants.IMAGE_TREE_ICON_WIDTH + 1;
else spacerWidth = (treeNode.getIndent() + 1) * WebConstants.IMAGE_TREE_ICON_WIDTH + 1;
spacerImage.add(AttributeModifier.replace("width", String.valueOf(spacerWidth)));
if (this.link.isVisible() == true) {
link.add(spacerImage);
add(WicketUtils.getInvisibleDummyImage("spacer", getRequestCycle()));
} else {
add(spacerImage);
}
final ContextImage leafImage = new PresizedImage("leaf", WebConstants.IMAGE_TREE_ICON_LEAF);
leafImage.setVisible(treeNode.isLeaf());
add(leafImage);
final WebMarkupContainer iconSpan = new WebMarkupContainer("icons");
add(iconSpan);
if (useAjaxAtDefault == false) {
iconSpan.setRenderBodyOnly(true);
}
{
final WebMarkupContainer exploreLink;
if (useAjaxAtDefault == true) {
exploreLink = new AjaxFallbackLink<Object>("explore") {
@Override
public void onClick(final AjaxRequestTarget target)
{
if (target == null || treeTable == null) {
// Link with right mouse button and select new browser window / tab?
return;
}
treeTable.setOpenedStatusOfNode(TreeTableEvent.EXPLORE, treeNode.getHashId());
if (treeNode.isFolder() == true) {
// Implore
page.setEvent(target, TreeTableEvent.IMPLORE, treeNode);
} else {
// Explore
page.setEvent(target, TreeTableEvent.EXPLORE, treeNode);
}
};
};
} else if (useSubmitLinkImages == true) {
exploreLink = new SubmitLink("explore") {
@Override
public void onSubmit()
{
treeTable.setOpenedStatusOfNode(TreeTableEvent.EXPLORE, treeNode.getHashId());
page.setEventNode(treeNode.getHashId());
}
};
} else {
exploreLink = new Link<Object>("explore") {
@Override
public void onClick()
{
treeTable.setOpenedStatusOfNode(TreeTableEvent.EXPLORE, treeNode.getHashId());
page.setEventNode(treeNode.getHashId());
};
};
}
exploreLink.setVisible(showExploreIcon);
iconSpan.add(exploreLink);
// Get string results in warnings (panel was added before)?
final ContextImage exploreImage = new PresizedImage("explore", WebConstants.IMAGE_TREE_ICON_EXPLOSION);
exploreLink.add(exploreImage);
}
{
final WebMarkupContainer folderLink;
if (useAjaxAtDefault == true) {
folderLink = new AjaxFallbackLink<TreeTableNode>("folder", new Model<TreeTableNode>(treeNode)) {
@Override
public void onClick(final AjaxRequestTarget target)
{
if (target == null || treeTable == null) {
// Link with right mouse button and select new browser window / tab?
return;
}
if (getModelObject().isOpened() == true) {
treeTable.setOpenedStatusOfNode(TreeTableEvent.CLOSE, treeNode.getHashId());
page.setEvent(target, TreeTableEvent.CLOSE, treeNode);
} else {
treeTable.setOpenedStatusOfNode(TreeTableEvent.OPEN, treeNode.getHashId());
page.setEvent(target, TreeTableEvent.OPEN, treeNode);
}
};
};
} else if (useSubmitLinkImages == true) {
folderLink = new SubmitLink("folder", new Model<TreeTableNode>(treeNode)) {
@Override
public void onSubmit()
{
if (((TreeTableNode) getDefaultModelObject()).isOpened() == true) {
treeTable.setOpenedStatusOfNode(TreeTableEvent.CLOSE, treeNode.getHashId());
page.setEventNode(treeNode.getHashId());
} else {
treeTable.setOpenedStatusOfNode(TreeTableEvent.OPEN, treeNode.getHashId());
page.setEventNode(treeNode.getHashId());
}
}
};
} else {
folderLink = new Link<TreeTableNode>("folder", new Model<TreeTableNode>(treeNode)) {
@Override
public void onClick()
{
if (getModelObject().isOpened() == true) {
treeTable.setOpenedStatusOfNode(TreeTableEvent.CLOSE, treeNode.getHashId());
page.setEventNode(treeNode.getHashId());
} else {
treeTable.setOpenedStatusOfNode(TreeTableEvent.OPEN, treeNode.getHashId());
page.setEventNode(treeNode.getHashId());
}
};
};
}
folderLink.setVisible(treeNode.hasChilds() == true);
iconSpan.add(folderLink);
folderImage = new PresizedImage("folderImage", WebConstants.IMAGE_TREE_ICON_FOLDER);
folderImage.setOutputMarkupId(true);
folderOpenImage = new PresizedImage("folderOpenImage", WebConstants.IMAGE_TREE_ICON_FOLDER_OPEN);
folderOpenImage.setOutputMarkupId(true);
folderLink.add(folderImage).add(folderOpenImage);
}
final Label clickedEntryLabel = new Label("clickedEntry", "<a name=\"clickedEntry\" />");
clickedEntryLabel.setEscapeModelStrings(false);