String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
UIRightClickPopupMenu uiPopupMenu = event.getSource();
UINavigationNodeSelector uiNodeSelector = uiPopupMenu.getAncestorOfType(UINavigationNodeSelector.class);
UIPopupWindow uiManagementPopup = uiNodeSelector.getAncestorOfType(UIPopupWindow.class);
UIPageNodeForm2 uiNodeForm = uiManagementPopup.createUIComponent(UIPageNodeForm2.class, null, null);
uiNodeForm.setValues(null);
uiManagementPopup.setUIComponent(uiNodeForm);
Object parent = null;
List<PageNode> pageNodes = uiNodeSelector.getSelectedNavigation().getNodes();
if (uri != null && uri.trim().length() > 0)
{
for (PageNode pageNode : pageNodes)
{
parent = PageNavigationUtils.searchPageNodeByUri(pageNode, uri);
if (parent != null)
{
break;
}
}
}
if (parent == null)
{
parent = uiNodeSelector.getSelectedNavigation();
}
uiNodeForm.setSelectedParent(parent);
// set navigation owner, navigation type
uiNodeForm.setOwner(uiNodeSelector.getSelectedNavigation().getOwnerId());
uiNodeForm.setOwnerType(uiNodeSelector.getSelectedNavigation().getOwnerType());
uiManagementPopup.setWindowSize(800, 500);
event.getRequestContext().addUIComponentToUpdateByAjax(uiManagementPopup.getParent());
}