new PropertyModel(this, "document.page"));
infoForm.add(defaultPageLabel);
infoForm.add(defaultPageField);
defaultPageLabel.setVisibilityAllowed(true);
defaultPageField.setVisibilityAllowed(true);
final ModalWindow metaDataModalWindow;
add(metaDataModalWindow = new ModalWindow("modalwindow"));
AjaxButton addFolder = new AjaxButton("addFolder",new ResourceModel("add.subfolder"),infoForm)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
metaDataModalWindow.setContent(new AddFolderPanel(metaDataModalWindow.getContentId()));
metaDataModalWindow.show(target);
}
};
infoForm.add(addFolder);
AjaxButton addPage = new AjaxButton("addPage",new ResourceModel("add.page"),infoForm)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
metaDataModalWindow.setContent(new AddPagePanel(
metaDataModalWindow.getContentId()));
metaDataModalWindow.show(target);
}
};
infoForm.add(addPage);
AjaxButton addLink = new AjaxButton("addLink",new ResourceModel("add.link"),infoForm)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
metaDataModalWindow.setContent(new AddLinkPanel(metaDataModalWindow.getContentId()));
metaDataModalWindow.show(target);
}
};
infoForm.add(addLink);
addFolder.setVisibilityAllowed(true);
addPage.setVisibilityAllowed(true);
addLink.setVisibilityAllowed(true);
SiteTreeNode node = getUserSelectedNode();
if (node.getDocType() == SiteTreeNode.FileType.Folder)
{
urlLabel.setVisible(false);
urlField.setVisible(false);
targetLabel.setVisible(false);
targetField.setVisible(false);
addFolder.setVisible(true);
addPage.setVisible(true);
addLink.setVisible(true);
}
else if (node.getDocType() == SiteTreeNode.FileType.Page)
{
defaultPageLabel.setVisible(false);
defaultPageField.setVisible(false);
urlLabel.setVisible(false);
urlField.setVisible(false);
targetLabel.setVisible(false);
targetField.setVisible(false);
addFolder.setVisible(false);
addPage.setVisible(false);
addLink.setVisible(false);
}
else if (node.getDocType() == SiteTreeNode.FileType.Link)
{
defaultPageLabel.setVisible(false);
defaultPageField.setVisible(false);
targetLabel.setVisible(true);
defaultPageField.setVisible(false);
pageDecoratorLabel.setVisible(false);
decoratorsList.setVisible(false);
portletDecoratorLabel.setVisible(false);
portletDecoratorsList.setVisible(false);
themeField.setVisible(false);
themeLabel.setVisible(false);
addFolder.setVisible(false);
addPage.setVisible(false);
addLink.setVisible(false);
}
if (node.getDocType() == SiteTreeNode.FileType.Link)
{
ExternalLink viewLink = new ExternalLink("view", new Model(getDocument().getUrl()), new ResourceModel("common.view"))
{
@Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag(tag);
if (tag.getName().equalsIgnoreCase("input") && ((getLabel() != null) && (getLabel().getObject() != null)))
{
tag.put("value", getDefaultModelObjectAsString(getLabel().getObject()));
}
}
};
viewLink.setPopupSettings(new PopupSettings());
infoForm.add(viewLink);
}
else
{
RequestContext context = (RequestContext) getPortletRequest().getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
String basePath = context.getPortalURL().getBasePath().replace("portal", "configure");
ExternalLink viewLink = new ExternalLink("view", new Model(basePath + getDocument().getPath()), new ResourceModel("common.view"))
{
@Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag(tag);
if (tag.getName().equalsIgnoreCase("input") && ((getLabel() != null) && (getLabel().getObject() != null)))
{
tag.put("value", getDefaultModelObjectAsString(getLabel().getObject()));
}
}
};
viewLink.setPopupSettings(new PopupSettings());
infoForm.add(viewLink);
}
infoForm.add(new AjaxButton("remove",new ResourceModel("common.remove"),infoForm)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form form)
{
excuteAction(getDocument(), REMOVE_ACTION);
DefaultMutableTreeNode node = getSelectedNode();
if (node != null && node.getParent() != null)
{
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
parentNode.remove(node);
LinkTree tree = (PortalTree) getPage().get("siteTree");
tree.updateTree(target);
}
}
}.add(new JavascriptEventConfirmation("onclick", new ResourceModel("action.delete.confirm"))));
infoForm.add(new AjaxButton("save",new ResourceModel("common.save"), infoForm)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form form)
{
excuteAction(getDocument(), SAVE_ACTION);
}
});
infoForm.add(new AjaxButton("copy",new ResourceModel("common.copy"),infoForm)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
SiteTreeNode selectedNode = getUserSelectedNode();
metaDataModalWindow.setContent(new CopyMoveWindow(
metaDataModalWindow.getContentId(), selectedNode
.getDocType().name(), selectedNode
.getNodeName(), getUserSelectedNode()
.getNodePath(), true));
metaDataModalWindow.show(target);
}
});
infoForm.add(new AjaxButton("move",new ResourceModel("common.move"),infoForm)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
SiteTreeNode selectedNode = getUserSelectedNode();
metaDataModalWindow.setContent(new CopyMoveWindow(
metaDataModalWindow.getContentId(), selectedNode
.getDocType().name(), selectedNode
.getNodeName(), getUserSelectedNode()
.getNodePath(), false));
metaDataModalWindow.show(target);
}
});
add(infoForm);
}