String root = SitePlugin.get().getSiteRootPath();
add(new PathLabel("path2", model, root) {
@Override
protected void onPathClicked(Path path) {
BrixNode node = (BrixNode) getNode().getSession().getItem(path.toString());
selectNode(node, false);
}
});
add(new Link<Void>("rename") {
@Override
public void onClick() {
String id = NodeManagerEditorPanel.this.getId();
Panel renamePanel = new RenamePanel(id, NodeManagerEditorPanel.this.getModel()) {
@Override
protected void onLeave() {
SitePlugin.get().refreshNavigationTree(this);
replaceWith(NodeManagerEditorPanel.this);
}
};
NodeManagerEditorPanel.this.replaceWith(renamePanel);
}
@Override
public boolean isVisible() {
BrixNode node = NodeManagerEditorPanel.this.getModelObject();
String path = node.getPath();
String web = SitePlugin.get().getSiteRootPath();
return SitePlugin.get().canRenameNode(node, Context.ADMINISTRATION) &&
path.length() > web.length() && path.startsWith(web);
}
});
add(new Link<Void>("makeVersionable") {
@Override
public void onClick() {
if (!getNode().isNodeType("mix:versionable")) {
getNode().addMixin("mix:versionable");
getNode().save();
getNode().checkin();
}
}
@Override
public boolean isVisible() {
if (true) {
// TODO: Implement proper versioning support!
return false;
}
return getNode() != null && getNode().isNodeType("nt:file") &&
!getNode().isNodeType("mix:versionable") &&
SitePlugin.get().canEditNode(getNode(), Context.ADMINISTRATION);
}
});
add(new Link<Void>("delete") {
@Override
public void onClick() {
BrixNode node = getNode();
BrixNode parent = (BrixNode) node.getParent();
node.remove();
try {
parent.save();
selectNode(parent, true);
}
catch (JcrException e) {
if (e.getCause() instanceof ReferentialIntegrityException) {
parent.getSession().refresh(false);
NodeManagerEditorPanel.this.getModel().detach();
// parent.refresh(false);
selectNode(NodeManagerEditorPanel.this.getModelObject(), true);
getSession().error(
NodeManagerEditorPanel.this.getString("referenceIntegrityError"));
} else {
throw e;
}
}
}
@Override
public boolean isVisible() {
BrixNode node = NodeManagerEditorPanel.this.getModelObject();
String path = node.getPath();
String web = SitePlugin.get().getSiteRootPath();
return SitePlugin.get().canDeleteNode(getNode(), Context.ADMINISTRATION) &&
path.length() > web.length() && path.startsWith(web);
}