Author: mwringe
Date: 2011-10-18 16:54:37 -0400 (Tue, 18 Oct 2011)
New Revision: 7767
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/UIGroupNavigationPortlet.java
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
Log:
GTNPORTAL-2140: Also add scope level support to UIGroupNavigationPortlet through a portlet
preferences, this will also be passed to the UINavigationNodeSelector.
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 2011-10-18
18:21:29 UTC (rev 7766)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2011-10-18
20:54:37 UTC (rev 7767)
@@ -27,6 +27,7 @@
import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.navigation.NavigationContext;
import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserPortal;
import org.exoplatform.portal.webui.navigation.UIAddGroupNavigation;
@@ -84,6 +85,9 @@
{
private UINavigationManagement naviManager;
+
+ //set navigationScope to GrandChildren for default value
+ private Scope navigationScope = Scope.GRANDCHILDREN;
public UIGroupNavigationManagement() throws Exception
{
@@ -113,6 +117,16 @@
virtualList.dataBind(new ObjectPageList<UserNavigation>(groupNav,
groupNav.size()));
}
+ public void setScope(Scope scope)
+ {
+ this.navigationScope = scope;
+ }
+
+ public Scope getScope()
+ {
+ return this.navigationScope;
+ }
+
/**
* User has right to add navigation to a group in below cases
*
@@ -205,6 +219,7 @@
UINavigationNodeSelector selector =
naviManager.getChild(UINavigationNodeSelector.class);
selector.setEdittedNavigation(nav);
selector.setUserPortal(userPortal);
+ selector.setScope(uicomp.getScope());
selector.initTreeData();
popUp.setUIComponent(naviManager);
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationPortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationPortlet.java 2011-10-18
18:21:29 UTC (rev 7766)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationPortlet.java 2011-10-18
20:54:37 UTC (rev 7767)
@@ -19,6 +19,13 @@
package org.exoplatform.navigation.webui.component;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+
+import org.exoplatform.portal.mop.navigation.GenericScope;
+import org.exoplatform.portal.mop.navigation.Scope;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.core.UIPortletApplication;
import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
@@ -26,8 +33,31 @@
@ComponentConfig(lifecycle = UIApplicationLifecycle.class)
public class UIGroupNavigationPortlet extends UIPortletApplication
{
+ public static final int DEFAULT_LEVEL = 2;
+
public UIGroupNavigationPortlet() throws Exception
{
- addChild(UIGroupNavigationManagement.class, null, null);
+ PortletRequestContext context =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance();
+ PortletRequest prequest = context.getRequest();
+ PortletPreferences prefers = prequest.getPreferences();
+ int level = DEFAULT_LEVEL;
+ try
+ {
+ level = Integer.valueOf(prefers.getValue("level",
String.valueOf(DEFAULT_LEVEL)));
+ }
+ catch (Exception ex)
+ {
+ log.warn("Preference for navigation level can only be integer");
+ }
+
+ UIGroupNavigationManagement groupNavigationManagement =
addChild(UIGroupNavigationManagement.class, null, null);
+ if (level <= 0)
+ {
+ groupNavigationManagement.setScope(Scope.ALL);
+ }
+ else
+ {
+ groupNavigationManagement.setScope(GenericScope.treeShape(level));
+ }
}
}
\ No newline at end of file
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2011-10-18 18:21:29
UTC (rev 7766)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2011-10-18 20:54:37
UTC (rev 7767)
@@ -143,6 +143,12 @@
<short-title>Group Navigation Portlet</short-title>
<keywords>Administration</keywords>
</portlet-info>
+ <portlet-preferences>
+ <preference>
+ <name>level</name>
+ <value>2</value>
+ </preference>
+ </portlet-preferences>
<supported-publishing-event>
<name>NavigationChange</name>
</supported-publishing-event>