Author: mwringe
Date: 2011-10-19 22:10:20 -0400 (Wed, 19 Oct 2011)
New Revision: 7793
Modified:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationNodeSelector.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPortalNavigationPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
Log:
JBEPP-1238: use portlet preferences of 'level' on UIPortalNavigationPortlet and
UIGroupNavigationPortlet to set the level of nodes used in UINavigationNodeSelector.
Modified:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2011-10-19
18:36:52 UTC (rev 7792)
+++
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2011-10-20
02:10:20 UTC (rev 7793)
@@ -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:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationPortlet.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationPortlet.java 2011-10-19
18:36:52 UTC (rev 7792)
+++
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationPortlet.java 2011-10-20
02:10:20 UTC (rev 7793)
@@ -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:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationNodeSelector.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationNodeSelector.java 2011-10-19
18:36:52 UTC (rev 7792)
+++
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationNodeSelector.java 2011-10-20
02:10:20 UTC (rev 7793)
@@ -44,6 +44,8 @@
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.portal.webui.workspace.UIPortalToolPanel;
import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -102,7 +104,8 @@
private Map<String, Map<Locale, State>> userNodeLabels;
- private static final Scope NODE_SCOPE = Scope.GRANDCHILDREN;
+ private static final Scope DEFAULT_SCOPE = Scope.GRANDCHILDREN;
+ private Scope navigationScope = DEFAULT_SCOPE;
public UINavigationNodeSelector() throws Exception
{
@@ -152,12 +155,12 @@
try
{
this.rootNode =
- new TreeNode(edittedNavigation, userPortal.getNode(edittedNavigation,
NODE_SCOPE, filterConfig, null));
+ new TreeNode(edittedNavigation, userPortal.getNode(edittedNavigation,
navigationScope, filterConfig, null));
TreeNode node = this.rootNode;
if (this.rootNode.getChildren().size() > 0)
{
- node = rebaseNode(this.rootNode.getChild(0), NODE_SCOPE);
+ node = rebaseNode(this.rootNode.getChild(0), navigationScope);
if (node == null)
{
initTreeData();
@@ -305,6 +308,16 @@
return getRootNode().findNode(nodeID);
}
+ public void setScope(Scope scope)
+ {
+ this.navigationScope = scope;
+ }
+
+ public Scope getScope()
+ {
+ return this.navigationScope;
+ }
+
private void invokeI18NizedLabels(TreeNode node)
{
DescriptionService descriptionService =
this.getApplicationComponent(DescriptionService.class);
@@ -324,7 +337,7 @@
{
protected TreeNode rebaseNode(TreeNode node, UINavigationNodeSelector selector)
throws Exception
{
- return rebaseNode(node, UINavigationNodeSelector.NODE_SCOPE, selector);
+ return rebaseNode(node, selector.getScope(), selector);
}
protected TreeNode rebaseNode(TreeNode node, Scope scope, UINavigationNodeSelector
selector) throws Exception
Modified:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPortalNavigationPortlet.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPortalNavigationPortlet.java 2011-10-19
18:36:52 UTC (rev 7792)
+++
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPortalNavigationPortlet.java 2011-10-20
02:10:20 UTC (rev 7793)
@@ -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 UIPortalNavigationPortlet extends UIPortletApplication
{
+ public static final int DEFAULT_LEVEL = 2;
+
public UIPortalNavigationPortlet() throws Exception
{
- addChild(UISiteManagement.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");
+ }
+
+ UISiteManagement siteManagement = addChild(UISiteManagement.class, null, null);
+ if (level <= 0)
+ {
+ siteManagement.setScope(Scope.ALL);
+ }
+ else
+ {
+ siteManagement.setScope(GenericScope.treeShape(level));
+ }
}
}
\ No newline at end of file
Modified:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2011-10-19
18:36:52 UTC (rev 7792)
+++
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2011-10-20
02:10:20 UTC (rev 7793)
@@ -30,6 +30,7 @@
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
+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.page.UISiteBody;
@@ -88,6 +89,9 @@
private LazyPageList<PortalConfig> pageList;
private UINavigationManagement naviManager;
+
+ //set navigationScope to GrandChildren for default value
+ private Scope navigationScope = Scope.GRANDCHILDREN;
public UISiteManagement() throws Exception
{
@@ -184,6 +188,16 @@
}, 10);
}
+
+ public void setScope(Scope scope)
+ {
+ this.navigationScope = scope;
+ }
+
+ public Scope getScope()
+ {
+ return this.navigationScope;
+ }
private boolean stillKeptInPageList(String portalName) throws Exception {
List<PortalConfig> portals = this.getPortalConfigs();
@@ -387,6 +401,7 @@
UserNavigation edittedNavigation =
userPortal.getNavigation(SiteKey.portal(portalName));
UINavigationNodeSelector selector =
naviManager.getChild(UINavigationNodeSelector.class);
+ selector.setScope(uicomp.getScope());
selector.setEdittedNavigation(edittedNavigation);
selector.setUserPortal(userPortal);
selector.initTreeData();
@@ -408,6 +423,7 @@
UINavigationNodeSelector selector =
navigationManager.getChild(UINavigationNodeSelector.class);
TreeNode selectedParent = (TreeNode)uiPageNodeForm.getSelectedParent();
+ selector.setScope(uiSiteManagement.getScope());
selector.selectNode(selectedParent);
WebuiRequestContext context = event.getRequestContext();
Modified:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2011-10-19
18:36:52 UTC (rev 7792)
+++
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2011-10-20
02:10:20 UTC (rev 7793)
@@ -140,6 +140,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>
@@ -169,6 +175,14 @@
<short-title>Portal Navigation Portlet</short-title>
<keywords>System</keywords>
</portlet-info>
+
+ <portlet-preferences>
+ <preference>
+ <name>level</name>
+ <value>2</value>
+ </preference>
+ </portlet-preferences>
+
</portlet>
<portlet>