private IModel<BrixNode> targetNode = new BrixNodeModel();
public RestoreItemsPanel(String id, String prototypeWorkspaceId, final String targetWorkspaceId) {
super(id, prototypeWorkspaceId);
final Component message = new MultiLineLabel("message", new Model<String>(
""));
message.setOutputMarkupId(true);
add(message);
add(new SiteNodePickerPanel("picker", targetNode, targetWorkspaceId, true, null));
add(new AjaxLink<Void>("restore") {
@Override
public void onClick(AjaxRequestTarget target) {
List<JcrNode> nodes = getSelectedNodes();
if (!nodes.isEmpty()) {
Brix brix = ((BrixNode) nodes.iterator().next()).getBrix();
JcrWorkspace targetWorkspace = brix.getCurrentSession(targetWorkspaceId).getWorkspace();
Map<JcrNode, List<JcrNode>> dependencies = JcrUtil.getUnsatisfiedDependencies(
nodes, targetWorkspace);
;
if (!dependencies.isEmpty()) {
message.setDefaultModelObject(getDependenciesMessage(dependencies));
} else {
JcrNode rootNode = targetNode.getObject();
if (rootNode == null) {
rootNode = targetWorkspace.getSession().getRootNode();
}
PrototypePlugin.get().restoreNodes(nodes, rootNode);
findParent(ModalWindow.class).close(target);
}
} else {
message.setDefaultModelObject("You have to select at least one node.");
}
target.addComponent(message);
}
});
}