UIRightClickPopupMenu uiPopupMenu = event.getSource();
uiNodeSelector = uiPopupMenu.getAncestorOfType(UINavigationNodeSelector.class);
context.addUIComponentToUpdateByAjax(uiNodeSelector);
String nodeID = context.getRequestParameter(UIComponent.OBJECTID);
TreeNode targetNode = uiNodeSelector.findNode(nodeID);
TreeNode sourceNode = uiNodeSelector.getCopyNode();
if (sourceNode == null)
return;
try {
targetNode = rebaseNode(targetNode, uiNodeSelector);
if (targetNode == null)
return;
} catch (NavigationServiceException ex) {
handleError(ex.getError(), uiNodeSelector);
return;
}
if (sourceNode.getId().equals(targetNode.getId())) {
context.getUIApplication().addMessage(
new ApplicationMessage("UIPageNodeSelector.msg.paste.sameSrcAndDes", null));
return;
}
if (isExistChild(targetNode, sourceNode)) {
context.getUIApplication().addMessage(new ApplicationMessage("UIPageNodeSelector.msg.paste.sameName", null));
return;
}
if(isExistsInTree(sourceNode, targetNode)) {
context.getUIApplication().addMessage(new ApplicationMessage("UIPageNodeSelector.msg.paste.wrongLocation", null, ApplicationMessage.WARNING));
return;
}
UITree uitree = uiNodeSelector.getChild(UITree.class);
UIRightClickPopupMenu popup = uitree.getUIRightClickPopupMenu();
popup.setActions(new String[] { "AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CutNode", "CloneNode",
"DeleteNode", "MoveUp", "MoveDown" });
uiNodeSelector.setCopyNode(null);
if (uiNodeSelector.findNode(sourceNode.getId()) == null) {
context.getUIApplication().addMessage(
new ApplicationMessage("UINavigationNodeSelector.msg.copiedNode.deleted", null,
ApplicationMessage.WARNING));
uiNodeSelector.selectNode(uiNodeSelector.getRootNode());
return;
}
if (sourceNode.isDeleteNode()) {
targetNode.addChild(sourceNode);
uiNodeSelector.selectNode(targetNode);
return;
}
pageService = uiNodeSelector.getApplicationComponent(PageService.class);
pasteNode(sourceNode, targetNode, sourceNode.isCloneNode());
uiNodeSelector.selectNode(targetNode);
}