Author: hoang_to
Date: 2010-01-28 05:09:29 -0500 (Thu, 28 Jan 2010)
New Revision: 1457
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/SiteConfig.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.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/UIPortalNavigation.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
Log:
GTNPORTAL-540: Create multiple UIPortal object within a session
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -31,6 +31,9 @@
private PortalConfig portal;
private List<PageNavigation> navigations;
+
+ /** Added by Minh Hoang TO */
+ private PageNavigation selectedNavigation;
public UserPortalConfig()
{
@@ -52,7 +55,21 @@
{
this.portal = portal;
}
+
+ public void setSelectedNavigation(PageNavigation _selectedNavigation)
+ {
+ this.selectedNavigation = _selectedNavigation;
+ }
+ public PageNavigation getSelectedNavigation()
+ {
+ if(this.selectedNavigation != null)
+ {
+ return this.selectedNavigation;
+ }
+ return navigations.get(0);
+ }
+
public void setNavigations(List<PageNavigation> navs)
{
navigations = navs;
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/SiteConfig.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/SiteConfig.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/SiteConfig.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -0,0 +1,40 @@
+package org.exoplatform.portal.config.model;
+
+import org.exoplatform.portal.pom.data.ModelData;
+
+/**
+ *
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @version $Id$
+ *
+ */
+public class SiteConfig extends ModelObject
+{
+
+ private String ownerType;
+
+ private String ownerId;
+
+ private Container layout;
+
+ private PageNavigation navigation;
+
+ private String[] accessPermissions;
+
+ private String editPermission;
+
+ public SiteConfig(String _ownerType, String _ownerId, String storageId)
+ {
+ super(storageId);
+ this.ownerType = _ownerType;
+ this.ownerId = _ownerId;
+ }
+
+ @Override
+ public ModelData build()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Modified:
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java
===================================================================
---
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -24,7 +24,6 @@
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.page.UIPageBody;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
@@ -87,10 +86,13 @@
private void initPageNavigation() throws Exception
{
- String remoteUser = Util.getPortalRequestContext().getRemoteUser();
- pageNavigation = getPageNavigation(PortalConfig.USER_TYPE + "::" +
remoteUser);
+ //String remoteUser = Util.getPortalRequestContext().getRemoteUser();
+ //pageNavigation = getPageNavigation(PortalConfig.USER_TYPE + "::" +
remoteUser);
+ //TODO: Check this part carefully
+ this.pageNavigation = uiPortal.getSelectedNavigation();
}
+ /*
private PageNavigation getPageNavigation(String owner) throws Exception
{
List<PageNavigation> allNavigations = uiPortal.getNavigations();
@@ -102,6 +104,8 @@
return null;
}
+ */
+
public int getCurrentNumberOfTabs() throws Exception
{
@@ -128,7 +132,7 @@
public List<PageNode> getSameSiblingsNode() throws Exception
{
List<PageNode> siblings = getPageNavigation().getNodes();
- List<PageNode> selectedPath = Util.getUIPortal().getSelectedPaths();
+ List<PageNode> selectedPath = Util.getUIPortal().getSelectedPath();
if (selectedPath != null && selectedPath.size() > 1)
{
PageNode currentParent = selectedPath.get(selectedPath.size() - 2);
@@ -223,7 +227,7 @@
pageNavigation.getOwnerId());
page.setTitle(nodeLabel);
- List<PageNode> selectedPath = uiPortal.getSelectedPaths();
+ List<PageNode> selectedPath = uiPortal.getSelectedPath();
PageNode parentNode = null;
if (selectedPath != null && selectedPath.size() > 1)
{
@@ -308,7 +312,7 @@
try
{
List<PageNode> nodes = pageNavigation.getNodes();
- List<PageNode> selectedPath = uiPortal.getSelectedPaths();
+ List<PageNode> selectedPath = uiPortal.getSelectedPath();
PageNode parentNode = null;
if (selectedPath != null && selectedPath.size() > 1)
{
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-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -289,7 +289,7 @@
{
editPortal.setSelectedNode(uiPortal.getSelectedNode());
editPortal.setSelectedNavigation(uiPortal.getSelectedNavigation());
- editPortal.setSelectedPaths(uiPortal.getSelectedPaths());
+ editPortal.setSelectedPath(uiPortal.getSelectedPath());
UISiteBody siteBody =
uiWorkingWS.findFirstComponentOfType(UISiteBody.class);
siteBody.setUIComponent(null);
}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -47,12 +47,16 @@
public PageNavigation getSelectedNavigation() throws Exception
{
+ return Util.getUIPortal().getSelectedNavigation();
+
+ /*
PageNavigation nav = Util.getUIPortal().getSelectedNavigation();
if (nav != null)
return nav;
if (Util.getUIPortal().getNavigations().size() < 1)
return null;
return Util.getUIPortal().getNavigations().get(0);
+ */
}
@Override
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -62,7 +62,8 @@
private PageNavigation getPageNavigation(String owner) throws Exception
{
- List<PageNavigation> allNavigations = Util.getUIPortal().getNavigations();
+ //List<PageNavigation> allNavigations = Util.getUIPortal().getNavigations();
+ List<PageNavigation> allNavigations =
Util.getUIPortalApplication().getNavigations();
for (PageNavigation nav : allNavigations)
{
if (nav.getOwner().equals(owner))
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -48,7 +48,8 @@
public List<PageNavigation> getGroupNavigations() throws Exception
{
String remoteUser = Util.getPortalRequestContext().getRemoteUser();
- List<PageNavigation> allNavigations = Util.getUIPortal().getNavigations();
+ //List<PageNavigation> allNavigations = Util.getUIPortal().getNavigations();
+ List<PageNavigation> allNavigations =
Util.getUIPortalApplication().getNavigations();
List<PageNavigation> navigations = new ArrayList<PageNavigation>();
for (PageNavigation navigation : allNavigations)
{
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -72,7 +72,8 @@
private PageNavigation getPageNavigation(String owner) throws Exception
{
- List<PageNavigation> allNavigations = Util.getUIPortal().getNavigations();
+ //List<PageNavigation> allNavigations = Util.getUIPortal().getNavigations();
+ List<PageNavigation> allNavigations =
Util.getUIPortalApplication().getUserPortalConfig().getNavigations();
for (PageNavigation nav : allNavigations)
{
if (nav.getOwner().equals(owner))
Modified:
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java
===================================================================
---
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -64,7 +64,7 @@
public void loadSelectedPath()
{
- List<PageNode> nodes = Util.getUIPortal().getSelectedPaths();
+ List<PageNode> nodes = Util.getUIPortal().getSelectedPath();
List<LocalPath> paths = new ArrayList<LocalPath>();
for (PageNode node : nodes)
{
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-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -23,10 +23,14 @@
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.services.resources.ResourceBundleManager;
import org.exoplatform.webui.application.WebuiRequestContext;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
/**
* Created by The eXo Platform SARL
@@ -173,4 +177,26 @@
return null;
return copyNode;
}
+
+ public static void localizePageNavigation(PageNavigation nav,Locale locale,
ResourceBundleManager i18nManager)
+ {
+ if (nav.getOwnerType().equals(PortalConfig.USER_TYPE))
+ return;
+ ResourceBundle res = i18nManager.getNavigationResourceBundle(locale.getLanguage(),
nav.getOwnerType(), nav.getOwnerId());
+ for (PageNode node : nav.getNodes())
+ {
+ resolveLabel(res, node);
+ }
+ }
+
+ private static void resolveLabel(ResourceBundle res, PageNode node)
+ {
+ node.setResolvedLabel(res);
+ if (node.getChildren() == null)
+ return;
+ for (PageNode childNode : node.getChildren())
+ {
+ resolveLabel(res, childNode);
+ }
+ }
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -125,7 +125,7 @@
{
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
treeNode_ = new TreeNode(new PageNode(), new PageNavigation(), true);
- for (PageNavigation nav : Util.getUIPortal().getNavigations())
+ for (PageNavigation nav : Util.getUIPortalApplication().getNavigations())
{
if (!showUserNavigation && nav.getOwnerType().equals("user"))
{
@@ -224,7 +224,8 @@
else
{
String navId = uri.substring(0, index);
- selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+ //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+ selectNav = uiPortal.getSelectedNavigation();
}
PageNode selectNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
uiNavigation.selectedNode_ = selectNode;
@@ -271,8 +272,11 @@
PageNavigation selectNav = null;
String navId = uri.substring(0, index);
- selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
-
+
+ //TODO: Minh Hoang TO
+ //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+ selectNav = uiPortal.getSelectedNavigation();
+
// get PageNode by uri
PageNode expandNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
@@ -307,8 +311,11 @@
PageNavigation selectNav = null;
String navId = uri.substring(0, index);
- selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
-
+
+ //TODO: Minh Hoang TO
+ //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+ selectNav = uiPortal.getSelectedNavigation();
+
// get PageNode by uri
PageNode expandNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -162,7 +162,10 @@
else
{
String navId = uri.substring(0, index);
- selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+
+ //TODO: Minh Hoang TO
+ //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+ selectNav = uiPortal.getSelectedNavigation();
}
PageNode selectNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
uiNavigation.selectedNode_ = selectNode;
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -57,285 +57,254 @@
static public class ChangePageNodeActionListener extends
EventListener<UIPortal>
{
+ @Override
public void execute(Event<UIPortal> event) throws Exception
{
- PageNodeEvent<UIPortal> pnevent = (PageNodeEvent<UIPortal>)event;
- UIPortal uiPortal = pnevent.getSource();
- UIPageBody uiPageBody = uiPortal.findFirstComponentOfType(UIPageBody.class);
- UIPortalApplication uiPortalApp =
uiPortal.getAncestorOfType(UIPortalApplication.class);
- if (uiPortalApp.getModeState() != UIPortalApplication.NORMAL_MODE)
- {
- UserPortalConfigService configService =
uiPortalApp.getApplicationComponent(UserPortalConfigService.class);
- String remoteUser = Util.getPortalRequestContext().getRemoteUser();
- UserPortalConfig portalConfig =
-
configService.getUserPortalConfig(Util.getPortalRequestContext().getPortalOwner(),
remoteUser);
- uiPortal.getChildren().clear();
- PortalDataMapper.toUIPortal(uiPortal, portalConfig);
- uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
- uiPortal.broadcast(event, event.getExecutionPhase());
- return;
- }
+ UIPortal showedUIPortal = event.getSource();
+ UIPortalApplication uiPortalApp =
showedUIPortal.getAncestorOfType(UIPortalApplication.class);
+
+ //This code snippet is to make sure that Javascript/Skin is fully loaded at the
first request
UIWorkingWorkspace uiWorkingWS =
uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
PortalRequestContext pcontext = Util.getPortalRequestContext();
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
pcontext.setFullRender(true);
-
- String currentUri = (uiPortal.getSelectedNode() == null) ? null :
uiPortal.getSelectedNode().getUri();
- PageNavigation currentNav = uiPortal.getSelectedNavigation();
-
- uiPortal.setSelectedNavigation(null);
- uiPortal.setSelectedNode(null);
- List<PageNode> selectedPaths_ = new ArrayList<PageNode>(5);
-
- List<PageNavigation> navigations = uiPortal.getNavigations();
- String uri = pnevent.getTargetNodeUri();
- if (uri == null || (uri = uri.trim()).length() < 1)
+
+ PageNavigation currentNav = showedUIPortal.getSelectedNavigation();
+ String currentUri = showedUIPortal.getSelectedNode().getUri();
+ if(currentUri.startsWith("/"))
{
- return;
+ currentUri = currentUri.substring(1);
}
- if (uri.length() == 1 && uri.charAt(0) == '/')
+
+ //This if branche is to make sure that the first time user logs in,
showedUIPortal has selectedPaths
+ //Otherwise, there will be NPE on BreadcumbsPortlet
+ if(showedUIPortal.getSelectedPath() == null)
{
- for (PageNavigation nav : navigations)
- {
- for (PageNode child : nav.getNodes())
- {
- if (PageNavigationUtils.filter(child, pcontext.getRemoteUser()) !=
null)
- {
- selectedPaths_.add(child);
- uiPortal.setSelectedNode(child);
- uiPortal.setSelectedPaths(selectedPaths_);
- String selectedUri =
- (uiPortal.getSelectedNode() == null) ? null :
uiPortal.getSelectedNode().getUri();
-
- if (!currentUri.equals(selectedUri))
- {
- updateLayout(uiPortal, currentNav,
uiPortal.getSelectedNavigation(), uiPortalApp);
- uiPageBody =
uiPortal.findFirstComponentOfType(UIPageBody.class);
- if (uiPageBody.getMaximizedUIComponent() != null)
- {
- UIPortlet currentPortlet =
(UIPortlet)uiPageBody.getMaximizedUIComponent();
- currentPortlet.setCurrentWindowState(WindowState.NORMAL);
- uiPageBody.setMaximizedUIComponent(null);
- }
- }
- uiPageBody.setPageBody(uiPortal.getSelectedNode(), uiPortal);
- return;
- }
- }
- }
+ List<PageNode> currentSelectedPath = findPath(currentNav,
currentUri.split("/"));
+ showedUIPortal.setSelectedPath(currentSelectedPath);
}
- if (uri.charAt(0) == '/')
+
+ String targetedUri = ((PageNodeEvent<UIPortal>)event).getTargetNodeUri();
+ if(targetedUri.startsWith("/"))
{
- uri = uri.substring(1);
+ targetedUri = targetedUri.substring(1);
}
-
- int idx = uri.lastIndexOf("::");
- if (idx < 0)
+
+ PageNavigation targetedNav = getTargetedNav(uiPortalApp, targetedUri);
+
+ if(targetedNav == null)
{
- PageNode selectedNode = null;
- for (PageNavigation nav : navigations)
+ return;
+ }
+
+ String formerNavType = currentNav.getOwnerType();
+ String formerNavId = currentNav.getOwnerId();
+ String newNavType = targetedNav.getOwnerType();
+ String newNavId = targetedNav.getOwnerId();
+
+ String[] targetPath = targetedUri.split("/");
+ PageNode targetPageNode = getTargetedNode(targetedNav, targetPath);
+ List<PageNode> targetedPathNodes = findPath(targetedNav, targetPath);
+
+ if(formerNavType.equals(newNavType) && formerNavId.equals(newNavId))
+ {
+ //Case 1: Both navigation type and id are not changed, but current page node
is changed
+ if(!currentUri.equals(targetedUri))
{
- String[] nodeNames = uri.split("/");
- int i = 0;
- PageNode tempNode = nav.getNode(nodeNames[i]);
- selectedNode = tempNode;
- while (tempNode != null && ++i < nodeNames.length)
- {
- selectedPaths_.add(selectedNode = tempNode);
- tempNode = tempNode.getChild(nodeNames[i]);
- }
- if (tempNode != null)
- {
- selectedPaths_.add(selectedNode = tempNode);
- }
-
- if (selectedNode != null)
- {
- uiPortal.setSelectedNavigation(nav);
- break;
- }
+ showedUIPortal.setSelectedNode(targetPageNode);
+ showedUIPortal.setSelectedPath(targetedPathNodes);
+ showedUIPortal.refreshUIPage();
+ return;
}
- // TODO tam.nguyen: filter navigation, select navigation up to user
- if (selectedNode == null)
+ }
+ else
+ {
+ // Case 2: Either navigation type or id has been changed
+ // First, we try to find a cached UIPortal
+ UIPortal cachedUIPortal = uiPortalApp.getCachedUIPortal(newNavType,
newNavId);
+ if (cachedUIPortal != null)
{
- filter : for (PageNavigation nav : navigations)
- {
- for (PageNode child : nav.getNodes())
- {
- if (PageNavigationUtils.filter(child, pcontext.getRemoteUser()) !=
null)
- {
- selectedNode = child;
- break filter;
- }
- }
- }
+ System.out.println("Found UIPortal with OWNERTYPE: " +
newNavType + " OWNERID " + newNavId);
+ cachedUIPortal.setSelectedNode(targetPageNode);
+ cachedUIPortal.setSelectedPath(targetedPathNodes);
+ uiPortalApp.setShowedUIPortal(cachedUIPortal);
+ cachedUIPortal.refreshUIPage();
+ return;
}
- uiPortal.setSelectedNode(selectedNode);
- if (selectedNode == null)
+ else
{
- selectedPaths_.add(uiPortal.getSelectedNode());
- }
- uiPortal.setSelectedPaths(selectedPaths_);
- String selectedUri = (uiPortal.getSelectedNode() == null) ? null :
uiPortal.getSelectedNode().getUri();
- if (currentUri != null && !currentUri.equals(selectedUri))
- {
- updateLayout(uiPortal, currentNav, uiPortal.getSelectedNavigation(),
uiPortalApp);
- uiPageBody = uiPortal.findFirstComponentOfType(UIPageBody.class);
- if (uiPageBody.getMaximizedUIComponent() != null)
+ UIPortal newUIPortal = buildUIPortal(targetedNav, uiPortalApp,
uiPortalApp.getUserPortalConfig());
+ if(newUIPortal == null)
{
- UIPortlet currentPortlet =
(UIPortlet)uiPageBody.getMaximizedUIComponent();
- currentPortlet.setCurrentWindowState(WindowState.NORMAL);
- uiPageBody.setMaximizedUIComponent(null);
+ return;
}
+ newUIPortal.setSelectedNode(targetPageNode);
+ newUIPortal.setSelectedPath(targetedPathNodes);
+ uiPortalApp.setShowedUIPortal(newUIPortal);
+ uiPortalApp.addUIPortal(newUIPortal);
+ newUIPortal.refreshUIPage();
+ return;
}
-
- uiPageBody.setPageBody(uiPortal.getSelectedNode(), uiPortal);
- return;
}
- String navId = uri.substring(0, idx);
- uri = uri.substring(idx + 2, uri.length());
- PageNavigation nav = null;
- for (PageNavigation ele : navigations)
+ }
+
+ /**
+ * Get the targeted <code>PageNavigation</code>
+ *
+ * @param uiPortalApp
+ * @param targetedUri
+ * @return
+ */
+ private PageNavigation getTargetedNav(UIPortalApplication uiPortalApp, String
targetedUri)
+ {
+ List<PageNavigation> allNavs =
uiPortalApp.getUserPortalConfig().getNavigations();
+
+ //That happens when user browses to an empty-nodeUri URL like
../portal/public/classic/
+ //In this case, we returns default navigation
+ if(targetedUri.length() == 0)
{
- if (ele.getId() == Integer.parseInt(navId))
+ return uiPortalApp.getNavigations().get(0);
+ }
+
+ String[] pathNodes = targetedUri.split("/");
+
+ //We check the first navigation in the list containing all descendants
corresponding to pathNodes
+ for(PageNavigation nav : allNavs)
+ {
+ if(containingDescendantNodes(nav, pathNodes))
{
- nav = ele;
- break;
+ return nav;
}
}
- if (nav != null)
- {
- String[] nodeNames = uri.split("/");
- int i = 0;
- PageNode tempNode = nav.getNode(nodeNames[i]);
- PageNode selecttedNode = tempNode;
- while (tempNode != null && ++i < nodeNames.length)
+ return null;
+ }
+
+ /**
+ * Check if a given <code>PageNavigation</code> contains all the
descendants corresponding to the pathNodes
+ *
+ * @param navigation
+ * @param pathNodes
+ * @return
+ */
+ private static boolean containingDescendantNodes(PageNavigation navigation,
String[] pathNodes)
+ {
+ PageNode firstLevelNode = navigation.getNode(pathNodes[0]);
+ if(firstLevelNode == null)
+ {
+ return false;
+ }
+
+ //Recursive code snippet with two variables
+ PageNode tempNode = firstLevelNode;
+ PageNode currentNode;
+
+ for(int i = 1; i < pathNodes.length; i++)
+ {
+ currentNode = tempNode.getChild(pathNodes[i]);
+
+ //If the navigation does not support an intermediate pathNode, then returns
false
+ if (currentNode == null)
{
- selectedPaths_.add(selecttedNode = tempNode);
- tempNode = tempNode.getChild(nodeNames[i]);
+ return false;
}
- if (tempNode != null)
+ else
{
- selectedPaths_.add(selecttedNode = tempNode);
+ tempNode = currentNode;
}
-
- uiPortal.setSelectedNode(selecttedNode);
- uiPortal.setSelectedNavigation(nav);
+ }
+ return true;
+ }
+
+ /**
+ * Fetch the currently selected pageNode under a PageNavigation. It is the last
node encountered
+ * while descending the pathNodes
+ *
+ * @param targetedNav
+ * @param pathNodes
+ * @return
+ */
+ private static PageNode getTargetedNode(PageNavigation targetedNav, String[]
pathNodes)
+ {
+ //Case users browses to a URL of the form */portal/public/classic
+ if(pathNodes.length == 0)
+ {
+ return targetedNav.getNodes().get(0);
}
-
- pcontext.getJavascriptManager().addCustomizedOnLoadScript(
- "document.title='" +
uiPortal.getSelectedNode().getResolvedLabel().replaceAll("'",
"\\\\'") + "';");
- uiPortal.setSelectedPaths(selectedPaths_);
- String selectedUri = (uiPortal.getSelectedNode() == null) ? null :
uiPortal.getSelectedNode().getUri();
-
- if (!currentUri.equals(selectedUri))
+
+ PageNode currentNode = targetedNav.getNode(pathNodes[0]);
+ PageNode tempNode = null;
+
+ for(int i = 1; i < pathNodes.length; i++)
{
- if (uiPageBody.getMaximizedUIComponent() != null)
+ tempNode = currentNode.getChild(pathNodes[i]);
+ if (tempNode == null)
{
- UIPortlet currentPortlet =
(UIPortlet)uiPageBody.getMaximizedUIComponent();
- currentPortlet.setCurrentWindowState(WindowState.NORMAL);
- uiPageBody.setMaximizedUIComponent(null);
+ return null;
}
+ else
+ {
+ currentNode = tempNode;
+ }
}
- uiPageBody.setPageBody(uiPortal.getSelectedNode(), uiPortal);
+
+ return currentNode;
}
-
- /**
- * Update the layout of UIPortal if both ownerType and ownerId of
- * navigation are changed
- *
- * @param uiPortal
- * @param formerNav
- * @param newNav
- * @param uiPortalApp
- * @throws Exception
- */
- private void updateLayout(UIPortal uiPortal, PageNavigation formerNav,
PageNavigation newNav,
- UIPortalApplication uiPortalApp) throws Exception
+
+ private static List<PageNode> findPath(PageNavigation nav, String[]
pathNodes)
{
- if (formerNav == null || newNav == null)
+ List<PageNode> nodes = new ArrayList<PageNode>(4);
+
+ //That happens when user browses to a URL like */portal/public/classic
+ if(pathNodes.length == 0)
{
- return;
+ nodes.add(nav.getNodes().get(0));
+ return nodes;
}
- String newOwnerType = newNav.getOwnerType();
- String newOwnerId = newNav.getOwnerId();
- String formerOwnerType = formerNav.getOwnerType();
- String formerOwnerId = formerNav.getOwnerId();
-
- if (newOwnerId.equals(formerOwnerId) &&
formerOwnerType.equals(newOwnerType))
+ PageNode startNode = nav.getNode(pathNodes[0]);
+ if (startNode == null)
{
- return;
+ return nodes;
}
+ nodes.add(startNode);
- DataStorage storage = uiPortalApp.getApplicationComponent(DataStorage.class);
- PortalConfig pConfig = storage.getPortalConfig(newOwnerType, newOwnerId);
- Container container = pConfig.getPortalLayout();
- if (container != null)
+ for (int i = 1; i < pathNodes.length; i++)
{
- UserPortalConfig portalConfig = uiPortalApp.getUserPortalConfig();
- portalConfig.setPortal(pConfig);
- rebuildUIPortal(uiPortal, portalConfig);
+ startNode = startNode.getChild(pathNodes[i]);
+ if (startNode == null)
+ {
+ return nodes;
+ }
+ else
+ {
+ nodes.add(startNode);
+ }
}
+ return nodes;
}
- /**
- * Rebuild UIPortal with updated UserPortalConfig
- *
- * @param uiPortal
- * @param portalConfig
- * @throws Exception
- */
- private void rebuildUIPortal(UIPortal uiPortal, UserPortalConfig portalConfig)
throws Exception
+ private static UIPortal buildUIPortal(PageNavigation newPageNav,
UIPortalApplication uiPortalApp, UserPortalConfig userPortalConfig) throws Exception
{
- PageNode backupSelectedNode = uiPortal.getSelectedNode();
- PageNavigation backupSelectedNavigation = uiPortal.getSelectedNavigation();
- List<PageNode> backupSelectedPaths = uiPortal.getSelectedPaths();
- uiPortal.getChildren().clear();
- PortalDataMapper.toUIPortal(uiPortal, portalConfig);
- uiPortal.setSelectedNode(backupSelectedNode);
- uiPortal.setSelectedNavigation(backupSelectedNavigation);
- uiPortal.setSelectedPaths(backupSelectedPaths);
+ DataStorage storage = uiPortalApp.getApplicationComponent(DataStorage.class);
+ if(storage == null){
+ return null;
+ }
+ PortalConfig portalConfig = storage.getPortalConfig(newPageNav.getOwnerType(),
newPageNav.getOwnerId());
+ Container layout = portalConfig.getPortalLayout();
+ if(layout != null)
+ {
+ userPortalConfig.setPortal(portalConfig);
+ }
+ UIPortal uiPortal = uiPortalApp.createUIComponent(UIPortal.class, null, null);
+ //Reset selected navigation on userPortalConfig
+ userPortalConfig.setSelectedNavigation(newPageNav);
+ System.out.println("Build new UIPortal with OWNERTYPE: " +
newPageNav.getOwnerType() + " OWNERID: " + newPageNav.getOwnerId());
+ PortalDataMapper.toUIPortal(uiPortal, userPortalConfig);
+ return uiPortal;
}
}
- //
- // static public class DeleteWidgetActionListener extends
- // EventListener<UIPage> {
- // public void execute(Event<UIPage> event) throws Exception {
- // WebuiRequestContext pContext = event.getRequestContext();
- // String id = pContext.getRequestParameter(UIComponent.OBJECTID);
- // UIPage uiPage = event.getSource();
- // List<UIWidget> uiWidgets = new ArrayList<UIWidget>();
- // uiPage.findComponentOfType(uiWidgets, UIWidget.class);
- // for(UIWidget uiWidget : uiWidgets) {
- // if(uiWidget.getApplicationInstanceUniqueId().equals(id)) {
- // uiPage.getChildren().remove(uiWidget);
- // String userName = pContext.getRemoteUser() ;
- // if(userName != null && userName.trim().length() > 0) {
- // UserWidgetStorage widgetDataService =
- // uiPage.getApplicationComponent(UserWidgetStorage.class) ;
- // widgetDataService.delete(userName, uiWidget.getApplicationName(),
- // uiWidget.getApplicationInstanceUniqueId()) ;
- // }
- // if(uiPage.isModifiable()) {
- // Page page = PortalDataMapper.toPageModel(uiPage);
- // UserPortalConfigService configService =
- // uiPage.getApplicationComponent(UserPortalConfigService.class);
- // if(page.getChildren() == null) page.setChildren(new ArrayList<Object>());
- // configService.update(page);
- // }
- // break;
- // }
- // }
- // PortalRequestContext pcontext =
- // (PortalRequestContext)event.getRequestContext();
- // pcontext.setFullRender(false);
- // pcontext.setResponseComplete(true) ;
- // pcontext.getWriter().write(EventListener.RESULT_OK) ;
- // }
- // }
- //
+
static public class DeleteGadgetActionListener extends EventListener<UIPage>
{
public void execute(Event<UIPage> event) throws Exception
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -80,14 +80,18 @@
UserPortalConfigService userPortalConfigService =
(UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
Page page = null;
- UIPage uiPage = null;
+ UIPage uiPage;
+
+ String pageReference = null;
+
if (pageNode != null)
{
+ pageReference = pageNode.getPageReference();
try
{
- if (pageNode.getPageReference() != null)
+ if (pageReference != null)
{
- page = userPortalConfigService.getPage(pageNode.getPageReference(),
context.getRemoteUser());
+ page = userPortalConfigService.getPage(pageReference,
context.getRemoteUser());
}
}
catch (Exception e)
@@ -96,41 +100,66 @@
uiApp.addMessage(new ApplicationMessage(e.getMessage(), new Object[]{}));
}
}
-
+
uiPortal.setMaximizedUIComponent(null);
- if (page != null)
+
+ uiPage = getUIPage(pageReference, page, uiPortal, context);
+
+ if (uiPage.isShowMaxWindow())
{
- if (Page.DESKTOP_PAGE.equals(page.getFactoryId()))
+ uiPortal.setMaximizedUIComponent(uiPage);
+ }
+ else
+ {
+ UIComponent maximizedComponent = uiPortal.getMaximizedUIComponent();
+ if (maximizedComponent != null && maximizedComponent instanceof UIPage)
{
- uiPage = createUIComponent(context, UIDesktopPage.class, null, null);
+ uiPortal.setMaximizedUIComponent(null);
}
- else
+ maximizedComponent = this.getMaximizedUIComponent();
+ if (maximizedComponent != null && maximizedComponent instanceof UIPage)
{
- uiPage = createUIComponent(context, UIPage.class, null, null);
+ this.setMaximizedUIComponent(null);
}
- PortalDataMapper.toUIPage(uiPage, page);
- if (uiPage.isShowMaxWindow())
- {
- uiPortal.setMaximizedUIComponent(uiPage);
- }
- else
- {
- UIComponent maximizedComponent = uiPortal.getMaximizedUIComponent();
- if (maximizedComponent != null && maximizedComponent instanceof
UIPage)
- {
- uiPortal.setMaximizedUIComponent(null);
- }
- maximizedComponent = this.getMaximizedUIComponent();
- if (maximizedComponent != null && maximizedComponent instanceof
UIPage)
- {
- this.setMaximizedUIComponent(null);
- }
- }
-
}
setUIComponent(uiPage);
}
+ /**
+ * Return cached UIPage or a newly built UIPage
+ *
+ * @param pageReference
+ * @param page
+ * @param uiPortal
+ * @return
+ */
+ private UIPage getUIPage(String pageReference, Page page, UIPortal uiPortal,
WebuiRequestContext context)
+ throws Exception
+ {
+ UIPage uiPage = uiPortal.getUIPage(pageReference);
+ if (uiPage != null)
+ {
+ return uiPage;
+ }
+
+ if(page == null)
+ {
+ return null;
+ }
+
+ if (Page.DESKTOP_PAGE.equals(page.getFactoryId()))
+ {
+ uiPage = createUIComponent(context, UIDesktopPage.class, null, null);
+ }
+ else
+ {
+ uiPage = createUIComponent(context, UIPage.class, null, null);
+ }
+ PortalDataMapper.toUIPage(uiPage, page);
+
+ return uiPage;
+ }
+
public void renderChildren() throws Exception
{
uicomponent_.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -131,8 +131,7 @@
localeConfig = localeConfigService.getDefaultLocaleConfig();
uiApp.setLocale(localeConfig.getLocale());
uiApp.setOrientation(localeConfig.getOrientation());
- UIPortal uiPortal = uiApp.findFirstComponentOfType(UIPortal.class);
- uiPortal.refreshNavigation(localeConfig.getLocale());
+ uiApp.localizeNavigations();
OrganizationService orgService =
event.getSource().getApplicationComponent(OrganizationService.class);
String remoteUser = event.getRequestContext().getRemoteUser();
if (remoteUser != null)
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -29,6 +29,7 @@
import org.exoplatform.portal.config.model.Properties;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
+import org.exoplatform.portal.webui.page.UIPage;
import org.exoplatform.portal.webui.page.UIPageBody;
import
org.exoplatform.portal.webui.page.UIPageActionListener.ChangePageNodeActionListener;
import
org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeApplicationListActionListener;
@@ -60,6 +61,7 @@
import java.util.Map;
import java.util.ResourceBundle;
+import javax.portlet.WindowState;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@@ -67,8 +69,6 @@
@EventConfig(listeners = ChangePageNodeActionListener.class),
@EventConfig(listeners = ChangeApplicationListActionListener.class),
@EventConfig(listeners = MoveChildActionListener.class),
- // @EventConfig(listeners =
- // RemoveJSApplicationToDesktopActionListener.class),
@EventConfig(listeners = UIPortal.ChangeWindowStateActionListener.class),
@EventConfig(listeners = UIPortal.LogoutActionListener.class),
@EventConfig(listeners = ShowLoginFormActionListener.class),
@@ -98,14 +98,19 @@
private Properties properties;
- private List<PageNavigation> navigations;
+ //private List<PageNavigation> navigations;
- private List<PageNode> selectedPaths_;
+ private PageNavigation navigation;
+
+ private List<PageNode> selectedPath;
private PageNode selectedNode_;
-
- private PageNavigation selectedNavigation_;
-
+
+ private UIPage showedUIPage;
+
+ //private Map<UIPageKey, UIPage> all_UIPages;
+ private Map<String, UIPage> all_UIPages;
+
private Map<String, String[]> publicParameters_ = new HashMap<String,
String[]>();
private UIComponent maximizedUIComponent;
@@ -189,7 +194,35 @@
{
publicParameters_ = publicParams;
}
+
+ /** At the moment, this method ensure compatibility with legacy code */
+ public List<PageNavigation> getNavigations() throws Exception
+ {
+ List<PageNavigation> listNavs = new ArrayList<PageNavigation>();
+ listNavs.add(navigation);
+ return listNavs;
+ }
+
+ public UIPage getUIPage(String pageReference)
+ {
+ if(all_UIPages == null)
+ {
+ this.all_UIPages = new HashMap<String, UIPage>(5);
+ return null;
+ }
+ return this.all_UIPages.get(pageReference);
+ }
+
+ public void setUIPage(String pageReference, UIPage uiPage)
+ {
+ if(this.all_UIPages == null)
+ {
+ this.all_UIPages = new HashMap<String, UIPage>(5);
+ }
+ this.all_UIPages.put(pageReference, uiPage);
+ }
+ /*
public List<PageNavigation> getNavigations() throws Exception
{
UserPortalConfigService serv =
getApplicationComponent(UserPortalConfigService.class);
@@ -205,7 +238,9 @@
return navigations;
}
-
+ */
+
+ /*
public void setNavigation(List<PageNavigation> navs) throws Exception
{
navigations = navs;
@@ -241,11 +276,46 @@
refreshNavigation(uiApp.getLocale());
}
- public void setSelectedNode(PageNode node)
+ */
+
+ public void setNavigation(PageNavigation _navigation)
{
+ this.navigation = _navigation;
+ }
+
+ /** Refresh the UIPage under UIPortal */
+ public void refreshUIPage() throws Exception
+ {
+ if(selectedNode_ == null)
+ {
+ selectedNode_ = navigation.getNodes().get(0);
+ }
+
+ UIPageBody uiPageBody = findFirstComponentOfType(UIPageBody.class);
+ if(uiPageBody == null)
+ {
+ return;
+ }
+
+ if (uiPageBody.getMaximizedUIComponent() != null)
+ {
+ UIPortlet currentPortlet = (UIPortlet)uiPageBody.getMaximizedUIComponent();
+ currentPortlet.setCurrentWindowState(WindowState.NORMAL);
+ uiPageBody.setMaximizedUIComponent(null);
+ }
+ uiPageBody.setPageBody(selectedNode_, this);
+
+ //Refresh locale
+ Locale locale = Util.getUIPortalApplication().getLocale();
+ refreshNavigation(locale);
+ }
+
+ public synchronized void setSelectedNode(PageNode node)
+ {
selectedNode_ = node;
}
+ /*
public PageNode getSelectedNode() throws Exception
{
if (selectedNode_ != null)
@@ -256,17 +326,32 @@
selectedNode_ = selectedNavigation_.getNodes().get(0);
return selectedNode_;
}
+ */
+
+ public PageNode getSelectedNode() throws Exception
+ {
+ if(selectedNode_ != null)
+ {
+ return selectedNode_;
+ }
+ if(navigation == null || navigation.getNodes() == null ||
navigation.getNodes().size() < 1)
+ {
+ return null;
+ }
+ return navigation.getNodes().get(0);
+ }
- public List<PageNode> getSelectedPaths()
+ public List<PageNode> getSelectedPath()
{
- return selectedPaths_;
+ return selectedPath;
}
- public void setSelectedPaths(List<PageNode> nodes)
+ public void setSelectedPath(List<PageNode> nodes)
{
- selectedPaths_ = nodes;
+ selectedPath = nodes;
}
+ /*
public PageNavigation getSelectedNavigation() throws Exception
{
if (selectedNavigation_ != null && selectedNavigation_.getNodes() != null
@@ -292,7 +377,19 @@
setSelectedNavigation(pNav);
return pNav;
}
+ */
+
+ public PageNavigation getSelectedNavigation() throws Exception
+ {
+ return navigation;
+ }
+
+ public void setSelectedNavigation(PageNavigation _navigation)
+ {
+ this.navigation = _navigation;
+ }
+ /**
public PageNavigation getPageNavigation(int id)
{
for (PageNavigation nav : navigations)
@@ -303,11 +400,15 @@
return null;
}
+*/
+ /*
public void setSelectedNavigation(PageNavigation selectedNavigation)
{
selectedNavigation_ = selectedNavigation;
}
+ */
+
public UIComponent getMaximizedUIComponent()
{
return maximizedUIComponent;
@@ -372,6 +473,7 @@
setProperty(PortalProperties.SESSION_ALIVE, type);
}
+ /*
@Deprecated
public void refreshNavigation()
{
@@ -387,7 +489,9 @@
}
}
}
-
+ */
+
+ /*
public void refreshNavigation(Locale locale)
{
for (PageNavigation nav : navigations)
@@ -395,6 +499,11 @@
localizePageNavigation(nav,locale);
}
}
+ */
+ public void refreshNavigation(Locale locale)
+ {
+ localizePageNavigation(navigation, locale);
+ }
private void localizePageNavigation(PageNavigation nav,Locale locale)
{
@@ -490,5 +599,32 @@
event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWS);
}
}
+
+ private static class UIPageKey
+ {
+ private String ownerType;
+
+ private String ownerId;
+
+ UIPageKey(String _ownerType, String _ownerId)
+ {
+ this.ownerType = _ownerType;
+ this.ownerId = _ownerId;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if(this == null || obj == null)
+ {
+ return this == null && obj == null;
+ }
+ if(!(obj instanceof UIPageKey))
+ {
+ return false;
+ }
+ return this.ownerType.equals(((UIPageKey)obj).ownerType) &&
this.ownerId.equals(((UIPageKey)obj).ownerId);
+ }
+ }
}
\ No newline at end of file
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -207,7 +207,8 @@
if (!portalAppLanguage.equals(userLanguage) &&
!portalAppLanguage.equals(browserLanguage))
{
uiPortalApp.setLocale(localeConfig.getLocale());
- editPortal.refreshNavigation(localeConfig.getLocale());
+ //editPortal.refreshNavigation(localeConfig.getLocale());
+ uiPortalApp.localizeNavigations();
}
uiPortalApp.setSkin(editPortal.getSkin());
}
@@ -587,18 +588,20 @@
public void execute(Event<UIPortalComposer> event) throws Exception
{
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
- UIPortal uiPortal = Util.getUIPortal();
+ UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
UIEditInlineWorkspace editInlineWS = event.getSource().getParent();
UIWorkingWorkspace uiWorkingWS = editInlineWS.getParent();
UIPortalToolPanel uiToolPanel =
uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
+
UIPage uiPage = uiToolPanel.findFirstComponentOfType(UIPage.class);
Page page = (Page)PortalDataMapper.buildModelObject(uiPage);
+ String pageId = page.getPageId();
+
UserPortalConfigService portalConfigService =
uiWorkingWS.getApplicationComponent(UserPortalConfigService.class);
- if (page.getStorageId() != null &&
portalConfigService.getPage(page.getPageId()) == null)
+ if (page.getStorageId() != null && portalConfigService.getPage(pageId)
== null)
{
- uiPortalApp.addMessage(new
ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{page
- .getPageId()}, 1));
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{pageId}, 1));
uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
PageNodeEvent<UIPortal> pnevent =
new PageNodeEvent<UIPortal>(uiPortal,
PageNodeEvent.CHANGE_PAGE_NODE,
@@ -624,6 +627,10 @@
// Perform mop update
portalConfigService.update(page);
uiToolPanel.setUIComponent(null);
+
+ // Update UIPage cache on UIPortal
+ uiPortal.setUIPage(pageId, uiPage);
+
if (PortalProperties.SESSION_ALWAYS.equals(uiPortal.getSessionAlive()))
{
uiPortalApp.setSessionOpen(true);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -369,7 +369,8 @@
buildUIContainer(uiPortal, child, false);
}
}
- uiPortal.setNavigation(userPortalConfig.getNavigations());
+ //uiPortal.setNavigation(userPortalConfig.getNavigations());
+ uiPortal.setNavigation(userPortalConfig.getSelectedNavigation());
}
private static void buildUIContainer(UIContainer uiContainer, Object model, boolean
dashboard) throws Exception
@@ -422,4 +423,5 @@
}
uiContainer.addChild(uiComponent);
}
+
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -62,8 +62,9 @@
static public UIPortal getUIPortal()
{
- return getUIPortalApplication().<UIWorkingWorkspace>
getChildById(UIPortalApplication.UI_WORKING_WS_ID)
- .findFirstComponentOfType(UIPortal.class);
+ //return getUIPortalApplication().<UIWorkingWorkspace>
getChildById(UIPortalApplication.UI_WORKING_WS_ID)
+ // .findFirstComponentOfType(UIPortal.class);
+ return getUIPortalApplication().getShowedUIPortal();
}
static public UIPortalToolPanel getUIPortalToolPanel()
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -122,8 +122,8 @@
{
public void execute(Event<UIWorkingWorkspace> event) throws Exception
{
- UIPortal uiPortal = Util.getUIPortal();
UIPortalApplication uiApp = Util.getUIPortalApplication();
+ UIPortal uiPortal = uiApp.getShowedUIPortal();
PortalConfig portalConfig = uiApp.getUserPortalConfig().getPortalConfig();
UserACL userACL = uiPortal.getApplicationComponent(UserACL.class);
if (!userACL.hasEditPermission(portalConfig))
@@ -141,7 +141,7 @@
PortalDataMapper.toUIPortal(newPortal, uiApp.getUserPortalConfig());
newPortal.setSelectedNode(uiPortal.getSelectedNode());
newPortal.setSelectedNavigation(uiPortal.getSelectedNavigation());
- newPortal.setSelectedPaths(uiPortal.getSelectedPaths());
+ newPortal.setSelectedPath(uiPortal.getSelectedPath());
UIEditInlineWorkspace uiEditWS =
uiWorkingWS.getChild(UIEditInlineWorkspace.class);
uiEditWS.setUIComponent(newPortal);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-01-28
07:00:24 UTC (rev 1456)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-01-28
10:09:29 UTC (rev 1457)
@@ -26,6 +26,9 @@
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.resource.Skin;
@@ -33,6 +36,7 @@
import org.exoplatform.portal.resource.SkinService;
import org.exoplatform.portal.resource.SkinURL;
import org.exoplatform.portal.webui.application.UIPortlet;
+import org.exoplatform.portal.webui.navigation.PageNavigationUtils;
import org.exoplatform.portal.webui.page.UISiteBody;
import org.exoplatform.portal.webui.portal.PageNodeEvent;
import org.exoplatform.portal.webui.portal.UIPortal;
@@ -44,6 +48,7 @@
import org.exoplatform.services.resources.LocaleConfig;
import org.exoplatform.services.resources.LocaleConfigService;
import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.services.resources.ResourceBundleManager;
import org.exoplatform.web.application.javascript.JavascriptConfigService;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -56,19 +61,23 @@
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
import java.util.Set;
+
/**
* This extends the UIApplication and hence is a sibling of UIPortletApplication
* (used by any eXo Portlets as the Parent class to build the portlet component
* tree). The UIPortalApplication is responsible to build its subtree according
* to some configuration parameters. If all components are displayed it is
- * composed of 2 UI components: -UIWorkingWorkSpace: the right part that can
- * display the normal or webos portal layouts
- * - UIPopupWindow: a popup window that display or not
+ * composed of 2 UI components: -UIWorkingWorkSpace: the right part that can
+ * display the normal or webos portal layouts - UIPopupWindow: a popup window
+ * that display or not
*/
@ComponentConfig(lifecycle = UIPortalApplicationLifecycle.class, template =
"system:/groovy/portal/webui/workspace/UIPortalApplication.gtmpl")
public class UIPortalApplication extends UIApplication
@@ -104,17 +113,23 @@
private UserPortalConfig userPortalConfig_;
private boolean isSessionOpen = false;
-
+
+ private Map<UIPortalKey, UIPortal> all_UIPortals;
+
+ private List<PageNavigation> all_Navigations;
+
+ private UIPortal showedUIPortal;
+
/**
* The constructor of this class is used to build the tree of UI components
* that will be aggregated in the portal page. 1) The component is stored in
* the current PortalRequestContext ThreadLocal 2) The configuration for the
* portal associated with the current user request is extracted from the
- * PortalRequestContext 3) Then according to the context path, either a public
- * or private portal is initiated. Usually a public portal does not contain
- * the left column and only the private one has it. 4) The skin to use is
- * setup 5) Finally, the current component is associated with the current
- * portal owner
+ * PortalRequestContext 3) Then according to the context path, either a
+ * public or private portal is initiated. Usually a public portal does not
+ * contain the left column and only the private one has it. 4) The skin to
+ * use is setup 5) Finally, the current component is associated with the
+ * current portal owner
*
* @throws Exception
*/
@@ -122,11 +137,17 @@
{
log = ExoLogger.getLogger("portal:UIPortalApplication");
PortalRequestContext context = PortalRequestContext.getCurrentInstance();
+
userPortalConfig_ =
(UserPortalConfig)context.getAttribute(UserPortalConfig.class);
if (userPortalConfig_ == null)
throw new Exception("Can't load user portal config");
- // dang.tung - set portal language by user preference -> browser -> default
+ //TODO: Check if we need to clone page node
+ this.all_Navigations = userPortalConfig_.getNavigations();
+ localizeNavigations();
+
+ // dang.tung - set portal language by user preference -> browser ->
+ // default
// ------------------------------------------------------------------------------
String portalLanguage = null;
LocaleConfigService localeConfigService =
getApplicationComponent(LocaleConfigService.class);
@@ -149,7 +170,8 @@
localeConfig = localeConfigService.getLocaleConfig(portalLanguage);
if (portalLanguage == null || !portalLanguage.equals(localeConfig.getLanguage()))
{
- // if user language no support by portal -> get browser language if no ->
+ // if user language no support by portal -> get browser language if no
+ // ->
// get portal
portalLanguage = context.getRequest().getLocale().getLanguage();
localeConfig = localeConfigService.getLocaleConfig(portalLanguage);
@@ -163,6 +185,7 @@
// -------------------------------------------------------------------------------
context.setUIApplication(this);
+ setupUIPortalCache();
addWorkingWorkspace();
String currentSkin = userPortalConfig_.getPortalConfig().getSkin();
@@ -171,6 +194,52 @@
setOwner(context.getPortalOwner());
}
+ public void setShowedUIPortal(UIPortal uiPortal)
+ {
+ this.showedUIPortal = uiPortal;
+
+ UISiteBody siteBody = this.findFirstComponentOfType(UISiteBody.class);
+ if(siteBody != null)
+ {
+ //TODO: Check this part carefully
+ siteBody.setUIComponent(uiPortal);
+ }
+ }
+
+ public UIPortal getShowedUIPortal()
+ {
+ return showedUIPortal;
+ }
+
+ public UIPortal getCachedUIPortal(String ownerType, String ownerId)
+ {
+ if(ownerType == null || ownerId == null)
+ {
+ return null;
+ }
+ return this.all_UIPortals.get(new UIPortalKey(ownerType, ownerId));
+ }
+
+ public void addUIPortal(UIPortal uiPortal)
+ {
+ String ownerType = uiPortal.getOwnerType();
+ String ownerId = uiPortal.getOwner();
+
+ if(ownerType != null && ownerId != null)
+ {
+ this.all_UIPortals.put(new UIPortalKey(ownerType, ownerId), uiPortal);
+ }
+ }
+
+ public void removeUIPortal(String ownerType, String ownerId)
+ {
+ if(ownerType == null || ownerId == null)
+ {
+ return;
+ }
+ this.all_UIPortals.remove(new UIPortalKey(ownerType, ownerId));
+ }
+
public boolean isSessionOpen()
{
return isSessionOpen;
@@ -286,12 +355,12 @@
}
/**
- * Returns a list of portlets skin that have to be added in the HTML head tag.
- * The skin can directly point to a real css file (this is the case of all the
- * porlet included in a page) or point to a servlet that agregates different
- * portlet CSS files into one to lower the number of HTTP calls (this is the
- * case in production as all the portlets included in a portal, and hence
- * there on everypage are merged into a single CSS file)
+ * Returns a list of portlets skin that have to be added in the HTML head
+ * tag. The skin can directly point to a real css file (this is the case of
+ * all the porlet included in a page) or point to a servlet that agregates
+ * different portlet CSS files into one to lower the number of HTTP calls
+ * (this is the case in production as all the portlets included in a portal,
+ * and hence there on everypage are merged into a single CSS file)
*
* @return the portlet skins
*/
@@ -311,7 +380,8 @@
toolPanel.findComponentOfType(uiportlets, UIPortlet.class);
}
- // Get portal portlets to filter since they are already in the portal skins
+ // Get portal portlets to filter since they are already in the portal
+ // skins
Set<SkinConfig> portletConfigs = getPortalPortletSkins();
//
@@ -340,7 +410,22 @@
return null;
}
}
-
+
+ private void setupUIPortalCache()
+ {
+ this.all_UIPortals = new HashMap<UIPortalKey, UIPortal>(5);
+ }
+
+ private void setupSkin()
+ {
+
+ }
+
+ private void setupLocale()
+ {
+
+ }
+
/**
* The central area is called the WorkingWorkspace. It is composed of: 1) A
* UIPortal child which is filled with portal data using the PortalDataMapper
@@ -359,6 +444,10 @@
Container container = dataStorage.getSharedLayout();
UIPortal uiPortal = createUIComponent(UIPortal.class, null, null);
PortalDataMapper.toUIPortal(uiPortal, userPortalConfig_);
+
+ this.addUIPortal(uiPortal);
+ this.showedUIPortal = uiPortal;
+
uiWorkingWorkspace.addChild(UIEditInlineWorkspace.class, null,
UI_EDITTING_WS_ID).setRendered(false);
if (container != null)
{
@@ -367,16 +456,20 @@
uiContainer.setStorageId(container.getStorageId());
PortalDataMapper.toUIContainer(uiContainer, container);
UISiteBody uiSiteBody = uiContainer.findFirstComponentOfType(UISiteBody.class);
- uiSiteBody.setUIComponent(uiPortal);
+ //uiSiteBody.setUIComponent(uiPortal);
+ uiSiteBody.setUIComponent(this.showedUIPortal);
uiContainer.setRendered(true);
uiViewWS.setUIComponent(uiContainer);
}
else
{
- uiViewWS.setUIComponent(uiPortal);
+ //uiViewWS.setUIComponent(uiPortal);
+ uiViewWS.setUIComponent(this.showedUIPortal);
}
- //uiWorkingWorkspace.addChild(UIPortalToolPanel.class, null,
null).setRendered(false);
- //editInlineWS.addChild(UIPortalToolPanel.class, null, null).setRendered(false);
+ // uiWorkingWorkspace.addChild(UIPortalToolPanel.class, null,
+ // null).setRendered(false);
+ // editInlineWS.addChild(UIPortalToolPanel.class, null,
+ // null).setRendered(false);
addChild(UIMaskWorkspace.class, UIPortalApplication.UI_MASK_WS_ID, null);
}
@@ -398,33 +491,31 @@
if (!nodePath.equals(nodePath_) || !isPageExist())
{
nodePath_ = nodePath;
- UIPortal uiPortal = findFirstComponentOfType(UIPortal.class);
- PageNodeEvent<UIPortal> pnevent =
- new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE,
nodePath_);
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ PageNodeEvent<UIPortal> pnevent = new
PageNodeEvent<UIPortal>(showedUIPortal, PageNodeEvent.CHANGE_PAGE_NODE, nodePath_);
+ showedUIPortal.broadcast(pnevent, Event.Phase.PROCESS);
}
super.processDecode(context);
}
/**
- * The processrender() method handles the creation of the returned HTML either
- * for a full page render or in the case of an AJAX call The first request,
- * Ajax is not enabled (means no ajaxRequest parameter in the request) and
- * hence the super.processRender() method is called. This will hence call the
- * processrender() of the Lifecycle object as this method is not overidden in
- * UIPortalApplicationLifecycle. There we simply render the bounded template
- * (groovy usually). Note that bounded template are also defined in component
- * annotations, so for the current class it is UIPortalApplication.gtmpl On
- * second calls, request have the "ajaxRequest" parameter set to true in
the
- * URL. In that case the algorithm is a bit more complex: a) The list of
- * components that should be updated is extracted using the
- * context.getUIComponentToUpdateByAjax() method. That list was setup during
- * the process action phase b) Portlets and other UI components to update are
- * split in 2 different lists c) Portlets full content are returned and set
- * with the tag <div class="PortalResponse"> d) Block to updates
(which are UI
- * components) are set within the <div class="PortalResponseData"> tag
e) Then
- * the scripts and the skins to reload are set in the <div
- * class="PortalResponseScript">
+ * The processrender() method handles the creation of the returned HTML
+ * either for a full page render or in the case of an AJAX call The first
+ * request, Ajax is not enabled (means no ajaxRequest parameter in the
+ * request) and hence the super.processRender() method is called. This will
+ * hence call the processrender() of the Lifecycle object as this method is
+ * not overidden in UIPortalApplicationLifecycle. There we simply render the
+ * bounded template (groovy usually). Note that bounded template are also
+ * defined in component annotations, so for the current class it is
+ * UIPortalApplication.gtmpl On second calls, request have the
"ajaxRequest"
+ * parameter set to true in the URL. In that case the algorithm is a bit more
+ * complex: a) The list of components that should be updated is extracted
+ * using the context.getUIComponentToUpdateByAjax() method. That list was
+ * setup during the process action phase b) Portlets and other UI components
+ * to update are split in 2 different lists c) Portlets full content are
+ * returned and set with the tag <div class="PortalResponse"> d) Block
to
+ * updates (which are UI components) are set within the <div
+ * class="PortalResponseData"> tag e) Then the scripts and the skins to
+ * reload are set in the <div class="PortalResponseScript">
*/
public void processRender(WebuiRequestContext context) throws Exception
{
@@ -483,10 +574,10 @@
w.append("<div
class=\"PortletResponseData\">");
/*
- * If the portlet is using our UI framework or supports it then it
- * will return a set of block to updates. If there is not block to
- * update the javascript client will see that as a full refresh of the
- * content part
+ * If the portlet is using our UI framework or supports it then
+ * it will return a set of block to updates. If there is not
+ * block to update the javascript client will see that as a full
+ * refresh of the content part
*/
uiPortlet.processRender(context);
@@ -589,4 +680,67 @@
return (page != null);
}
+ public void localizeNavigations()
+ {
+ ResourceBundleManager i18nManager =
getApplicationComponent(ResourceBundleManager.class);
+ Locale locale = getLocale();
+
+ for(PageNavigation nav : this.getNavigations())
+ {
+ PageNavigationUtils.localizePageNavigation(nav, locale, i18nManager);
+ }
+ }
+
+ public void setNavigations(List<PageNavigation> navs)
+ {
+ this.all_Navigations = navs;
+ }
+
+ public List<PageNavigation> getNavigations()
+ {
+ return this.all_Navigations;
+ }
+
+ private static class UIPortalKey
+ {
+ private String ownerType;
+
+ private String ownerId;
+
+ private final int hashCode;
+
+ UIPortalKey(String _ownerType, String _ownerId)
+ {
+ this.ownerType = _ownerType;
+ this.ownerId = _ownerId;
+ this.hashCode = this.ownerType.hashCode() * 2 + this.ownerId.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == null || obj == null)
+ {
+ return this == null && obj == null;
+ }
+ if (!(obj instanceof UIPortalKey))
+ {
+ return false;
+ }
+ return this.ownerType.equals(((UIPortalKey)obj).ownerType) &&
this.ownerId.equals(((UIPortalKey)obj).ownerId);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return this.hashCode;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "OWNERTYPE: " + ownerType + " OWNERID: " + ownerId;
+ }
+ }
+
}