Author: hoang_to
Date: 2010-04-25 22:16:46 -0400 (Sun, 25 Apr 2010)
New Revision: 2758
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/util/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/util/PageNavigationSynchronizer.java
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
Log:
GTNPORTAL-1091: Clean rotten code in webui/portal
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/util/PageNavigationSynchronizer.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/util/PageNavigationSynchronizer.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/util/PageNavigationSynchronizer.java 2010-04-26
02:16:46 UTC (rev 2758)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.portal.config.model.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @version $Id$
+ *
+ */
+public class PageNavigationSynchronizer
+{
+
+ private PageNavigation wrappedPageNavigation;
+
+ private List<PageNavigation> tobeSynchronizedNavigations;
+
+ public PageNavigationSynchronizer(PageNavigation _wrappedPageNavigation)
+ {
+ this.wrappedPageNavigation = _wrappedPageNavigation;
+ this.tobeSynchronizedNavigations = new ArrayList<PageNavigation>();
+ }
+
+ public void start(List<PageNavigation> _synchronizedNavigations)
+ {
+ this.tobeSynchronizedNavigations = _synchronizedNavigations;
+ }
+
+ public void stopSynchronizing(List<PageNavigation> notSynchronizedAnymoreNavs)
+ {
+
+ }
+
+ public void stop()
+ {
+
+ }
+
+ /**
+ * Add a page node to the <code>wrappedPageNavigation</code> as well as
synchronize this action to all navigations in list of
+ * tobeSynchronizedNavigations
+ *
+ */
+ public void addPageNode(PageNode pageNode, String parentUri)
+ {
+ PageNavigationUtil.addPageNode(wrappedPageNavigation, pageNode, parentUri);
+ for(PageNavigation synchronizedNav : tobeSynchronizedNavigations)
+ {
+ PageNavigationUtil.addPageNode(synchronizedNav, pageNode, parentUri);
+ }
+ }
+
+
+ public void removePageNode(PageNode pageNode, String parentUri)
+ {
+ PageNavigationUtil.removePageNode(wrappedPageNavigation, pageNode, parentUri);
+ for(PageNavigation synchronizedNav : tobeSynchronizedNavigations)
+ {
+ PageNavigationUtil.removePageNode(synchronizedNav, pageNode, parentUri);
+ }
+ }
+
+ public void movePageNode(PageNode pageNode, String parentUri, boolean moveUp)
+ {
+
+ }
+
+
+}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2010-04-24
17:12:00 UTC (rev 2757)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2010-04-26
02:16:46 UTC (rev 2758)
@@ -209,16 +209,15 @@
pageManager.setOwnerType(navigation.getOwnerType());
UINavigationNodeSelector selector =
pageManager.getChild(UINavigationNodeSelector.class);
- ArrayList<PageNavigation> list = new ArrayList<PageNavigation>();
- list.add(navigation);
- selector.initNavigations(list);
- selector.loadNavigationByNavId(navId, uicomp.navigations);
- //selector.removeChild(UIRightClickPopupMenu.class);
+
+ //TODO: Set correct value for filteredEdittedNavigation
+ selector.setOriginalEdittedNavigation(navigation);
+ selector.setFilteredEdittedNavigation(navigation);
+ selector.initTreeData();
popUp.setUIComponent(pageManager);
popUp.setWindowSize(400, 400);
popUp.setShowMask(true);
popUp.setShow(true);
- // prContext.addUIComponentToUpdateByAjax(workingWS);
}
}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-04-24
17:12:00 UTC (rev 2757)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-04-26
02:16:46 UTC (rev 2758)
@@ -79,7 +79,6 @@
public class UISiteManagement extends UIContainer
{
- //public static String[] SELECT_ACTIONS = {"EditPortalLayout",
"EditNavigation", "DeletePortal"} ;
public static String[] ACTIONS = {"EditNavigation",
"DeletePortal", "EditPortalLayout"};
private LazyPageList pageList;
@@ -91,7 +90,6 @@
UIPopupWindow editNavigation = addChild(UIPopupWindow.class, null, null);
editNavigation.setWindowSize(400, 400);
editNavigation.setId(editNavigation.getId() + "-" +
UUID.randomUUID().toString().replaceAll("-", ""));
- //loadPortalConfigs();
}
public List<PortalConfig> getPortalConfigs() throws Exception
@@ -183,12 +181,12 @@
}
- public PageNavigation getSelectedNavigation()
+ public PageNavigation getOriginalSelectedNavigation()
{
return selectedNavigation;
}
- public void setSelectedNavigation(PageNavigation navigation)
+ public void setOriginalSelectedNavigation(PageNavigation navigation)
{
selectedNavigation = navigation;
}
@@ -349,16 +347,26 @@
naviManager.setOwner(portalName);
naviManager.setOwnerType(PortalConfig.PORTAL_TYPE);
- PageNavigation navi = dataService.getPageNavigation(PortalConfig.PORTAL_TYPE,
portalName);
- //Filter the navigation
- navi = PageNavigationUtils.filterNavigation(navi, context.getRemoteUser(),
true);
+ PageNavigation originalNavi =
dataService.getPageNavigation(PortalConfig.PORTAL_TYPE, portalName);
+ PageNavigation filteredNavi = null;
+ try{
+ filteredNavi = PageNavigationUtils.filterNavigation(originalNavi,
prContext.getRemoteUser(), true);
+ }
+ catch(Exception ex)
+ {
+
+ }
+
+ uicomp.setOriginalSelectedNavigation(originalNavi);
+ UINavigationNodeSelector selector =
naviManager.getChild(UINavigationNodeSelector.class);
+ //ArrayList<PageNavigation> list = new ArrayList<PageNavigation>();
+ //list.add(navi);
+ //selector.initNavigations(list);
+ selector.setOriginalEdittedNavigation(originalNavi);
+ //selector.setFilteredEdittedNavigation(filteredNavi);
+ selector.setFilteredEdittedNavigation(originalNavi);
+ selector.initTreeData();
- uicomp.setSelectedNavigation(navi);
- UINavigationNodeSelector selector =
naviManager.getChild(UINavigationNodeSelector.class);
- ArrayList<PageNavigation> list = new ArrayList<PageNavigation>();
- list.add(navi);
- selector.initNavigations(list);
- //selector.removeChild(UIRightClickPopupMenu.class);
popUp.setUIComponent(naviManager);
popUp.setShowMask(true);
popUp.setShow(true);
@@ -373,7 +381,7 @@
{
UIPageNodeForm2 uiPageNodeForm = event.getSource();
UISiteManagement uiSiteManagement =
uiPageNodeForm.getAncestorOfType(UISiteManagement.class);
- PageNavigation selectedNavigation = uiSiteManagement.getSelectedNavigation();
+ PageNavigation selectedNavigation =
uiSiteManagement.getOriginalSelectedNavigation();
UIPopupWindow uiNavigationPopup =
uiSiteManagement.getChild(UIPopupWindow.class);
UINavigationManagement pageManager =
uiPageNodeForm.createUIComponent(UINavigationManagement.class, null, null);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-04-24
17:12:00 UTC (rev 2757)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-04-26
02:16:46 UTC (rev 2758)
@@ -26,7 +26,6 @@
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.Visibility;
-import org.exoplatform.services.organization.User;
import org.exoplatform.services.resources.ResourceBundleManager;
import org.exoplatform.webui.application.WebuiRequestContext;
@@ -58,6 +57,8 @@
}
}
+ // Minh Hoang TO
+ //TODO: Rewrite this method with a better algorithm by spliting the uri
public static PageNode[] searchPageNodesByUri(PageNode node, String uri)
{
if (node.getUri().equals(uri))
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java 2010-04-24
17:12:00 UTC (rev 2757)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java 2010-04-26
02:16:46 UTC (rev 2758)
@@ -102,7 +102,7 @@
DataStorage dataService =
uiManagement.getApplicationComponent(DataStorage.class);
UserPortalConfigService portalConfigService =
uiManagement.getApplicationComponent(UserPortalConfigService.class);
- PageNavigation navigation = uiNodeSelector.getSelectedNavigation();
+ PageNavigation navigation = uiNodeSelector.getFilteredEdittedNavigation();
String editedOwnerType = navigation.getOwnerType();
String editedOwnerId = navigation.getOwnerId();
// Check existed
@@ -195,7 +195,7 @@
UIPageNodeForm2 uiNodeForm =
uiManagementPopup.createUIComponent(UIPageNodeForm2.class, null, null);
uiNodeForm.setValues(null);
uiManagementPopup.setUIComponent(uiNodeForm);
- PageNavigation nav = uiNodeSelector.getSelectedNavigation();
+ PageNavigation nav = uiNodeSelector.getFilteredEdittedNavigation();
uiNodeForm.setSelectedParent(nav);
// set owner type, owner
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java 2010-04-24
17:12:00 UTC (rev 2757)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java 2010-04-26
02:16:46 UTC (rev 2758)
@@ -50,6 +50,8 @@
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
+import groovy.util.slurpersupport.FilteredNodeChildren;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -77,9 +79,14 @@
private List<PageNavigation> navigations;
- private SelectedNode selectedNode;
+ private PageNavigation originalEdittedNavigation;
+
+ private PageNavigation filteredEdittedNavigation;
+
+ private TreeNodeData edittedTreeNodeData;
- private SelectedNode copyNode;
+ /** This field holds transient copy of edittedTreeNodeData, which is used when user
pastes the content to a new tree node */
+ private TreeNodeData copyOfTreeNodeData;
private List<PageNavigation> deleteNavigations = new
ArrayList<PageNavigation>();
@@ -108,60 +115,88 @@
return navigations;
}
+ public void setOriginalEdittedNavigation(PageNavigation _originalEdittedNavigation)
throws Exception
+ {
+ this.originalEdittedNavigation = _originalEdittedNavigation;
+ }
+
+ public PageNavigation getOriginalEdittedNavigation()
+ {
+ return this.originalEdittedNavigation;
+ }
+
+ public void setFilteredEdittedNavigation(PageNavigation _filteredEdittedNavigation)
throws Exception
+ {
+ this.filteredEdittedNavigation = _filteredEdittedNavigation;
+ }
+
+ public PageNavigation getFilteredEdittedNavigation()
+ {
+ return this.filteredEdittedNavigation;
+ }
+
public void initNavigations(List<PageNavigation> navis) throws Exception
{
navigations = navis;
WebuiRequestContext requestContext = WebuiRequestContext.getCurrentInstance();
localizeNavigation(requestContext.getLocale());
- updateNodeTree();
- initEditedData();
+ cleanTreeSibbling();
+ initEdittedTreeNodeData();
}
+
+ /**
+ * Init the UITree wrapped in UINavigationNodeSelector and localize the label
+ * @throws Exception
+ */
+ public void initTreeData() throws Exception
+ {
+ WebuiRequestContext requestContext = WebuiRequestContext.getCurrentInstance();
+ localizeNavigation(requestContext.getLocale());
+
+ cleanTreeSibbling();
+ initEdittedTreeNodeData();
+ }
public void loadNavigationByNavId(Integer navId, List<PageNavigation>
navigations) throws Exception
{
this.navigations = navigations;
- // set resolved label for navigations
WebuiRequestContext requestContext = WebuiRequestContext.getCurrentInstance();
localizeNavigation(requestContext.getLocale());
selectNavigation(navId);
}
- private void updateNodeTree()
+ private void cleanTreeSibbling()
{
- if (navigations == null || navigations.size() < 1)
+ /*
+ if (filteredEdittedNavigation == null)
{
getChild(UITree.class).setSibbling(null);
return;
}
+ */
}
/**
* Init the edited node as well as its parent, navigation
*
*/
- private void initEditedData()
+ private void initEdittedTreeNodeData()
{
- if (navigations == null || navigations.size() < 1)
+ if(filteredEdittedNavigation == null)
{
return;
}
- if (selectedNode == null)
+ if (edittedTreeNodeData == null)
{
- PageNavigation navigation = navigations.get(0);
- selectedNode = new SelectedNode(navigation, null, null);
- if (navigation.getNodes().size() > 0)
- {
- selectedNode.setNode(navigation.getNodes().get(0));
- }
+ edittedTreeNodeData = new TreeNodeData(filteredEdittedNavigation);
+ selectPageNodeByUri(edittedTreeNodeData.getNode().getUri());//TODO: Check null
}
- selectNavigation(selectedNode.getPageNavigation().getId());
- if (selectedNode.getNode() != null)
- {
- selectPageNodeByUri(selectedNode.getNode().getUri());
- }
+
+ UITree tree = getChild(UITree.class);
+ tree.setSibbling(filteredEdittedNavigation.getNodes());
}
-
+
private void selectNavigation(int id)
{
for (int i = 0; i < navigations.size(); i++)
@@ -170,7 +205,7 @@
{
continue;
}
- selectedNode = new SelectedNode(navigations.get(i), null, null);
+ edittedTreeNodeData = new TreeNodeData(navigations.get(i), null, null);
selectPageNodeByUri(null);
UITree uiTree = getChild(UITree.class);
uiTree.setSibbling(navigations.get(i).getNodes());
@@ -181,20 +216,17 @@
{
LocaleConfig localeConfig =
getApplicationComponent(LocaleConfigService.class).getLocaleConfig(locale.getLanguage());
- for (PageNavigation nav : navigations)
+ String ownerType = filteredEdittedNavigation.getOwnerType();
+ if (!PortalConfig.USER_TYPE.equals(ownerType))
{
- if (nav.getOwnerType().equals(PortalConfig.USER_TYPE))
+ String ownerId = filteredEdittedNavigation.getOwnerId();
+ if (PortalConfig.GROUP_TYPE.equals(ownerType))
{
- continue;
- }
- String ownerId = nav.getOwnerId();
- if (nav.getOwnerType().equals(PortalConfig.GROUP_TYPE))
- {
// Remove the trailing '/' for a group
ownerId = ownerId.substring(1);
}
- ResourceBundle res =
localeConfig.getNavigationResourceBundle(nav.getOwnerType(), ownerId);
- for (PageNode node : nav.getNodes())
+ ResourceBundle res = localeConfig.getNavigationResourceBundle(ownerType,
ownerId);
+ for (PageNode node : filteredEdittedNavigation.getNodes())
{
resolveLabel(res, node);
}
@@ -216,7 +248,7 @@
public void selectPageNodeByUri(String uri)
{
- if (selectedNode == null)
+ if (edittedTreeNodeData == null)
{
return;
}
@@ -224,11 +256,11 @@
List<?> sibbling = tree.getSibbling();
tree.setSibbling(null);
tree.setParentSelected(null);
- selectedNode.setNode(searchPageNodeByUri(selectedNode.getPageNavigation(), uri));
- if (selectedNode.getNode() != null)
+
edittedTreeNodeData.setNode(searchPageNodeByUri(edittedTreeNodeData.getPageNavigation(),
uri));
+ if (edittedTreeNodeData.getNode() != null)
{
- tree.setSelected(selectedNode.getNode());
- tree.setChildren(selectedNode.getNode().getChildren());
+ tree.setSelected(edittedTreeNodeData.getNode());
+ tree.setChildren(edittedTreeNodeData.getNode().getChildren());
return;
}
tree.setSelected(null);
@@ -286,7 +318,7 @@
{
tree.setParentSelected(pageNode);
}
- selectedNode.setParentNode(pageNode);
+ edittedTreeNodeData.setParentNode(pageNode);
return returnPageNode;
}
return null;
@@ -294,11 +326,9 @@
public List<PageNavigation> getPageNavigations()
{
- if (navigations == null)
- {
- navigations = new ArrayList<PageNavigation>();
- }
- return navigations;
+ List<PageNavigation> navs = new ArrayList<PageNavigation>(3);
+ navs.add(filteredEdittedNavigation);
+ return navs;
}
public void addPageNavigation(PageNavigation navigation)
@@ -308,7 +338,7 @@
navigations = new ArrayList<PageNavigation>();
}
navigations.add(navigation);
- updateNodeTree();
+ cleanTreeSibbling();
}
public void deletePageNavigation(PageNavigation navigation)
@@ -319,9 +349,9 @@
}
navigations.remove(navigation);
deleteNavigations.add(navigation);
- selectedNode = null;
- initEditedData();
- updateNodeTree();
+ edittedTreeNodeData = null;
+ initEdittedTreeNodeData();
+ cleanTreeSibbling();
}
public PageNavigation getPageNavigation(int id)
@@ -341,7 +371,7 @@
UIRightClickPopupMenu uiPopupMenu = getChild(UIRightClickPopupMenu.class);
if (uiPopupMenu != null)
{
- if (navigations == null || navigations.size() < 1)
+ if (filteredEdittedNavigation == null)
{
uiPopupMenu.setRendered(false);
}
@@ -353,14 +383,14 @@
super.processRender(context);
}
- public SelectedNode getCopyNode()
+ public TreeNodeData getCopyNode()
{
- return copyNode;
+ return copyOfTreeNodeData;
}
- public void setCopyNode(SelectedNode copyNode)
+ public void setCopyNode(TreeNodeData copyNode)
{
- this.copyNode = copyNode;
+ this.copyOfTreeNodeData = copyNode;
}
static public class ChangeNodeActionListener extends EventListener<UITree>
@@ -394,7 +424,8 @@
uiManagementPopup.setUIComponent(uiNodeForm);
Object parent = null;
- List<PageNode> pageNodes =
uiNodeSelector.getSelectedNavigation().getNodes();
+ PageNavigation filteredEdittedNavigation =
uiNodeSelector.getFilteredEdittedNavigation();
+ List<PageNode> pageNodes = filteredEdittedNavigation.getNodes();
if (uri != null && uri.trim().length() > 0)
{
for (PageNode pageNode : pageNodes)
@@ -408,13 +439,14 @@
}
if (parent == null)
{
- parent = uiNodeSelector.getSelectedNavigation();
+ parent = filteredEdittedNavigation;
}
+
uiNodeForm.setSelectedParent(parent);
// set navigation owner, navigation type
- uiNodeForm.setOwner(uiNodeSelector.getSelectedNavigation().getOwnerId());
- uiNodeForm.setOwnerType(uiNodeSelector.getSelectedNavigation().getOwnerType());
+
uiNodeForm.setOwner(uiNodeSelector.getFilteredEdittedNavigation().getOwnerId());
+
uiNodeForm.setOwnerType(uiNodeSelector.getFilteredEdittedNavigation().getOwnerType());
uiManagementPopup.setWindowSize(800, 500);
event.getRequestContext().addUIComponentToUpdateByAjax(uiManagementPopup.getParent());
@@ -435,7 +467,7 @@
// get Selected PageNode
PageNode selectedPageNode = null;
- List<PageNode> pageNodes =
uiNodeSelector.getSelectedNavigation().getNodes();
+ List<PageNode> pageNodes =
uiNodeSelector.getFilteredEdittedNavigation().getNodes();
if (uri != null && uri.trim().length() > 0)
{
for (PageNode pageNode : pageNodes)
@@ -517,7 +549,7 @@
UIApplication uiApp = ctx.getUIApplication();
String uri =
event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
UINavigationNodeSelector uiNodeSelector =
popupMenu.getAncestorOfType(UINavigationNodeSelector.class);
- PageNavigation selectedNav = uiNodeSelector.getSelectedNavigation();
+ PageNavigation selectedNav = uiNodeSelector.getFilteredEdittedNavigation();
Object obj = PageNavigationUtils.searchParentNode(selectedNav, uri);
PageNode selectedNode = PageNavigationUtils.searchPageNodeByUri(selectedNav,
uri);
String pageId = selectedNode.getPageReference();
@@ -538,8 +570,8 @@
uiManagementPopup.setUIComponent(uiNodeForm);
// set navigation owner, navigation type
- uiNodeForm.setOwner(uiNodeSelector.getSelectedNavigation().getOwnerId());
- uiNodeForm.setOwnerType(uiNodeSelector.getSelectedNavigation().getOwnerType());
+
uiNodeForm.setOwner(uiNodeSelector.getFilteredEdittedNavigation().getOwnerId());
+
uiNodeForm.setOwnerType(uiNodeSelector.getFilteredEdittedNavigation().getOwnerType());
uiNodeForm.setValues(selectedNode);
uiNodeForm.setSelectedParent(obj);
@@ -559,7 +591,7 @@
uiManagement.setRenderedChildrenOfTypes(childrenToRender);
event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
- PageNavigation nav = uiNodeSelector.getSelectedNavigation();
+ PageNavigation nav = uiNodeSelector.getFilteredEdittedNavigation();
if (nav == null)
{
return;
@@ -569,7 +601,7 @@
{
return;
}
- SelectedNode selectedNode = new SelectedNode(nav, pageNodes[0], pageNodes[1]);
+ TreeNodeData selectedNode = new TreeNodeData(nav, pageNodes[0], pageNodes[1]);
selectedNode.setDeleteNode(false);
uiNodeSelector.setCopyNode(selectedNode);
event.getSource().setActions(
@@ -591,7 +623,7 @@
uiManagement.setRenderedChildrenOfTypes(childrenToRender);
event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
- PageNavigation nav = uiNodeSelector.getSelectedNavigation();
+ PageNavigation nav = uiNodeSelector.getFilteredEdittedNavigation();
if (nav == null)
{
return;
@@ -610,7 +642,7 @@
}
}
- SelectedNode selectedNode = new SelectedNode(nav, pageNodes[0], pageNodes[1]);
+ TreeNodeData selectedNode = new TreeNodeData(nav, pageNodes[0], pageNodes[1]);
selectedNode.setDeleteNode(false);
uiNodeSelector.setCopyNode(selectedNode);
event.getSource().setActions(
@@ -646,14 +678,14 @@
Class<?>[] childrenToRender = new
Class<?>[]{UINavigationNodeSelector.class};
uiManagement.setRenderedChildrenOfTypes(childrenToRender);
event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
- SelectedNode selectedNode = uiNodeSelector.getCopyNode();
+ TreeNodeData selectedNode = uiNodeSelector.getCopyNode();
if (selectedNode == null)
{
return;
}
PageNode newNode = selectedNode.getNode().clone();
- PageNavigation targetNav = uiNodeSelector.getSelectedNavigation();
+ PageNavigation targetNav = uiNodeSelector.getFilteredEdittedNavigation();
PageNode targetNode = PageNavigationUtils.searchPageNodeByUri(targetNav,
targetUri);
if (targetNode != null && newNode.getUri().equals(targetNode.getUri()))
@@ -798,7 +830,7 @@
String uri =
event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
UINavigationNodeSelector uiNodeSelector =
event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
event.getRequestContext().addUIComponentToUpdateByAjax(uiNodeSelector.getParent());
- PageNavigation nav = uiNodeSelector.getSelectedNavigation();
+ PageNavigation nav = uiNodeSelector.getFilteredEdittedNavigation();
PageNode targetNode = PageNavigationUtils.searchPageNodeByUri(nav, uri);
Object parentNode = PageNavigationUtils.searchParentNode(nav, uri);
List<PageNode> children = new ArrayList<PageNode>();
@@ -846,7 +878,7 @@
UINavigationNodeSelector uiNodeSelector =
event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
pcontext.addUIComponentToUpdateByAjax(uiNodeSelector);
- PageNavigation nav = uiNodeSelector.getSelectedNavigation();
+ PageNavigation nav = uiNodeSelector.getFilteredEdittedNavigation();
if (nav == null)
{
return;
@@ -880,24 +912,24 @@
}
}
- public SelectedNode getSelectedNode()
+ public TreeNodeData getSelectedNode()
{
- return selectedNode;
+ return edittedTreeNodeData;
}
public PageNavigation getSelectedNavigation()
{
- return selectedNode == null ? null : selectedNode.getPageNavigation();
+ return edittedTreeNodeData == null ? null :
edittedTreeNodeData.getPageNavigation();
}
public PageNode getSelectedPageNode()
{
- return selectedNode == null ? null : selectedNode.getNode();
+ return edittedTreeNodeData == null ? null : edittedTreeNodeData.getNode();
}
public String getUpLevelUri()
{
- return selectedNode.getParentNode().getUri();
+ return edittedTreeNodeData.getParentNode().getUri();
}
public List<PageNavigation> getDeleteNavigations()
@@ -905,7 +937,15 @@
return deleteNavigations;
}
- public static class SelectedNode
+ /**
+ * This class encapsulate data bound to an editted tree node. It consists of a page
node (to be added,
+ * removed, moved) its parent node and its navigation
+ *
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @version $Id$
+ *
+ */
+ public static class TreeNodeData
{
private PageNavigation nav;
@@ -918,12 +958,22 @@
private boolean cloneNode = false;
- public SelectedNode(PageNavigation nav, PageNode parentNode, PageNode node)
+ public TreeNodeData(PageNavigation nav, PageNode parentNode, PageNode node)
{
this.nav = nav;
this.parentNode = parentNode;
this.node = node;
}
+
+ public TreeNodeData(PageNavigation nav)
+ {
+ this.nav = nav;
+ List<PageNode> children = nav.getNodes();
+ if(children != null && children.size() > 0)
+ {
+ this.node = children.get(0);
+ }
+ }
public PageNavigation getPageNavigation()
{