[gatein-commits] gatein SVN: r6047 - in epp/portal/branches/EPP_5_1_Branch: component/portal/src/main/java/org/exoplatform/portal/config/model and 13 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Mar 16 16:49:36 EDT 2011


Author: thomas.heute at jboss.com
Date: 2011-03-16 16:49:35 -0400 (Wed, 16 Mar 2011)
New Revision: 6047

Modified:
   epp/portal/branches/EPP_5_1_Branch/component/common/src/main/java/org/exoplatform/commons/utils/Safe.java
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration1.xml
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration2.xml
   epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/portal/portal/test/navigation.xml
   epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UITabbedDashboard.js
   epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ar.xml
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_de.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_es.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_fr.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_it.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ja.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ko.xml
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ne.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_nl.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_pt_BR.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ru.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_uk.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_zh.xml
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_zh_TW.xml
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/page/UIPageSelector.gtmpl
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/page/UIWizardPageSetInfo.gtmpl
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl
   epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/TreeNode.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPageNavigationForm.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPageNodeSelector.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/PageQueryAccessList.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIDesktopPage.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageSelector.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
   epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java
Log:
JBEPP-853: Performance issues with the shipped-in applications when the portal has many nodes or pages
Rolling back


Modified: epp/portal/branches/EPP_5_1_Branch/component/common/src/main/java/org/exoplatform/commons/utils/Safe.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/common/src/main/java/org/exoplatform/commons/utils/Safe.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/common/src/main/java/org/exoplatform/commons/utils/Safe.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -26,8 +26,6 @@
 import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Collections;
-import java.util.Set;
 
 /**
  * A class that contains utility method that make the caller not worry much about the unexpectable expected such as
@@ -115,26 +113,6 @@
       }
    }
 
-   /**
-    * Wrap the set so that it is unmodifiable when it is not null, otherwise returns null.
-    *
-    * @todo it would be nice to avoid to rewrap unmodifiable set (not sure it is non proprietary possible)
-    * @param set the set to wrap
-    * @param <E> the set generic element type
-    * @return the unmodifiable set
-    */
-   public static <E> Set<E> unmodifiableSet(Set<E> set)
-   {
-      if (set == null)
-      {
-         return null;
-      }
-      else
-      {
-         return Collections.unmodifiableSet(set);
-      }
-   }
-
    // THIS CODE IS TEMPORARY
 
    /** . */

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -186,7 +186,6 @@
       children = list;
    }
 
-   // Remove this which seems to be not used
    public boolean isModifiable()
    {
       return modifiable;

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -19,7 +19,6 @@
 
 package org.exoplatform.portal.config.model;
 
-import org.exoplatform.portal.mop.SiteType;
 import org.exoplatform.portal.pom.config.Utils;
 import org.exoplatform.portal.pom.data.PortalData;
 
@@ -36,11 +35,11 @@
 public class PortalConfig extends ModelObject
 {
 
-   final public static String USER_TYPE = SiteType.USER.getName();
+   final public static String USER_TYPE = "user";
 
-   final public static String GROUP_TYPE = SiteType.GROUP.getName();
+   final public static String GROUP_TYPE = "group";
 
-   final public static String PORTAL_TYPE = SiteType.PORTAL.getName();
+   final public static String PORTAL_TYPE = "portal";
 
    final public static Container DEFAULT_LAYOUT = initDefaultLayout();
 

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -36,28 +36,20 @@
 
    public <V> V execute(POMSession session, POMTask<V> task) throws Exception
    {
-      if (log.isDebugEnabled())
+      String s = task.toString();
+      long t0 = System.currentTimeMillis();
+      V v = session.execute(task);
+      long t1 = System.currentTimeMillis();
+      String t = "" + (t1 - t0);
+      if (t.length() < 4)
       {
-         String s = task.toString();
-         log.debug("Executing " + s + "");
-         long t0 = System.currentTimeMillis();
-         V v = session.execute(task);
-         long t1 = System.currentTimeMillis();
-         String t = "" + (t1 - t0);
-         if (t.length() < 4)
-         {
-            t = padding[t.length()] + t;
-            log.debug("Executed [" + t + "] " + s + "");
-         }
-         else
-         {
-            log.debug("Executed in " + t + " " + s + "");
-         }
-         return v;
+         t = padding[t.length()] + t;
+         log.debug("Executed [" + t + "] " + s + "");
       }
       else
       {
-         return session.execute(task);
+         log.debug("Executed in " + t + " " + s + "");
       }
+      return v;
    }
 }

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -39,8 +39,6 @@
 import org.exoplatform.portal.config.model.PersistentApplicationState;
 import org.exoplatform.portal.config.model.TransientApplicationState;
 import org.exoplatform.portal.pom.config.tasks.DashboardTask;
-import org.exoplatform.portal.pom.config.tasks.MOPAccess;
-import org.exoplatform.portal.pom.config.tasks.NodeTask;
 import org.exoplatform.portal.pom.config.tasks.PageNavigationTask;
 import org.exoplatform.portal.pom.config.tasks.PageTask;
 import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
@@ -53,7 +51,6 @@
 import org.exoplatform.portal.pom.data.ModelDataStorage;
 import org.exoplatform.portal.pom.data.NavigationData;
 import org.exoplatform.portal.pom.data.NavigationKey;
-import org.exoplatform.portal.pom.data.NodeData;
 import org.exoplatform.portal.pom.data.PageData;
 import org.exoplatform.portal.pom.data.PageKey;
 import org.exoplatform.portal.pom.data.PortalData;
@@ -148,17 +145,6 @@
       pomMgr.execute(new PageNavigationTask.Remove(navigation));
    }
 
-
-   public NodeData loadNode(NavigationKey key) throws Exception
-   {
-      return pomMgr.execute(new NodeTask.Load<NavigationKey>(NodeTask.KeyType.NAVIGATION, key));
-   }
-
-   public NodeData loadNode(String key) throws Exception
-   {
-      return pomMgr.execute(new NodeTask.Load<String>(NodeTask.KeyType.STRING, key));
-   }
-
    public void save(PortletPreferences portletPreferences) throws Exception
    {
       pomMgr.execute(new PortletPreferencesTask.Save(portletPreferences));
@@ -251,11 +237,11 @@
       Class<T> type = q.getClassType();
       if (PageData.class.equals(type))
       {
-         return (LazyPageList<T>)new LazyPageList<PageData>(new MOPAccess.PageAccess(pomMgr, (Query<PageData>)q), 10);
+         return (LazyPageList<T>)pomMgr.execute(new SearchTask.FindPage((Query<PageData>)q));
       }
       else if (NavigationData.class.equals(type))
       {
-         return (LazyPageList<T>)new LazyPageList<NavigationData>(new MOPAccess.NavigationAccess(pomMgr, (Query<NavigationData>)q), 10);
+         return (LazyPageList<T>)pomMgr.execute(new SearchTask.FindNavigation((Query<NavigationData>)q));
       }
       else if (PortletPreferences.class.equals(type))
       {

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -21,7 +21,6 @@
 
 import org.chromattic.api.ChromatticSession;
 import org.chromattic.api.UndeclaredRepositoryException;
-import org.chromattic.api.query.QueryResult;
 import org.exoplatform.commons.chromattic.SessionContext;
 import org.exoplatform.commons.chromattic.SynchronizationListener;
 import org.exoplatform.commons.chromattic.SynchronizationStatus;
@@ -240,13 +239,8 @@
       return prefs;
    }
 
-   public <O extends WorkspaceObject> QueryResult<O> findObjects(
-      ObjectType<O> type,
-      ObjectType<Site> siteType,
-      String ownerId,
-      String title,
-      int offset,
-      int limit)
+   public <O extends WorkspaceObject> Iterator<O> findObjects(ObjectType<O> type, ObjectType<? extends Site> siteType,
+      String ownerId, String title)
    {
       this.save();
       //
@@ -357,7 +351,7 @@
          throw new Error(e);
       }
       Class<O> mappedClass = (Class<O>)mapping.get(type);
-      return session.createQueryBuilder(mappedClass).where(statement).get().objects((long)offset, (long)limit);
+      return session.createQueryBuilder(mappedClass).where(statement).get().objects();
    }
 
    private final SynchronizationListener listener = new SynchronizationListener()

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -73,11 +73,6 @@
       this.executor = new PortalNamesCache(new DataCache(new ExecutorDispatcher()));
    }
 
-   public ChromatticLifeCycle getLifeCycle()
-   {
-      return configurator;
-   }
-
    public void cachePut(Serializable key, Object value)
    {
       GlobalKey globalKey = GlobalKey.wrap(configurator.getRepositoryName(), key);

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -25,14 +25,20 @@
 import org.exoplatform.portal.config.Query;
 import org.exoplatform.portal.pom.config.POMTask;
 import org.exoplatform.portal.pom.data.Mapper;
+import org.exoplatform.portal.pom.data.NavigationData;
+import org.exoplatform.portal.pom.data.PageData;
 import org.exoplatform.portal.pom.data.PortalData;
 import org.exoplatform.portal.pom.data.PortalKey;
 import org.exoplatform.portal.pom.config.POMSession;
+import org.gatein.mop.api.workspace.Navigation;
 import org.gatein.mop.api.workspace.ObjectType;
 import org.gatein.mop.api.workspace.Site;
 import org.gatein.mop.api.workspace.Workspace;
+import org.gatein.mop.api.workspace.WorkspaceObject;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 
 /**
@@ -50,6 +56,124 @@
       this.q = query;
    }
 
+   public abstract static class FindSiteObject<W extends WorkspaceObject, T> extends SearchTask<T>
+   {
+
+      public FindSiteObject(Query<T> query)
+      {
+         super(query);
+      }
+
+      public LazyPageList<T> run(final POMSession session) throws Exception
+      {
+         Iterator<W> ite;
+         try
+         {
+            String ownerType = q.getOwnerType();
+            ObjectType<? extends Site> siteType = null;
+            if (ownerType != null)
+            {
+               siteType = Mapper.parseSiteType(ownerType);
+            }
+            ite = findW(session, siteType, q.getOwnerId(), q.getTitle());
+
+         }
+         catch (IllegalArgumentException e)
+         {
+            ite = Collections.<W> emptyList().iterator();
+         }
+
+         //
+         final ArrayList<W> array = new ArrayList<W>();
+         while (ite.hasNext())
+         {
+            array.add(ite.next());
+         }
+
+         //
+         final Iterator<W> it = array.iterator();
+         ListAccess<T> la = new ListAccess<T>()
+         {
+            public T[] load(int index, int length) throws Exception, IllegalArgumentException
+            {
+               T[] result = createT(length);
+               for (int i = 0; i < length; i++)
+               {
+                  T t = loadT(session, it.next());
+                  result[i] = t;
+               }
+               return result;
+            }
+
+            public int getSize() throws Exception
+            {
+               return array.size();
+            }
+         };
+
+         //
+         return new LazyPageList<T>(la, 10);
+      }
+
+      protected abstract Iterator<W> findW(POMSession session, ObjectType<? extends Site> siteType, String ownerId,
+         String title);
+
+      protected abstract T[] createT(int length);
+
+      protected abstract T loadT(POMSession session, W w);
+
+   }
+
+   public static class FindPage extends FindSiteObject<org.gatein.mop.api.workspace.Page, PageData>
+   {
+
+      public FindPage(Query<PageData> pageQuery)
+      {
+         super(pageQuery);
+      }
+
+      protected Iterator<org.gatein.mop.api.workspace.Page> findW(POMSession session,
+         ObjectType<? extends Site> siteType, String ownerId, String title)
+      {
+         return session.findObjects(ObjectType.PAGE, siteType, q.getOwnerId(), q.getTitle());
+      }
+
+      protected PageData[] createT(int length)
+      {
+         return new PageData[length];
+      }
+
+      protected PageData loadT(POMSession session, org.gatein.mop.api.workspace.Page w)
+      {
+         return new Mapper(session).load(w);
+      }
+   }
+
+   public static class FindNavigation extends FindSiteObject<Navigation, NavigationData>
+   {
+
+      public FindNavigation(Query<NavigationData> pageQuery)
+      {
+         super(pageQuery);
+      }
+
+      protected Iterator<Navigation> findW(POMSession session, ObjectType<? extends Site> siteType, String ownerId,
+         String title)
+      {
+         return session.findObjects(ObjectType.NAVIGATION, siteType, q.getOwnerId(), q.getTitle());
+      }
+
+      protected NavigationData[] createT(int length)
+      {
+         return new NavigationData[length];
+      }
+
+      protected NavigationData loadT(POMSession session, Navigation w)
+      {
+         return new Mapper(session).load(w);
+      }
+   }
+
    public static class FindPortletPreferences extends SearchTask<PortletPreferences>
    {
 
@@ -149,10 +273,4 @@
          return new LazyPageList<PortalKey>(la, 10);
       }
    }
-
-  @Override
-  public String toString()
-  {
-     return getClass().getSimpleName() + "[query=" + q + "]";
-  }
 }

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration1.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration1.xml	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration1.xml	2011-03-16 20:49:35 UTC (rev 6047)
@@ -101,11 +101,6 @@
   </component>
 
   <component>
-    <key>org.exoplatform.portal.mop.navigation.NavigationService</key>
-    <type>org.exoplatform.portal.mop.navigation.NavigationServiceWrapper</type>
-  </component>
-
-  <component>
     <key>org.exoplatform.portal.config.UserPortalConfigService</key>
     <type>org.exoplatform.portal.config.UserPortalConfigService</type>
   </component>

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration2.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration2.xml	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration2.xml	2011-03-16 20:49:35 UTC (rev 6047)
@@ -95,9 +95,6 @@
                 <value>
                   <string>system</string>
                 </value>
-                <value>
-                  <string>large</string>
-                </value>
               </collection>
             </field>
             <field name="ownerType">

Modified: epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/portal/portal/test/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/portal/portal/test/navigation.xml	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/component/portal/src/test/resources/portal/portal/test/navigation.xml	2011-03-16 20:49:35 UTC (rev 6047)
@@ -1,59 +1,46 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2009 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. -->
+<!--
 
+    Copyright (C) 2009 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.
+
+-->
+
 <node-navigation>
-   <owner-type>portal</owner-type>
-   <owner-id>test</owner-id>
-   <priority>1</priority>
+  <owner-type>portal</owner-type>
+  <owner-id>test</owner-id>
+  <priority>1</priority>
 
-   <page-nodes>
-      <node>
-         <uri>node_uri</uri>
-         <name>node_name</name>
-         <label>node_label</label>
-         <icon>node_icon</icon>
-         <start-publication-date>2000-03-21T01:33:00</start-publication-date>
-         <end-publication-date>2009-03-21T01:33:00</end-publication-date>
-         <visibility>TEMPORAL</visibility>
-         <page-reference>portal::test::test1</page-reference>
-      </node>
-      <node>
-         <uri>node_uri</uri>
-         <name>node_name1</name>
-         <label>node_label</label>
-         <icon>node_icon</icon>
-         <start-publication-date>2000-03-21T01:33:00</start-publication-date>
-         <end-publication-date>2050-03-21T01:33:00</end-publication-date>
-         <visibility>TEMPORAL</visibility>
-         <page-reference>portal::test::test1</page-reference>
-      </node>
-      <node>
-         <uri>node_uri</uri>
-         <name>node_name2</name>
-         <label>node_label</label>
-         <icon>node_icon</icon>
-         <start-publication-date>2050-03-21T01:33:00</start-publication-date>
-         <visibility>TEMPORAL</visibility>
-         <page-reference>portal::test::test1</page-reference>
-      </node>
-      <node>
-         <uri>node_uri</uri>
-         <name>node_name3</name>
-         <label>node_label</label>
-         <icon>node_icon</icon>
-         <end-publication-date>2050-03-21T01:33:00</end-publication-date>
-         <visibility>TEMPORAL</visibility>
-         <page-reference>portal::test::test1</page-reference>
-      </node>
-      <node>
-         <uri>node_uri</uri>
-         <name>node_name4</name>
-         <label>node_label4</label>
-         <page-reference>portal::test::test1</page-reference>
-      </node>
-   </page-nodes>
+  <page-nodes>
+	  <node>
+	    <uri>node_uri</uri>
+	    <name>node_name</name>
+	    <label>node_label</label>
+      <icon>node_icon</icon>
+      <start-publication-date>2000-03-21T01:33:00</start-publication-date>
+      <end-publication-date>2009-03-21T01:33:00</end-publication-date>
+      <visibility>TEMPORAL</visibility>
+	    <page-reference>portal::test::test</page-reference>
+	  </node>    
+    <node>
+      <uri>node_uri2</uri>
+      <name>node_name2</name>
+      <label>node_label2</label>
+      <page-reference>portal::test::test</page-reference>
+    </node>
+  </page-nodes>
 </node-navigation>

Modified: epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UITabbedDashboard.js
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UITabbedDashboard.js	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UITabbedDashboard.js	2011-03-16 20:49:35 UTC (rev 6047)
@@ -37,7 +37,7 @@
 			var DOMUtil = eXo.core.DOMUtil;
 			var portletFrag = DOMUtil.findAncestorByClass(inputElement, "PORTLET-FRAGMENT");
 			var compId = portletFrag.parentNode.id;
-			var nodeName = inputElement.id;
+			var nodeIndex = inputElement.id;
 			
 			//Send request to server to change node name
 			var href = eXo.env.server.portalBaseURL + "?portal:componentId=" + compId;
@@ -45,7 +45,7 @@
 			href += "&portal:isSecure=false";
 			href += "&uicomponent=UITabPaneDashboard";
 			href += "&op=RenameTabLabel";
-			href += "&objectId=" + nodeName;
+			href += "&objectId=" + nodeIndex;
 			href += "&newTabLabel=" + encodeURIComponent(newTabLabel);
 			window.location = href;
 		}
@@ -59,7 +59,7 @@
 		}
 	},
 
-	showEditLabelInput : function(selectedElement, nodeName, currentContent){
+	showEditLabelInput : function(selectedElement, nodeIndex, currentContent){
 		eXo.webui.UITabbedDashboard.backupElement = selectedElement;
 		var prNode = selectedElement.parentNode;
 		var tabContainer = eXo.core.DOMUtil.findAncestorByClass(prNode, "TabsContainer");
@@ -67,7 +67,7 @@
 		
 		var inputElement = document.createElement("input");
 		inputElement.type = "text";
-		inputElement.id = nodeName;
+		inputElement.id = nodeIndex;
 		inputElement.name = currentContent; // To store old value
 		inputElement.value = currentContent;
 		inputElement.style.border = "1px solid #b7b7b7";

Modified: epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js	2011-03-16 20:49:35 UTC (rev 6047)
@@ -29,7 +29,7 @@
   	childrenHeight += children[i].offsetHeight;  	
   }
   
-  if (!uiVirtualList.isFinished && childrenHeight <= uiVirtualList.offsetHeight && childrenHeight != 0) {
+  if (!uiVirtualList.isFinished && childrenHeight <= uiVirtualList.offsetHeight) {
 		uiVirtualList.onscroll();
   } else {  	
   	uiVirtualList.isInitiated = true;
@@ -50,7 +50,7 @@
 UIVirtualList.prototype.scrollMove = function(uiVirtualList, url) {
 	if (uiVirtualList.isFinished || uiVirtualList.isLocked) return;
 	var DOMUtil = eXo.core.DOMUtil;	
-	var componentHeight = uiVirtualList.offsetHeight;
+var componentHeight = uiVirtualList.offsetHeight;
 	var scrollPosition = uiVirtualList.scrollTop;
 	var scrollerHeight = uiVirtualList.scrollHeight;	
 	var scrollable_gap = scrollerHeight - (scrollPosition + componentHeight);	

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ar.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ar.xml	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ar.xml	2011-03-16 20:49:35 UTC (rev 6047)
@@ -839,7 +839,7 @@
 		# org.exoplatform.portal.component.customization.UIPageSelector#
 		#############################################################################
 	-->
-	<UIPageSelector>
+	<UIPageSelector2>
 		<header>
 			<name> اسم</name>
 			<id> صفحة رقم</id>
@@ -856,7 +856,7 @@
 			<name> #{word.name}</name>
 			<accessGroups> مجموعات الوصول</accessGroups>
 		</label>
-	</UIPageSelector>
+	</UIPageSelector2>
 	<UIPageBrowser>
 		<msg>
 			<NoPermission> لا يوجد لديك إذن لدخول هذه الصفحة.</NoPermission>
@@ -1057,7 +1057,7 @@
 			<label>
 				<PageNodeSetting>عقدة إعداد الصفحة </PageNodeSetting>
 				<Icon>#{word.icon} </Icon>
-				<UIPageSelector>تحديد الصفحة  </UIPageSelector>
+				<UIPageSelector2>تحديد الصفحة  </UIPageSelector2>
 			</label>
 		</tab>
 		<action>

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_de.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_de.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_de.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -393,18 +393,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Name
-UIPageSelector.header.id=Seiten-ID
-UIPageSelector.header.accessGroups=Gruppen
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Seiten leeren
-UIPageSelector.label.createPage=Seite erstellen
-UIPageSelector.label.searchandSelectPage=Seite suchen und  ausw\u00e4hlen
-UIPageSelector.label.currentSelectedPage=Ausgew\u00e4hlte Seite
-UIPageSelector.label.title=Titel
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Gruppen
+UIPageSelector2.header.name=Name
+UIPageSelector2.header.id=Seiten-ID
+UIPageSelector2.header.accessGroups=Gruppen
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Seiten leeren
+UIPageSelector2.label.createPage=Seite erstellen
+UIPageSelector2.label.searchandSelectPage=Seite suchen und  ausw\u00e4hlen
+UIPageSelector2.label.currentSelectedPage=Ausgew\u00e4hlte Seite
+UIPageSelector2.label.title=Titel
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Gruppen
 UIPageBrowser.msg.NoPermission=Sie haben keine Zugriffsberechtigung f\u00fcr diese Seite.
 UIPageBrowser.msg.PageNotExist=Die Seite existiert nicht.
 UIPageBrowser.msg.UserNotPermission=Sie haben keine Zugriffsberechtigung f\u00fcr die Seite dieses Knotens.
@@ -516,7 +516,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Standardeinstellung
 UIPageNodeForm.tab.label.PageNodeSetting=Seitenknoten-Eigenschaften
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Seiten-Auswahl
+UIPageNodeForm.tab.label.UIPageSelector2=Seiten-Auswahl
 
 
   #############################################################################

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -409,18 +409,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Name
-UIPageSelector.header.id=Page Id
-UIPageSelector.header.accessGroups=Access groups
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Clear Page
-UIPageSelector.label.createPage=Create Page
-UIPageSelector.label.searchandSelectPage=Search and Select Page
-UIPageSelector.label.currentSelectedPage=Selected Page Info
-UIPageSelector.label.title=Title
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Access groups
+UIPageSelector2.header.name=Name
+UIPageSelector2.header.id=Page Id
+UIPageSelector2.header.accessGroups=Access groups
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Clear Page
+UIPageSelector2.label.createPage=Create Page
+UIPageSelector2.label.searchandSelectPage=Search and Select Page
+UIPageSelector2.label.currentSelectedPage=Selected Page Info
+UIPageSelector2.label.title=Title
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Access groups
 UIPageBrowser.msg.NoPermission=You have no permission to access this page.
 UIPageBrowser.msg.PageNotExist=Page doesn't exist.
 UIPageBrowser.msg.UserNotPermission=You have no permission to access the node's page.
@@ -544,7 +544,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Get Default
 UIPageNodeForm.tab.label.PageNodeSetting=Page Node Setting
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Page Selector
+UIPageNodeForm.tab.label.UIPageSelector2=Page Selector
 UIPageNodeForm.action.Save=#{word.save}
 UIPageNodeForm.action.Back=#{word.back}
 
@@ -1292,7 +1292,6 @@
   
 UIPortalNavigation.Label.Next=Next
 UIPortalNavigation.Label.Previous=Previous
-UIPortalNavigation.msg.staleData=Node may be deleted
 
   #############################################################################
   #    org.exoplatform.portal.component.customization.UIDropDownConfigs #

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_es.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_es.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_es.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -391,18 +391,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Nombre
-UIPageSelector.header.id=Id de P\u00e1gina
-UIPageSelector.header.accessGroups=Grupos de Acceso
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Limpiar P\u00e1gina
-UIPageSelector.label.createPage=Crear P\u00e1gina
-UIPageSelector.label.searchandSelectPage=Buscar y Seleccionar P\u00e1gina
-UIPageSelector.label.currentSelectedPage=Informaci\u00f3n de la P\u00e1gina Seleccionada
-UIPageSelector.label.title=T\u00edtulo
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Grupos de Acceso
+UIPageSelector2.header.name=Nombre
+UIPageSelector2.header.id=Id de P\u00e1gina
+UIPageSelector2.header.accessGroups=Grupos de Acceso
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Limpiar P\u00e1gina
+UIPageSelector2.label.createPage=Crear P\u00e1gina
+UIPageSelector2.label.searchandSelectPage=Buscar y Seleccionar P\u00e1gina
+UIPageSelector2.label.currentSelectedPage=Informaci\u00f3n de la P\u00e1gina Seleccionada
+UIPageSelector2.label.title=T\u00edtulo
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Grupos de Acceso
 UIPageBrowser.msg.NoPermission=No tienes permisos para acceder a esta p\u00e1gina.
 UIPageBrowser.msg.PageNotExist=La p\u00e1gina no existe.
 UIPageBrowser.msg.UserNotPermission=No tienes permisos para acceder a la p\u00e1gina del nodo.
@@ -514,7 +514,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Obtener el por Defecto
 UIPageNodeForm.tab.label.PageNodeSetting=Ajustes de Nodo de P\u00e1gina
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Selector P\u00e1gina
+UIPageNodeForm.tab.label.UIPageSelector2=Selector P\u00e1gina
 
 
   #############################################################################

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_fr.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_fr.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_fr.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -382,18 +382,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Nom
-UIPageSelector.header.id=Id Page
-UIPageSelector.header.accessGroups=Groupe d'accès
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.searchandSelectPage=Recherche et Sélection d'une Page
-UIPageSelector.label.currentSelectedPage=Information sur la page sélectionnée
-UIPageSelector.label.title=Titre
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Groupes
-UIPageSelector.label.createPage=Créer Page
-UIPageSelector.label.clearPage=Clear Page
+UIPageSelector2.header.name=Nom
+UIPageSelector2.header.id=Id Page
+UIPageSelector2.header.accessGroups=Groupe d'accès
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.searchandSelectPage=Recherche et Sélection d'une Page
+UIPageSelector2.label.currentSelectedPage=Information sur la page sélectionnée
+UIPageSelector2.label.title=Titre
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Groupes
+UIPageSelector2.label.createPage=Créer Page
+UIPageSelector2.label.clearPage=Clear Page
 UIPageBrowser.msg.NoPermission=Vous n'avez pas les droits d'accès à cette page!
 UIPageBrowser.msg.PageNotExist=La page n'existe pas
 UIPageBrowser.msg.UserNotPermission=Vous n'avez pas les droits d'accès à ce noeud de page!
@@ -503,7 +503,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Valeur par défaut
 UIPageNodeForm.tab.label.PageNodeSetting=Configuration du noeud
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Sélecteur de page
+UIPageNodeForm.tab.label.UIPageSelector2=Sélecteur de page
 
 
   #############################################################################

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_it.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_it.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_it.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -409,18 +409,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Nome
-UIPageSelector.header.id=Id della Pagina
-UIPageSelector.header.accessGroups=Accesso ai Gruppi
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Azzera la pagina
-UIPageSelector.label.createPage=Crea la Pagina
-UIPageSelector.label.searchandSelectPage=Ricerca e seleziona la Pagina
-UIPageSelector.label.currentSelectedPage=Info sulla Pagina selezionata
-UIPageSelector.label.title=Titolo
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Accesso ai Gruppi
+UIPageSelector2.header.name=Nome
+UIPageSelector2.header.id=Id della Pagina
+UIPageSelector2.header.accessGroups=Accesso ai Gruppi
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Azzera la pagina
+UIPageSelector2.label.createPage=Crea la Pagina
+UIPageSelector2.label.searchandSelectPage=Ricerca e seleziona la Pagina
+UIPageSelector2.label.currentSelectedPage=Info sulla Pagina selezionata
+UIPageSelector2.label.title=Titolo
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Accesso ai Gruppi
 UIPageBrowser.msg.NoPermission=Non hai i permessi per accedere alla pagina.
 UIPageBrowser.msg.PageNotExist=La pagina non esiste.
 UIPageBrowser.msg.UserNotPermission=Non hai i permessi per accedere al nodo della pagina.
@@ -544,7 +544,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Ottieno il Default
 UIPageNodeForm.tab.label.PageNodeSetting=Preferenze del Nodo della Pagina
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Selettore della Pagina
+UIPageNodeForm.tab.label.UIPageSelector2=Selettore della Pagina
 UIPageNodeForm.action.Save=#{word.save}
 UIPageNodeForm.action.Back=#{word.back}
 

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ja.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ja.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ja.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -393,18 +393,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=\u540d\u524d
-UIPageSelector.header.id=\u30da\u30fc\u30b8ID
-UIPageSelector.header.accessGroups=\u30b0\u30eb\u30fc\u30d7\u306b\u30a2\u30af\u30bb\u30b9
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=\u30da\u30fc\u30b8\u3092\u30af\u30ea\u30a2
-UIPageSelector.label.createPage=\u30da\u30fc\u30b8\u3092\u4f5c\u6210 
-UIPageSelector.label.searchandSelectPage=\u30da\u30fc\u30b8\u3092\u691c\u7d22\u3057\u5909\u66f4
-UIPageSelector.label.currentSelectedPage=\u9078\u629e\u3057\u305f\u30da\u30fc\u30b8\u60c5\u5831
-UIPageSelector.label.title=\u30bf\u30a4\u30c8\u30eb
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=\u30b0\u30eb\u30fc\u30d7\u306b\u30a2\u30af\u30bb\u30b9
+UIPageSelector2.header.name=\u540d\u524d
+UIPageSelector2.header.id=\u30da\u30fc\u30b8ID
+UIPageSelector2.header.accessGroups=\u30b0\u30eb\u30fc\u30d7\u306b\u30a2\u30af\u30bb\u30b9
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=\u30da\u30fc\u30b8\u3092\u30af\u30ea\u30a2
+UIPageSelector2.label.createPage=\u30da\u30fc\u30b8\u3092\u4f5c\u6210 
+UIPageSelector2.label.searchandSelectPage=\u30da\u30fc\u30b8\u3092\u691c\u7d22\u3057\u5909\u66f4
+UIPageSelector2.label.currentSelectedPage=\u9078\u629e\u3057\u305f\u30da\u30fc\u30b8\u60c5\u5831
+UIPageSelector2.label.title=\u30bf\u30a4\u30c8\u30eb
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=\u30b0\u30eb\u30fc\u30d7\u306b\u30a2\u30af\u30bb\u30b9
 UIPageBrowser.msg.NoPermission=\u3053\u306e\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u305b\u3093\u3002
 UIPageBrowser.msg.PageNotExist=\u30da\u30fc\u30b8 \u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002
 UIPageBrowser.msg.UserNotPermission=\u305d\u306e\u30ce\u30fc\u30c9\u306e\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u305b\u3093\u3002
@@ -516,7 +516,7 @@
 UIPageNodeForm.Icon.title.SetDefault=\u30c7\u30d5\u30a9\u30eb\u30c8
 UIPageNodeForm.tab.label.PageNodeSetting=\u30da\u30fc\u30b8\u30ce\u30fc\u30c9\u8a2d\u5b9a
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=\u30da\u30fc\u30b8\u9078\u629e
+UIPageNodeForm.tab.label.UIPageSelector2=\u30da\u30fc\u30b8\u9078\u629e
 
 
   #############################################################################

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ko.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ko.xml	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ko.xml	2011-03-16 20:49:35 UTC (rev 6047)
@@ -617,7 +617,7 @@
          <done>완료</done>
       </action>
    </UIGroupSelector>
-   <UIPageSelector>
+   <UIPageSelector2>
       <header>
          <name>이름</name>
          <id>페이지 아이디</id>
@@ -634,7 +634,7 @@
          <name>#{word.name}</name>
          <accessGroups>액세스 그룹</accessGroups>
       </label>
-   </UIPageSelector>
+   </UIPageSelector2>
    <UIPageBrowser>
       <msg>
          <NoPermission>이 페이지의 액세스 권한이 없습니다.</NoPermission>
@@ -818,7 +818,7 @@
          <label>
             <PageNodeSetting>페이지 노드 설정</PageNodeSetting>
             <Icon>#{word.icon}</Icon>
-            <UIPageSelector>페이지 선택기</UIPageSelector>
+            <UIPageSelector2>페이지 선택기</UIPageSelector2>
          </label>
       </tab>
    </UIPageNodeForm>

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ne.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ne.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ne.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -393,18 +393,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=\u0928\u093e\u092e 
-UIPageSelector.header.id=\u092a\u0947\u091c Id
-UIPageSelector.header.accessGroups=\u0905\u0928\u0941\u092e\u0924\u0940 \u092a\u093e\u0909\u0928\u0947 \u0938\u092e\u0941\u0939\u0939\u0930\u0941 
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=\u092a\u0947\u091c \u0916\u093e\u0932\u0940 \u0917\u0930\u094d\u0928\u0941\u0939\u094b\u0938\u094d 
-UIPageSelector.label.createPage=\u092a\u0947\u091c \u092c\u0928\u093e\u0909\u0928\u0941\u0939\u094b\u0938\u094d 
-UIPageSelector.label.searchandSelectPage=\u0916\u094b\u091c\u0947\u0930 \u092a\u0947\u091c \u091b\u0928\u094c\u091f \u0917\u0930\u094d\u0928\u0941\u0939\u094b\u0938\u094d 
-UIPageSelector.label.currentSelectedPage=\u091b\u0928\u094c\u091f \u0917\u0930\u093f\u090f\u0915\u094b \u092a\u0947\u091c\u0915\u094b \u092a\u0930\u093f\u091a\u092f 
-UIPageSelector.label.title=\u0936\u093f\u0930\u094d\u0937\u0915
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=\u0905\u0928\u0941\u092e\u0924\u0940 \u092a\u093e\u0909\u0928\u0947 \u0938\u092e\u0941\u0939\u0939\u0930\u0941 
+UIPageSelector2.header.name=\u0928\u093e\u092e 
+UIPageSelector2.header.id=\u092a\u0947\u091c Id
+UIPageSelector2.header.accessGroups=\u0905\u0928\u0941\u092e\u0924\u0940 \u092a\u093e\u0909\u0928\u0947 \u0938\u092e\u0941\u0939\u0939\u0930\u0941 
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=\u092a\u0947\u091c \u0916\u093e\u0932\u0940 \u0917\u0930\u094d\u0928\u0941\u0939\u094b\u0938\u094d 
+UIPageSelector2.label.createPage=\u092a\u0947\u091c \u092c\u0928\u093e\u0909\u0928\u0941\u0939\u094b\u0938\u094d 
+UIPageSelector2.label.searchandSelectPage=\u0916\u094b\u091c\u0947\u0930 \u092a\u0947\u091c \u091b\u0928\u094c\u091f \u0917\u0930\u094d\u0928\u0941\u0939\u094b\u0938\u094d 
+UIPageSelector2.label.currentSelectedPage=\u091b\u0928\u094c\u091f \u0917\u0930\u093f\u090f\u0915\u094b \u092a\u0947\u091c\u0915\u094b \u092a\u0930\u093f\u091a\u092f 
+UIPageSelector2.label.title=\u0936\u093f\u0930\u094d\u0937\u0915
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=\u0905\u0928\u0941\u092e\u0924\u0940 \u092a\u093e\u0909\u0928\u0947 \u0938\u092e\u0941\u0939\u0939\u0930\u0941 
 UIPageBrowser.msg.NoPermission=\u0924\u092a\u093e\u0908\u0902\u0932\u093e\u0908 \u092f\u094b \u092a\u0947\u091c \u0939\u0947\u0930\u094d\u0928\u0947 \u0905\u0928\u0941\u092e\u0924\u0940 \u091b\u0948\u0928\u0964
 UIPageBrowser.msg.PageNotExist=\u092a\u0947\u091c \u0909\u092a\u0932\u092c\u094d\u0927 \u091b\u0948\u0928\u0964 
 UIPageBrowser.msg.UserNotPermission=\u0924\u092a\u093e\u0908\u0902\u0932\u093e\u0908 \u092f\u094b \u0928\u094b\u0921\u0915\u094b \u092a\u0947\u091c \u0939\u0947\u0930\u094d\u0928\u0947 \u0905\u0928\u0941\u092e\u0924\u0940 \u091b\u0948\u0928\u0964 
@@ -516,7 +516,7 @@
 UIPageNodeForm.Icon.title.SetDefault=\u0921\u093f\u092b\u094c\u0932\u094d\u091f \u092a\u093e\u0909\u0928\u0941\u0939\u094b\u0938\u094d 
 UIPageNodeForm.tab.label.PageNodeSetting=\u092a\u0947\u091c \u0928\u094b\u0921 \u0935\u094d\u092f\u0935\u0938\u094d\u0925\u093e\u092a\u0928
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=\u092a\u0947\u091c\u0915\u094b \u091b\u0928\u094c\u091f\u094d\u0915\u0930\u094d\u0924\u093e 
+UIPageNodeForm.tab.label.UIPageSelector2=\u092a\u0947\u091c\u0915\u094b \u091b\u0928\u094c\u091f\u094d\u0915\u0930\u094d\u0924\u093e 
 
   #############################################################################
   #              org.exoplatform.portal.component.customization.UIPageBrowser #

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_nl.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_nl.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_nl.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -393,18 +393,18 @@
 #              org.exoplatform.portal.component.customization.UIPageSelector#
 #############################################################################
 
-UIPageSelector.header.name=#{word.name}:
-UIPageSelector.header.id=Page Id
-UIPageSelector.header.accessGroups=Toegang groepen
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Wis pagina
-UIPageSelector.label.createPage=Cre\u00EBer pagina
-UIPageSelector.label.searchandSelectPage=Zoek en selecteer pagina
-UIPageSelector.label.currentSelectedPage=Geselecteerde pagina informatie
-UIPageSelector.label.title=#{word.title}
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Toegang groepen
+UIPageSelector2.header.name=#{word.name}:
+UIPageSelector2.header.id=Page Id
+UIPageSelector2.header.accessGroups=Toegang groepen
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Wis pagina
+UIPageSelector2.label.createPage=Cre\u00EBer pagina
+UIPageSelector2.label.searchandSelectPage=Zoek en selecteer pagina
+UIPageSelector2.label.currentSelectedPage=Geselecteerde pagina informatie
+UIPageSelector2.label.title=#{word.title}
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Toegang groepen
 UIPageBrowser.msg.NoPermission=U heeft geen permissies om deze pagina te bezoeken.
 UIPageBrowser.msg.PageNotExist=Pagina bestaat niet.
 UIPageBrowser.msg.UserNotPermission=U heeft geen permissie op deze node van de pagina.
@@ -516,7 +516,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Standaard
 UIPageNodeForm.tab.label.PageNodeSetting=Pagina node instellingen
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Pagina selecteur
+UIPageNodeForm.tab.label.UIPageSelector2=Pagina selecteur
 
 
 #############################################################################

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_pt_BR.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_pt_BR.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_pt_BR.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -389,18 +389,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Nome
-UIPageSelector.header.id=Id de Página
-UIPageSelector.header.accessGroups=Grupos de Acesso
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Limpar Página
-UIPageSelector.label.createPage=Criar Página
-UIPageSelector.label.searchandSelectPage=Selecionar Página
-UIPageSelector.label.currentSelectedPage=Informações da Página
-UIPageSelector.label.title=Título
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Grupos de Acesso
+UIPageSelector2.header.name=Nome
+UIPageSelector2.header.id=Id de Página
+UIPageSelector2.header.accessGroups=Grupos de Acesso
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Limpar Página
+UIPageSelector2.label.createPage=Criar Página
+UIPageSelector2.label.searchandSelectPage=Selecionar Página
+UIPageSelector2.label.currentSelectedPage=Informações da Página
+UIPageSelector2.label.title=Título
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Grupos de Acesso
 UIPageBrowser.msg.NoPermission=Usuário sem permissão para acessar essa página.
 UIPageBrowser.msg.PageNotExist=Página não existente.
 UIPageBrowser.msg.UserNotPermission=Usuário sem permissão para acessar o nodo dessa página.
@@ -512,7 +512,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Usar padrão
 UIPageNodeForm.tab.label.PageNodeSetting=Configurações de Nodo
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Seletor de Página
+UIPageNodeForm.tab.label.UIPageSelector2=Seletor de Página
 
 
   #############################################################################

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ru.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ru.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_ru.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -377,18 +377,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Название
-UIPageSelector.header.id=Идентификатор страницы
-UIPageSelector.header.accessGroups=Группы доступа
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Очистить страницу
-UIPageSelector.label.createPage=Создать страницу
-UIPageSelector.label.searchandSelectPage=Поиск и выбор страницы
-UIPageSelector.label.currentSelectedPage=Информация о выбранной странице
-UIPageSelector.label.title=Заголовок
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Группы доступа
+UIPageSelector2.header.name=Название
+UIPageSelector2.header.id=Идентификатор страницы
+UIPageSelector2.header.accessGroups=Группы доступа
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Очистить страницу
+UIPageSelector2.label.createPage=Создать страницу
+UIPageSelector2.label.searchandSelectPage=Поиск и выбор страницы
+UIPageSelector2.label.currentSelectedPage=Информация о выбранной странице
+UIPageSelector2.label.title=Заголовок
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Группы доступа
 UIPageBrowser.msg.NoPermission=У Вас нету прав доступа к этой странице.
 UIPageBrowser.msg.PageNotExist=Страница не существует.
 UIPageBrowser.msg.UserNotPermission=У Вас нету прав для доступа к страницам узла.
@@ -500,7 +500,7 @@
 UIPageNodeForm.Icon.title.SetDefault=По умолчанию
 UIPageNodeForm.tab.label.PageNodeSetting=Настройки узла страницы
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Страницы
+UIPageNodeForm.tab.label.UIPageSelector2=Страницы
 
 
   #############################################################################

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_uk.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_uk.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_uk.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -368,18 +368,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Назва
-UIPageSelector.header.id=Id сторінки
-UIPageSelector.header.accessGroups=Привілейовані групи
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Почистити сторінку
-UIPageSelector.label.createPage=Створити сторінку
-UIPageSelector.label.searchandSelectPage=Пошук і вибір сторінки
-UIPageSelector.label.currentSelectedPage=Інформація вибраної сторінки
-UIPageSelector.label.title=Назва
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Привілейовані групи
+UIPageSelector2.header.name=Назва
+UIPageSelector2.header.id=Id сторінки
+UIPageSelector2.header.accessGroups=Привілейовані групи
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Почистити сторінку
+UIPageSelector2.label.createPage=Створити сторінку
+UIPageSelector2.label.searchandSelectPage=Пошук і вибір сторінки
+UIPageSelector2.label.currentSelectedPage=Інформація вибраної сторінки
+UIPageSelector2.label.title=Назва
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Привілейовані групи
 UIPageBrowser.msg.NoPermission=У Вас недостатньо прав для доступу на цю сторінку.
 UIPageBrowser.msg.PageNotExist=Сторінка не існує.
 UIPageBrowser.msg.UserNotPermission=У Вас недостатньо прав для доступу на вузлову сторінку.
@@ -491,7 +491,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Взяти за замовчуванням
 UIPageNodeForm.tab.label.PageNodeSetting=Встановлення вузлової сторінки
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Селектор сторінок
+UIPageNodeForm.tab.label.UIPageSelector2=Селектор сторінок
 
 
   #############################################################################

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties	2011-03-16 20:49:35 UTC (rev 6047)
@@ -378,18 +378,18 @@
   #              org.exoplatform.portal.component.customization.UIPageSelector#
   #############################################################################
   
-UIPageSelector.header.name=Tên trang
-UIPageSelector.header.id=Mã trang
-UIPageSelector.header.accessGroups=Các nhóm truy nhập
-UIPageSelector.header.title=#{word.title}
-UIPageSelector.header.action=#{word.action}
-UIPageSelector.label.clearPage=Xóa trang
-UIPageSelector.label.createPage=Tạo trang
-UIPageSelector.label.searchandSelectPage=Tìm kiếm và chọn trang
-UIPageSelector.label.currentSelectedPage=Thông tin về trang bạn vừa chọn
-UIPageSelector.label.title=Tiêu đề trang
-UIPageSelector.label.name=#{word.name}
-UIPageSelector.label.accessGroups=Các nhóm truy nhập
+UIPageSelector2.header.name=Tên trang
+UIPageSelector2.header.id=Mã trang
+UIPageSelector2.header.accessGroups=Các nhóm truy nhập
+UIPageSelector2.header.title=#{word.title}
+UIPageSelector2.header.action=#{word.action}
+UIPageSelector2.label.clearPage=Xóa trang
+UIPageSelector2.label.createPage=Tạo trang
+UIPageSelector2.label.searchandSelectPage=Tìm kiếm và chọn trang
+UIPageSelector2.label.currentSelectedPage=Thông tin về trang bạn vừa chọn
+UIPageSelector2.label.title=Tiêu đề trang
+UIPageSelector2.label.name=#{word.name}
+UIPageSelector2.label.accessGroups=Các nhóm truy nhập
 UIPageBrowser.msg.NoPermission=Trang này không tồn tại hoặc bạn không được phân quyền để truy cập!
 UIPageBrowser.msg.PageNotExist=Trang này không tồn tại!
 UIPageBrowser.msg.UserNotPermission=Bạn không được phép truy cập vào trang này!
@@ -506,7 +506,7 @@
 UIPageNodeForm.Icon.title.SetDefault=Lấy mặc định
 UIPageNodeForm.tab.label.PageNodeSetting=Cấu hình node
 UIPageNodeForm.tab.label.Icon=#{word.icon}
-UIPageNodeForm.tab.label.UIPageSelector=Tùy chọn trang
+UIPageNodeForm.tab.label.UIPageSelector2=Tùy chọn trang
 UIPageNodeForm.action.Save=#{word.save}
 UIPageNodeForm.action.Back=#{word.back}
 

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_zh.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_zh.xml	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_zh.xml	2011-03-16 20:49:35 UTC (rev 6047)
@@ -578,7 +578,7 @@
          <done>完成</done>
       </action>
    </UIGroupSelector>
-   <UIPageSelector>
+   <UIPageSelector2>
       <header>
          <name>名称</name>
          <id>页面Id</id>
@@ -595,7 +595,7 @@
          <name>#{word.name}</name>
          <accessGroups>访问组</accessGroups>
       </label>
-   </UIPageSelector>
+   </UIPageSelector2>
    <UIPageBrowser>
       <msg>
          <NoPermission>您无权访问这个页面。</NoPermission>
@@ -774,7 +774,7 @@
          <label>
             <PageNodeSetting>页面节点设置</PageNodeSetting>
             <Icon>#{word.icon}</Icon>
-            <UIPageSelector>页面选择器</UIPageSelector>
+            <UIPageSelector2>页面选择器</UIPageSelector2>
          </label>
       </tab>
    </UIPageNodeForm>

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_zh_TW.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_zh_TW.xml	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_zh_TW.xml	2011-03-16 20:49:35 UTC (rev 6047)
@@ -722,7 +722,7 @@
          <done>完成</done>
       </action>
    </UIGroupSelector>
-   <UIPageSelector>
+   <UIPageSelector2>
       <header>
          <name>名稱</name>
          <id>頁面Id</id>
@@ -739,7 +739,7 @@
          <name>#{word.name}</name>
          <accessGroups>使用群組</accessGroups>
       </label>
-   </UIPageSelector>
+   </UIPageSelector2>
    <UIPageBrowser>
       <msg>
          <NoPermission>您無權使用這個頁面。</NoPermission>
@@ -919,7 +919,7 @@
          <label>
             <PageNodeSetting>頁面節點設定</PageNodeSetting>
             <Icon>#{word.icon}</Icon>
-            <UIPageSelector>頁面選擇器</UIPageSelector>
+            <UIPageSelector2>頁面選擇器</UIPageSelector2>
          </label>
       </tab>
    </UIPageNodeForm>

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml	2011-03-16 20:49:35 UTC (rev 6047)
@@ -94,11 +94,6 @@
   </component>
   
   <component>
-    <key>org.exoplatform.portal.mop.navigation.NavigationService</key>
-    <type>org.exoplatform.portal.mop.navigation.NavigationServiceWrapper</type>
-  </component>
-
-  <component>
     <key>org.exoplatform.portal.config.UserPortalConfigService</key>
     <type>org.exoplatform.portal.config.UserPortalConfigService</type>
     <component-plugins>           

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/page/UIPageSelector.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/page/UIPageSelector.gtmpl	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/page/UIPageSelector.gtmpl	2011-03-16 20:49:35 UTC (rev 6047)
@@ -2,7 +2,6 @@
 	import org.exoplatform.portal.config.model.Page; 
 	import org.exoplatform.webui.core.UIPopupWindow;
 	import org.exoplatform.webui.form.UIForm; 
-	import org.exoplatform.webui.form.UIFormInputSet;
 
 
 	Page page	= uicomponent.getPage();		
@@ -24,10 +23,8 @@
 	
 	def rcontext = _ctx.getRequestContext(); 
 	rcontext.getJavascriptManager().importJavascript('eXo.webui.UIPopupWindow');
-	
-	UIFormInputSet uiform = uicomponent.getChild(UIFormInputSet.class); 
 %>
-<div class="UIPageSelector" id="<%=uicomponent.getId();%>">
+<div class="UIPageSelector" id="<%=uicomponent.getId();%>" >
 	<div class="PageSelectorTitle">
 		<div class="Icon BlueInfoBox16x16Icon"><span></span></div>
 		<div class="Title"><%=_ctx.appRes(uicomponent.getId()+".label.currentSelectedPage")%></div>
@@ -35,37 +32,21 @@
 	</div>
 	<div class="UIFormInfo">
 		<div class="FormInfoBG">
-			<div class="FormInfoIcon UIForm">
-				<table class="UIPropertyInfo UIFormGrid">
-					<tr>
-						<td class="FieldLabel"><%=_ctx.appRes(uicomponent.getId()+".header.id")%>:</td>
-						<td class="FieldComponent">
-							<% if(page != null) { %>
-							$pageId
-							<% } %>
-						</td>
-					</tr>
-					<tr>
-						<td class="FieldLabel"><%=_ctx.appRes(uicomponent.getId()+".label.name")%>:</td>
-						<td class="FieldComponent">
-							<% if(page == null) { %>
-							<% uiform.renderChild("pageName");%>
-							<% } else { %>
-							$name
-							<% } %>
-						</td>
-					</tr>
-					<tr>
-						<td class="FieldLabel"><%=_ctx.appRes(uicomponent.getId()+".label.title")%>:</td>
-						<td class="FieldComponent">
-							<% if(page == null) { %>
-							<% uiform.renderChild("pageTitle");%>
-							<% } else { %>
-							$title
-							<% } %>
-						</td>
-					</tr>
-				</table>
+			<div class="FormInfoIcon">
+				<div class="UIPropertyInfo">
+					<div class="OverflowContainer">
+						<div class="PropertyName"><%=_ctx.appRes(uicomponent.getId()+".header.id")%>:</div>
+						<div class="PropertyValue">$pageId</div>
+					</div>
+					<div class="OverflowContainer">
+						<div class="PropertyName"><%=_ctx.appRes(uicomponent.getId()+".label.name")%>:</div>
+						<div class="PropertyValue">$name</div>
+					</div>
+					<div class="OverflowContainer">
+						<div class="PropertyName"><%=_ctx.appRes(uicomponent.getId()+".label.title")%>:</div>
+						<div class="PropertyValue">$title</div>
+					</div>
+				</div>
 			</div>
 		</div>
 	</div>
@@ -74,10 +55,9 @@
 			<tr>
 				<td>
 				 <%
-					String clearPageEvent = "javascript:void(0);"; 
+					String clearPageEvent = "#"; 
 					String css = "FloatBlockHidden ActionButton SimpleStyle"; 
-					def uiForm = uicomponent.getAncestorOfType(UIForm.class);
-					createPageEvent = uiForm.event("CreatePage"); 
+					def uiForm = uicomponent.getAncestorOfType(UIForm.class); 
 					if(page != null) {
 						clearPageEvent = uiForm.event("ClearPage"); 
 						css = "ActionButton SimpleStyle"; 
@@ -93,22 +73,8 @@
 							 	</div>
 							</div>
 						</div>					
-					</div>
-					<% if(page == null) { %>		
-					<div onclick="<%=createPageEvent%>" class="ActionButton SimpleStyle">
-						<div class="ButtonLeft">
-							<div class="ButtonRight">
-								<div class="ButtonMiddle">
-									<div class="GreenPlusPage16x16Icon Icon" title="<%=_ctx.appRes(uicomponent.getId()+".label.createPage")%>">
-										<a href="javascript:void(0);"><%=_ctx.appRes(uicomponent.getId() + ".label.createPage")%></a>
-									</div>
-							 	</div>
-							</div>
-						</div>					
 					</div> 
-					<% } %>
-					
-					<div class="ActionButton SimpleStyle" onclick="<%=uicomponent.event("OpenSelectPagePopUp")%>">
+					<div class="ActionButton SimpleStyle" onclick="javascript: eXo.webui.UIPopupWindow.show('<%=uicomponent.getChild(UIPopupWindow.class).getId();%>');">
 						<div class="ButtonLeft">
 							<div class="ButtonRight">
 								<div class="ButtonMiddle">
@@ -119,7 +85,6 @@
 							</div>
 						</div>
 					</div>
-					
 				</td>
 			</tr>
 		</table>

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/page/UIWizardPageSetInfo.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/page/UIWizardPageSetInfo.gtmpl	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/page/UIWizardPageSetInfo.gtmpl	2011-03-16 20:49:35 UTC (rev 6047)
@@ -1,21 +1,22 @@
 <%	
 	import org.exoplatform.portal.webui.navigation.UIPageNodeSelector;
+	import org.exoplatform.portal.config.model.PageNode;
 	import org.exoplatform.webui.core.UIComponent;
-
-	String nodeName = "/"; 	
+%>
+<%	
+	PageNode pageNode = uicomponent.getSelectedPageNode();
+	String nodeName = ""; 	
+	if(pageNode!=null ) nodeName = "/"+pageNode.getResolvedLabel();
 	boolean isNoSelecter = !uicomponent.getChild(UIPageNodeSelector.class).isRendered();
 %>
 <div class="UIWizardPageSetInfo">
 	<%uiform.begin()%>
 	<div class="<%=isNoSelecter ? "NoPageSelecter" : ""%>">
-  <%if(!isNoSelecter) {
-   	def pageNode = uicomponent.getSelectedPageNode();
-   	if( pageNode!=null && pageNode.getResolvedLabel() != null ) nodeName += pageNode.getResolvedLabel();
-  %>
+		<%if(!isNoSelecter) {%>
 		<div class="PageNodeContainer">
 			<% uicomponent.renderChild(UIPageNodeSelector.class); %>
 		</div>
-	<%}%>
+		<%}%>
 		<div class="SelectedPageInfo">
 			<div class="PageInfoContainer">
 				<div class="PageNodeInfo">

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl	2011-03-16 20:49:35 UTC (rev 6047)
@@ -1,7 +1,236 @@
-<%	
-		import org.exoplatform.portal.webui.navigation.UIPortalNavigation;
-					
-		def uiPortalNavigation = uicomponent.getChild(UIPortalNavigation.class); 
-		uiPortalNavigation.loadTreeNodes();
-		uicomponent.renderChildren();
-%>
\ No newline at end of file
+<div class="UISitemap">
+	<div class="ClearFix">
+		<div class="CollapseAll FloatLeft">Collapse All</div> 
+		<div class="ExpandAll FloatLeft">Expand All</div>
+	</div>
+	<div class="SitemapContent">
+		<div class="UISiteTree">
+			
+			<div class="Node ClearFix">
+				<div class="ExpandIcon FloatLeft">
+						<a class="NodeIcon DefaultPageIcon" href="#">Home</a>
+				</div>
+			</div>
+			
+			<div class="Node ClearFix">
+				<div class="ExpandIcon FloatLeft">
+						<a class="NodeIcon DefaultPageIcon" href="#">Web Explorer</a>
+				</div>
+			</div>
+			
+			<div class="Node ClearFix">
+				<div class="CollapseIcon FloatLeft">
+						<a class="NodeIcon DefaultPageIcon" href="#">My Link</a>
+				</div>
+												
+				<div class="ChildrenContainer FloatLeft">
+					<div class="Node ClearFix">
+						<div class="ExpandIcon FloatLeft">
+								<a class="NodeIcon DefaultPageIcon" href="#">Blog</a>
+						</div>
+					</div>
+			 		<div class="LastNode Node ClearFix">
+						<div class="CollapseIcon FloatLeft">
+								<a class="NodeIcon DefaultPageIcon" href="#">Facebook</a>
+						</div>
+						
+						<div class="ChildrenContainer FloatLeft">
+							<div class="Node ClearFix">
+								<div class="NullItem">
+									<div class="">
+										<a class="NodeIcon DefaultPageIcon" href="#">Samples link</a>
+									</div>
+								</div>
+							</div>
+							<div class="LastNode Node ClearFix">
+								<div class="NullItem"><a class="NodeIcon DefaultPageIcon" href="#">Samples link</a></div>
+							</div>
+						</div>
+						
+					</div>
+				</div><!--end ChildrenContainer-->
+										
+			</div><!--end Node-->
+			
+			<div class="Node ClearFix">
+				<div class="ExpandIcon FloatLeft"><a class="NodeIcon DefaultPageIcon" href="#">Register</a></div>											
+			</div>
+			
+			<div class="LastNode Node ClearFix">
+				<div class="ExpandIcon"><a class="NodeIcon DefaultPageIcon" href="#">Link</a></div>											
+			</div>
+			
+		</div>
+	</div>
+</div>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<!--
+<%
+	import org.exoplatform.webui.core.UIPortletApplication;
+	import org.exoplatform.portal.config.model.PageNode;
+	import org.exoplatform.portal.application.PortalRequestContext;
+	import org.exoplatform.portal.webui.util.Util;
+%>	
+<%
+	def navigations = uicomponent.getNavigations();
+	PortalRequestContext pcontext = Util.getPortalRequestContext();	
+	def String portalURI = pcontext.getPortalURI();
+	
+	UIPortletApplication siteMapPortlet = uicomponent.getParent();
+	def useAJAX = siteMapPortlet.isUseAjax();
+	
+	public void renderNextLevelNode(nav, children, int intLevel, String portalUri, boolean useAjax) {
+		if(intLevel > 4) return;
+		
+		for(PageNode node in children) {
+			String actionLink;
+			if(useAjax){
+				actionLink = uicomponent.event("SelectNode", nav.getId() + "::" + node.getUri());
+			}else{	
+				actionLink = portalUri + node.getUri();
+			}	
+			String iconType = node.getIcon();
+			if(iconType == null) {
+				iconType = "DefaultPageIcon";
+			}
+			
+			if(intLevel == 4) {
+				println """
+					<div class="Item">
+						<div class="Level$intLevel">
+							<div class="OverflowContainer">
+									<a class="IconItem ${iconType}" href="javascript: void(0);">...</a>
+							</div>
+						</div>
+					</div>
+				""";
+			 	break;
+			}
+			
+			String label = node.resolvedLabel;
+			String title = label;
+			if(label.length() > 38) {
+				label = label.substring(0,35) + "...";								
+			}
+							
+			println """
+				<div class="Item">
+					<div class="Level$intLevel">
+						<div class="OverflowContainer">
+		 	""";
+			 				if(node.pageReference != null) {
+								print """<a class="IconItem ${iconType}" href="$actionLink" title="$title">$label</a>""";
+							} else {
+								print """<a class="IconItem ${iconType}" title="$title">$label</a>""";
+							}
+		 	println """
+						</div>
+					</div>
+				</div>
+			""";
+			if (node.getChildren() != null) {
+				renderNextLevelNode(nav, node.getChildren(), intLevel + 1, portalUri, useAjax);
+			}
+		}
+	}
+%>
+<div class="UISitemap">
+	<div class="SitemapContainer">
+		<div class="SitemapBackground">
+			<%
+					boolean even = true;
+					String cssfloat = "left";
+					for(nav in navigations) { 
+						for(node in nav.getNodes()) { 
+							String iconType = node.getIcon();
+							if(iconType == null) {
+								iconType = "DefaultPageIcon";
+							}
+							if(even)cssfloat = "left";
+							else cssfloat = "right";
+							String blockFloat = "LeftBlock";
+							if(useAJAX){
+								actionLink = uicomponent.event("SelectNode", nav.getId() + "::" + node.getUri());
+							}else{
+								actionLink = portalURI + node.getUri();
+							}	
+							
+							String label = node.resolvedLabel;
+							String title = "";
+							if(label.length() > 35) {
+								title = label;
+								label = label.substring(0,32) + "...";								
+							}
+			%>
+			<div class="SitemapItemBox" style="float:${cssfloat};">
+				<div class="SitemapItemContainer">
+					<div class="TitleBar">
+						<%if(node.pageReference != null) {%>
+							<a href="<%=actionLink%>" class="Icon ${iconType}" title="$title">$label</a>
+						<%} else {%>
+							<a class="Icon ${iconType}" title="$title">$label</a>
+						<%}%>
+					</div>
+					<%if(node.getChildren() == null || node.getChildren().size() < 1) { %>
+							<div class="NestedSitemapItemBox">
+								<div class="SitemapItemBoxSelector BorderBox">											
+									<div class="Item">
+										<div class="SubItem">
+											<div class="Icon BlueInfoBox16x16Icon">
+												<%=_ctx.appRes("UISitemap.label.message")%>
+											</div>
+										</div>
+									</div>
+								</div>
+							</div> 
+					<%} else { %>
+							<div class="NestedSitemapItemBox">
+								<div class="SitemapItemBoxSelector">
+									<div class="ItemContainer">
+									 <% renderNextLevelNode(nav, node.getChildren(), 1, portalURI, useAJAX); %>
+									</div>
+								</div>
+							</div> 													
+						<%}%>
+				</div>
+			</div>
+			<% 
+						if(!even) {
+			%>
+						<div class="ClearBoth"><span></span></div>				
+			<%
+						}
+						even = !even;
+					}
+				}
+				if(!even){
+			%>
+			<div class="ClearBoth"><span></span></div> 
+			<% } %>
+		</div>			 
+	</div>
+</div>
+-->
\ No newline at end of file

Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl	2011-03-16 20:49:35 UTC (rev 6047)
@@ -1,78 +1,80 @@
 <%
 	import org.exoplatform.webui.core.UIPortletApplication;
-	import org.exoplatform.portal.mop.user.UserNode;
+	import org.exoplatform.portal.config.model.PageNode;
 	import org.exoplatform.portal.application.PortalRequestContext;
 	import org.exoplatform.portal.webui.util.Util;
 	import org.exoplatform.portal.webui.navigation.TreeNode;
-	import org.exoplatform.portal.mop.SiteKey;
-%>
+%>	
 <%
-	PortalRequestContext pcontext = Util.getPortalRequestContext();
+	def navigations = uicomponent.getNavigations();
+
+	PortalRequestContext pcontext = Util.getPortalRequestContext();	
 	def String portalURI = pcontext.getPortalURI();
-
+	
 	UIPortletApplication siteMapPortlet = uicomponent.getParent();
-
+	
 	def useAJAX = siteMapPortlet.isUseAjax();
-
+	
 	def actionExpandAll = uicomponent.event("ExpandAllNode");
 	def actionCollapseAll = uicomponent.event("CollapseAllNode");
-
+							
 	public void renderNodes(TreeNode rootTree, String portalUri, boolean useAjax) {
-		def childrenNodes=rootTree.getChildren();
-		int childrenSize = childrenNodes.size() ;
-		int size = 0;
-		for(treeNode in childrenNodes) {
-
+		List childrenNodes=rootTree.getChildren();
+		int childrenSize = childrenNodes.size() ;  
+		int size = 0;	
+		for(treeNode in childrenNodes) {	
+		
 			// count size;
 			size++;
-
+			
 			node = treeNode.getNode();
-	    def treePath = node.getId();
-			String label = node.getEncodedResolvedLabel();
-			actionExpand = uicomponent.event("ExpandNode", treePath).replace("javascript:", "");
-			def actionCollapse = "ajaxAsyncGetRequest('" + uicomponent.url("CollapseNode", treePath) + "', true)";
+			nav = treeNode.getNavigation();
+			String label = node.encodedResolvedLabel;	
+			actionExpand = uicomponent.event("ExpandNode", nav.getId() + "::" + node.getUri());				
+			def actionCollapse = "ajaxAsyncGetRequest('" + uicomponent.url("CollapseNode",nav.getId() + "::" + node.getUri()) + "', true)";	
+			
 			if(useAjax){
-				actionLink = uicomponent.event("SelectNode", treePath);
-			}else{
-				actionLink = portalUri + node.getURI();
-			}
-
+				actionLink = uicomponent.event("SelectNode", nav.getId() + "::" + node.getUri());
+			}else{	
+				actionLink = portalUri + node.getUri();
+			}	
+			
 			lastNode = '';
-
+			
 			if (size == childrenSize) {
 				lastNode = 'LastNode';
 			}
 			// if node have child
-
-			if(treeNode.hasChild()) {
+			
+			if(treeNode.isHasChild()) {
 				if (treeNode.isExpanded()) {
 					println """
 						<div class="$lastNode Node">
-							<div class="CollapseIcon ClearFix" onclick="eXo.portal.UIPortal.collapseExpand(this, function() {$actionExpand},  function() {$actionCollapse})">
+							<div class="CollapseIcon ClearFix" onclick="eXo.portal.UIPortal.collapseExpand(this);$actionCollapse">
 					""";
-					      if(treeNode.getNode().getPageRef() == null) println "<a class='NodeIcon DefaultPageIcon' href='javascript:void(0);'>$label</a>";
+					      if(treeNode.getNode().getPageReference() == null) println "<a class='NodeIcon DefaultPageIcon' href='javascript:void(0);'>$label</a>";
 					      else println "<a class='NodeIcon DefaultPageIcon' href='$actionLink'>$label</a>";
 					println """
 							</div>
 							<div class="ChildrenContainer" style="display: block">
 					""";
-
+					
 					renderNodes(treeNode, portalUri, useAjax);
-
+					
 				} else {
 					println """
 						<div class="$lastNode Node">
-							<div class="ExpandIcon ClearFix" onclick="eXo.portal.UIPortal.collapseExpand(this, function() {$actionExpand}, function() {$actionCollapse})">
+							<div class="ExpandIcon ClearFix" onclick="if(eXo.portal.UIPortal.collapseExpand(this)){$actionExpand}">
 					""";
-					      if(treeNode.getNode().getPageRef() == null) println "<a class='NodeIcon DefaultPageIcon' href='javascript:void(0);'>$label</a>";
+					      if(treeNode.getNode().getPageReference() == null) println "<a class='NodeIcon DefaultPageIcon' href='javascript:void(0);'>$label</a>";
 					      else println "<a class='NodeIcon DefaultPageIcon' href='$actionLink'>$label</a>";
 					println """
 							</div>
 							<div class="ChildrenContainer" style="display: none">
 					""";
 				}
-
-
+				
+				
 				println """
 						</div>
 					</div>
@@ -87,24 +89,24 @@
 							</div>
 						</div>
 					</div>
-
+					
 				""";
-
+				
 			}
 
-		}
-	  }
+		}		
+	  }  
 %>
 
 <div id="UISiteMap" class="UISitemap" >
 	<div class="ClearFix">
 		<div class="CollapseAll FloatLeft" onclick="eXo.portal.UIPortal.collapseExpand(this);$actionCollapseAll">
 			<%=_ctx.appRes(siteMapPortlet.getName() + ".label.CollapseAll")%>
+		</div> 
+		<div class="ExpandAll FloatLeft" onclick="{$actionExpandAll}">
+			<%=_ctx.appRes(siteMapPortlet.getName() + ".label.ExpandAll")%>
 		</div>
-  <div class="ExpandAll FloatLeft" onclick="{$actionExpandAll}">
-			<%//_ctx.appRes(siteMapPortlet.getName() + ".label.ExpandAll")%>
 	</div>
-	</div>
 	<div class="SitemapContent">
 		<div class="UISiteTree">
 			<% TreeNode treeNodeRoot = uicomponent.getTreeNodes() ;%>

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/TreeNode.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/TreeNode.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/TreeNode.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -19,13 +19,12 @@
 
 package org.exoplatform.portal.webui.navigation;
 
-import org.exoplatform.portal.mop.user.UserNode;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
+
 import javax.jcr.RepositoryException;
 
 /**
@@ -37,27 +36,31 @@
  */
 public class TreeNode
 {
+   //TODO Need use this class for BC TreeNode
    private boolean isExpanded_;
 
-   private UserNode node_;
+   private boolean hasChild_;
 
-   private List<TreeNode> children_ = Collections.emptyList();
+   private String path_;
 
-   private Map<String, TreeNode> cachedTreeNodes_;
+   private PageNode node_;
 
-   private TreeNode rootNode;
+   private PageNavigation navigation_;
 
-   public TreeNode()
+   private List<TreeNode> children_ = new ArrayList<TreeNode>();
+
+   public TreeNode(PageNode node, PageNavigation nav, boolean hasChild)
    {
-      cachedTreeNodes_ = new HashMap<String, TreeNode>();
-      rootNode = this;
+      this(node, node.getUri(), nav, hasChild);
    }
 
-   private TreeNode(UserNode node, TreeNode rootNode)
+   private TreeNode(PageNode node, String path, PageNavigation nav, boolean hasChild)
    {
       node_ = node;
+      navigation_ = nav;
       isExpanded_ = false;
-      this.rootNode = rootNode; 
+      path_ = path;
+      hasChild_ = hasChild;
    }
 
    public boolean isExpanded()
@@ -75,11 +78,26 @@
       return node_.getName();
    }
 
-   public UserNode getNode()
-   {               
+   public String getPath()
+   {
+      return path_;
+   }
+
+   public String getNodePath() throws RepositoryException
+   {
+      return node_.getUri();
+   }
+
+   public PageNode getNode()
+   {
       return node_;
    }
 
+   public void setNode(PageNode node)
+   {
+      node_ = node;
+   }
+
    public List<TreeNode> getChildren()
    {
       return children_;
@@ -90,32 +108,61 @@
       return children_.size();
    }
 
-   public void setChildren(Collection<UserNode> children) throws Exception
+   public TreeNode getChildByPath(String path, TreeNode treeNode)
    {
-      if (children == null)
-         return;
-                                   
-      children_ = new LinkedList<TreeNode>();      
-      for (UserNode child : children)
+      TreeNode returnVal = null;
+
+      for (TreeNode child : treeNode.getChildren())
       {
-         TreeNode node = new TreeNode(child, rootNode);
-         children_.add(node);
-         rootNode.cachedTreeNodes_.put(child.getId(), node);
+
+         if (returnVal != null)
+            continue;
+
+         if (child.getPath().equals(path))
+         {
+            returnVal = child;
+         }
+         else if (child.getChildren() != null)
+         {
+            returnVal = child.getChildByPath(path, child);
+         }
       }
+
+      return returnVal;
    }
 
-   public boolean hasChild()
+   public void setChildren(List<PageNode> children, PageNavigation nav) throws Exception
    {
-      return node_.getChildrenCount() > 0;
+      setExpanded(true);
+      for (PageNode child : children)
+      {
+         boolean isHasChild = (child.getChildren().size() > 0);
+         children_.add(new TreeNode(child, nav.getId() + "::" + child.getUri(), nav, isHasChild));
+      }
    }
 
-   /**
-    * Help to find nodes on the whole tree, not only in the childrens of this node
-     * @param nodeId - id of the UserNode
-    * @return null if not found
-    */
-   public TreeNode findNodes(String nodeId)
+   public void addChildren(TreeNode treeNode)
    {
-      return rootNode.cachedTreeNodes_.get(nodeId);
+      children_.add(treeNode);
    }
+
+   public void setNavigation(PageNavigation navigation_)
+   {
+      this.navigation_ = navigation_;
+   }
+
+   public PageNavigation getNavigation()
+   {
+      return navigation_;
+   }
+
+   public void setHasChild(boolean hasChild)
+   {
+      this.hasChild_ = hasChild;
+   }
+
+   public boolean isHasChild()
+   {
+      return hasChild_;
+   }
 }
\ No newline at end of file

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -27,13 +27,6 @@
 import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.PageNavigation;
 import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.SiteType;
-import org.exoplatform.portal.mop.navigation.Navigation;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.mop.navigation.NavigationState;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserPortal;
 import org.exoplatform.portal.webui.portal.UIPortal;
 import org.exoplatform.portal.webui.util.Util;
 import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
@@ -56,7 +49,6 @@
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -116,18 +108,9 @@
          listGroup = new ArrayList<String>();
       }
 
-      //Filter all groups having navigation
-      NavigationService navigationService = getApplicationComponent(NavigationService.class);
-      List<String> groupsHavingNavigation = new ArrayList<String>();
-      for(String groupName : listGroup)
-      {
-         Navigation navigation = navigationService.loadNavigation(SiteKey.group(groupName));
-         if(navigation != null && navigation.getState() != null)
-         {
-            groupsHavingNavigation.add(groupName);
-         }
-      }
-      listGroup.removeAll(groupsHavingNavigation);
+      UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
+      Set<String> groupIdsHavingNavigation = configService.findGroupHavingNavigation();
+      listGroup.removeAll(groupIdsHavingNavigation);
 
       UIVirtualList virtualList = getChild(UIVirtualList.class);
       virtualList.dataBind(new ObjectPageList<String>(listGroup, listGroup.size()));
@@ -144,20 +127,27 @@
          String ownerId = event.getRequestContext().getRequestParameter(OBJECTID);
          ownerId = URLDecoder.decode(ownerId);
 
+         //Add navigation
+         PageNavigation pageNav = new PageNavigation();
+
+         // set properties for navigation
+         pageNav.setPriority(1);
+         pageNav.setModifiable(true);
+         pageNav.setOwnerId(ownerId);
+         pageNav.setOwnerType(PortalConfig.GROUP_TYPE);
+         //UIPortalApplication uiPortalApp = uiForm.getAncestorOfType(UIPortalApplication.class);      
          UIPortalApplication uiPortalApp = Util.getUIPortal().getAncestorOfType(UIPortalApplication.class);
 
-         // ensure this navigation does not exist
-         NavigationService navigationService = uicomp.getApplicationComponent(NavigationService.class);
-         Navigation navigation = navigationService.loadNavigation(SiteKey.group(ownerId));
-         if (navigation != null && navigation.getState() != null)
+         // ensure this navigation is not exist
+         DataStorage dataService = uicomp.getApplicationComponent(DataStorage.class);
+         if (dataService.getPageNavigation(pageNav.getOwnerType(), pageNav.getOwnerId()) != null)
          {
             uiPortalApp.addMessage(new ApplicationMessage("UIPageNavigationForm.msg.existPageNavigation",
-               new String[]{ownerId}));
+               new String[]{pageNav.getOwnerId()}));
             return;
          }
 
-         // Create portal config of the group when it does not exist
-         DataStorage dataService = uicomp.getApplicationComponent(DataStorage.class);
+         // Create group when it does not exist
          if (dataService.getPortalConfig("group", ownerId) == null)
          {
             UserPortalConfigService configService = uicomp.getApplicationComponent(UserPortalConfigService.class);
@@ -165,8 +155,12 @@
          }
 
          // create navigation for group
-         navigationService.saveNavigation(SiteKey.group(ownerId), new NavigationState(0));
+         dataService.create(pageNav);
 
+         uiPortalApp.getUserPortalConfig().getNavigations().add(0, pageNav);
+         uiPortalApp.getNavigations().add(0, pageNav);
+         uiPortalApp.localizeNavigations();
+         
          //Update group navigation list
          ctx.addUIComponentToUpdateByAjax(uicomp);
 

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -25,9 +25,8 @@
 import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.PageNavigation;
 import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.user.UserNavigation;
 import org.exoplatform.portal.webui.page.UIPageNodeForm;
+import org.exoplatform.portal.webui.portal.UIPortal;
 import org.exoplatform.portal.webui.util.Util;
 import org.exoplatform.portal.webui.workspace.UIPortalApplication;
 import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
@@ -42,6 +41,8 @@
 import org.exoplatform.webui.event.Event;
 import org.exoplatform.webui.event.EventListener;
 
+import java.util.List;
+
 @ComponentConfig(template = "system:/groovy/portal/webui/navigation/UINavigationManagement.gtmpl", events = {
    @EventConfig(listeners = UINavigationManagement.SaveActionListener.class),
    @EventConfig(listeners = UINavigationManagement.AddRootNodeActionListener.class)})
@@ -98,49 +99,88 @@
          PortalRequestContext prContext = Util.getPortalRequestContext();
          UINavigationManagement uiManagement = event.getSource();
          UINavigationNodeSelector uiNodeSelector = uiManagement.getChild(UINavigationNodeSelector.class);
+         DataStorage dataService = uiManagement.getApplicationComponent(DataStorage.class);
          UserPortalConfigService portalConfigService = uiManagement.getApplicationComponent(UserPortalConfigService.class);
-
-         UIPopupWindow uiPopup = uiManagement.getParent();
-         uiPopup.setShow(false);
-         uiPopup.setUIComponent(null);
-         UIPortalApplication uiPortalApp = (UIPortalApplication)prContext.getUIApplication();
-         UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
-         prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
-         prContext.setFullRender(true);
-
-         UserNavigation navigation = uiNodeSelector.getEdittedNavigation();
-
-         SiteKey siteKey = navigation.getKey();
-         String editedOwnerId = siteKey.getName();
-
+         
+         PageNavigation navigation = uiNodeSelector.getEdittedNavigation();
+         String editedOwnerType = navigation.getOwnerType();
+         String editedOwnerId = navigation.getOwnerId();
          // Check existed
-         UserPortalConfig userPortalConfig;
-         if (PortalConfig.PORTAL_TYPE.equals(siteKey.getTypeName()))
+         PageNavigation persistNavigation =  dataService.getPageNavigation(editedOwnerType, editedOwnerId);
+         if (persistNavigation == null)
          {
-            userPortalConfig = portalConfigService.getUserPortalConfig(editedOwnerId, event.getRequestContext().getRemoteUser());
-
-            if (userPortalConfig == null)
+            UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
+            uiApp.addMessage(new ApplicationMessage("UINavigationManagement.msg.NavigationNotExistAnymore", null));
+            UIPopupWindow uiPopup = uiManagement.getParent();
+            uiPopup.setShow(false);
+            UIPortalApplication uiPortalApp = (UIPortalApplication)prContext.getUIApplication();
+            UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+            prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
+            prContext.setFullRender(true);
+            return;
+         }
+         
+         if(PortalConfig.PORTAL_TYPE.equals(navigation.getOwnerType()))
+         {
+            UserPortalConfig portalConfig = portalConfigService.getUserPortalConfig(navigation.getOwnerId(), prContext.getRemoteUser());
+            if(portalConfig != null)
             {
+               dataService.save(navigation);
+            }
+            else
+            {
                UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
                uiApp.addMessage(new ApplicationMessage("UIPortalForm.msg.notExistAnymore", null));
+               UIPopupWindow uiPopup = uiManagement.getParent();
+               uiPopup.setShow(false);
+               UIPortalApplication uiPortalApp = (UIPortalApplication)prContext.getUIApplication();
+               UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+               prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
+               prContext.setFullRender(true);
                return;
             }
          }
          else
          {
-            userPortalConfig =  portalConfigService.getUserPortalConfig(prContext.getPortalOwner(), event.getRequestContext().getRemoteUser());
+            dataService.save(navigation);
          }
 
-         UserNavigation persistNavigation =  userPortalConfig.getUserPortal().getNavigation(siteKey);
-         if (persistNavigation == null)
+         // Reload navigation here as some navigation could exist in the back end such as system navigations
+         // that would not be in the current edited UI navigation
+         navigation = dataService.getPageNavigation(navigation.getOwnerType(), navigation.getOwnerId());
+
+         UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
+         setNavigation(uiPortalApp.getNavigations(), navigation);
+
+         // Need to relocalize as it was loaded from storage
+         uiPortalApp.localizeNavigations();
+         
+         //Update UIPortal corredponding to edited navigation
+         UIPortal targetedUIPortal = uiPortalApp.getCachedUIPortal(editedOwnerType, editedOwnerId);
+         if(targetedUIPortal != null)
          {
-            UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
-            uiApp.addMessage(new ApplicationMessage("UINavigationManagement.msg.NavigationNotExistAnymore", null));
-            return;
-         }         
+            targetedUIPortal.setNavigation(navigation);
+         }
+         
+         UIPopupWindow uiPopup = uiManagement.getParent();
+         uiPopup.setShow(false);
+         UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+         prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
+         prContext.setFullRender(true);
+      }
 
-         uiNodeSelector.getRootNode().save();
+      private void setNavigation(List<PageNavigation> navs, PageNavigation nav)
+      {
+         for (int i = 0; i < navs.size(); i++)
+         {
+            if (navs.get(i).getId() == nav.getId())
+            {
+               navs.set(i, nav);
+               return;
+            }
+         }
       }
+
    }
 
    static public class AddRootNodeActionListener extends EventListener<UINavigationManagement>
@@ -155,9 +195,10 @@
          UIPageNodeForm uiNodeForm = uiManagementPopup.createUIComponent(UIPageNodeForm.class, null, null);
          uiNodeForm.setValues(null);
          uiManagementPopup.setUIComponent(uiNodeForm);
+         PageNavigation nav = uiNodeSelector.getEdittedNavigation();
+         uiNodeForm.setSelectedParent(nav);
 
-         uiNodeForm.setSelectedParent(uiNodeSelector.getSelectedNode());
-         uiNodeForm.setContextPageNavigation(uiNodeSelector.getEdittedNavigation());
+         uiNodeForm.setContextPageNavigation(nav);
 
          uiManagementPopup.setWindowSize(800, 500);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiManagementPopup.getParent());

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -19,19 +19,14 @@
 
 package org.exoplatform.portal.webui.navigation;
 
-import org.exoplatform.portal.config.DataStorage;
 import org.exoplatform.portal.config.UserACL;
 import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.mop.SiteKey;
+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.mop.Visibility;
-import org.exoplatform.portal.mop.navigation.NavigationServiceException;
-import org.exoplatform.portal.mop.navigation.NodeFilter;
-import org.exoplatform.portal.mop.navigation.Scope;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserNode;
-import org.exoplatform.portal.mop.user.UserNodePredicate;
-import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.portal.webui.navigation.ParentChildPair;
 import org.exoplatform.portal.webui.page.UIPage;
 import org.exoplatform.portal.webui.page.UIPageNodeForm;
 import org.exoplatform.portal.webui.portal.UIPortalComposer;
@@ -41,6 +36,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.resources.LocaleConfig;
+import org.exoplatform.services.resources.LocaleConfigService;
 import org.exoplatform.web.application.ApplicationMessage;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -49,16 +46,17 @@
 import org.exoplatform.webui.core.UIApplication;
 import org.exoplatform.webui.core.UIComponent;
 import org.exoplatform.webui.core.UIContainer;
+import org.exoplatform.webui.core.UIFilterableTree;
 import org.exoplatform.webui.core.UIPopupWindow;
 import org.exoplatform.webui.core.UIRightClickPopupMenu;
 import org.exoplatform.webui.core.UITree;
 import org.exoplatform.webui.event.Event;
 import org.exoplatform.webui.event.EventListener;
+
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.Locale;
+import java.util.ResourceBundle;
 
 /** Copied by The eXo Platform SARL Author May 28, 2009 3:07:15 PM */
 @ComponentConfigs({
@@ -79,33 +77,28 @@
       @EventConfig(listeners = UINavigationNodeSelector.PasteNodeActionListener.class)})})
 public class UINavigationNodeSelector extends UIContainer
 {
+
+   //private List<PageNavigation> navigations;
    
-   private UserNavigation edittedNavigation;
+   private PageNavigation edittedNavigation;
+   
+   private TreeNodeData edittedTreeNodeData;
 
    /** This field holds transient copy of edittedTreeNodeData, which is used when user pastes the content to a new tree node */
    private TreeNodeData copyOfTreeNodeData;
 
-   private TreeNodeData rootNode;
-   
-   private UserPortal userPortal;
+   private List<PageNavigation> deleteNavigations = new ArrayList<PageNavigation>();
 
-   private NodeFilter nodeFilter;
-
-   private static final Scope NODE_SCOPE = Scope.CHILDREN;
-
-   private Map<String, TreeNodeData> cachedNodes = new HashMap<String, TreeNodeData>();
-
    public UINavigationNodeSelector() throws Exception
    {
       UIRightClickPopupMenu rightClickPopup =
          addChild(UIRightClickPopupMenu.class, "UINavigationNodeSelectorPopupMenu", null).setRendered(true);
       rightClickPopup.setActions(new String[]{"AddNode", "PasteNode"});
 
-      UITree uiTree = addChild(UITree.class, null, "TreeNodeSelector");
+      UIFilterableTree uiTree = addChild(UIFilterableTree.class, null, "TreeNodeSelector");
       uiTree.setIcon("DefaultPageIcon");
       uiTree.setSelectedIcon("DefaultPageIcon");
-      uiTree.setBeanIdField("Id");
-      uiTree.setBeanChildCountField("childrenCount");
+      uiTree.setBeanIdField("uri");
       uiTree.setBeanLabelField("encodedResolvedLabel");
       uiTree.setBeanIconField("icon");
       
@@ -114,143 +107,191 @@
       uiPopupMenu.setActions(new String[]{"AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CloneNode",
          "CutNode", "DeleteNode", "MoveUp", "MoveDown"});
       uiTree.setUIRightClickPopupMenu(uiPopupMenu);
+      setupTreeFilter();
    }
+   
+   /**
+    * Setup a filter on the tree node. In this case, SYSTEM node is not displayed if user is not super user
+    *
+    */
+   private void setupTreeFilter()
+   {
+      UIFilterableTree.TreeNodeFilter nodeFilter = new UIFilterableTree.TreeNodeFilter()
+      {
+         public boolean filterThisNode(Object nodeObject, WebuiRequestContext context)
+         {
+            boolean isSystemNode = (((PageNode)nodeObject).getVisibility() == Visibility.SYSTEM );
+            if(!isSystemNode)
+            {
+               return false;
+            }else
+            {
+               UserACL userACL = context.getUIApplication().getApplicationComponent(UserACL.class);
+               return !userACL.getSuperUser().equals(context.getRemoteUser());
+            }
+            
+         }
+      };
+      this.getChild(UIFilterableTree.class).setTreeNodeFilter(nodeFilter);
+   }
+
+   public void setEdittedNavigation(PageNavigation _filteredEdittedNavigation) throws Exception
+   {
+      this.edittedNavigation = _filteredEdittedNavigation;
+   }
+   
+   public PageNavigation getEdittedNavigation()
+   {
+      return this.edittedNavigation;
+   }
       
    /**
     * Init the UITree wrapped in UINavigationNodeSelector and localize the label
     * @throws Exception
     */
    public void initTreeData() throws Exception
-   {      
-      if(edittedNavigation == null || userPortal == null)
-      {
-         throw new IllegalStateException("edittedNavigation and userPortal must be initialized first");
-      }
-
-      cachedNodes.clear();
-
-      initRootNode();
-      selectNode(rootNode);
-   }
-
-   public TreeNodeData selectNode(String nodeID) throws Exception
    {
-      TreeNodeData node = searchNode(nodeID);
-      return selectNode(node);
+      WebuiRequestContext requestContext = WebuiRequestContext.getCurrentInstance();
+      localizeNavigation(requestContext.getLocale());
+      
+      initEdittedTreeNodeData();
    }
 
-   public TreeNodeData selectNode(TreeNodeData node) throws Exception
+   /**
+    * Init the edited node as well as its parent, navigation
+    *
+    */
+   private void initEdittedTreeNodeData()
    {
-      node = lazyLoadData(node);
-
-      if (node == null)
+      if(edittedNavigation == null)
       {
-         return null;
+         return;
       }
-
-      UITree tree = getChild(UITree.class);
-      tree.setSelected(node);
-      if (node.getParent() == null)
+      if (edittedTreeNodeData == null)
       {
-         tree.setChildren(null);
-         tree.setSibbling(node.getChildren());
-         tree.setParentSelected(null);
+         edittedTreeNodeData = new TreeNodeData(edittedNavigation);
+         if(edittedTreeNodeData.getNode() != null)
+         {
+            selectPageNodeByUri(edittedTreeNodeData.getNode().getUri());
+         }
       }
-      else
-      {
-         TreeNodeData parentNode = node.getParent();
-         tree.setChildren(node.getChildren());                    
-         tree.setSibbling(parentNode.getChildren());
-         tree.setParentSelected(parentNode);
-      }
-      return node;
+      
+      UITree tree = getChild(UITree.class);
+      tree.setSibbling(edittedNavigation.getNodes());
    }
+   
 
-   public TreeNodeData searchNode(String nodeID)
+   private void localizeNavigation(Locale locale)
    {
-      if (nodeID == null || nodeID.trim().isEmpty())
+      String localeLanguage = (locale.getCountry().length() > 0) ? locale.getLanguage() + "_" + locale.getCountry() : locale.getLanguage();
+      LocaleConfig localeConfig =
+         getApplicationComponent(LocaleConfigService.class).getLocaleConfig(localeLanguage);
+      String ownerType = edittedNavigation.getOwnerType();
+      if (!PortalConfig.USER_TYPE.equals(ownerType))
       {
-         nodeID = rootNode.getId();
+         String ownerId = edittedNavigation.getOwnerId();
+         if (PortalConfig.GROUP_TYPE.equals(ownerType))
+         {
+            // Remove the trailing '/' for a group
+            ownerId = ownerId.substring(1);
+         }
+         ResourceBundle res = localeConfig.getNavigationResourceBundle(ownerType, ownerId);
+         for (PageNode node : edittedNavigation.getNodes())
+         {
+            resolveLabel(res, node);
+         }
       }
-
-      return cachedNodes.get(nodeID);
    }
 
-   private TreeNodeData initRootNode() throws Exception
+   private void resolveLabel(ResourceBundle res, PageNode node)
    {
-      this.rootNode = new TreeNodeData(edittedNavigation, userPortal.getNode(edittedNavigation, NODE_SCOPE).filter(nodeFilter), this);
-      rootNode.setLoaded(true);      
-      return addToCached(rootNode);
-   }
-
-   private TreeNodeData addToCached(TreeNodeData node)
-   {
-      if (node == null)
+      node.setResolvedLabel(res);
+      if (node.getChildren() == null)
       {
-         return null;
+         return;
       }
-      if (!cachedNodes.containsKey(node.getId()))
+      for (PageNode childNode : node.getChildren())
       {
-         cachedNodes.put(node.getId(), node);
+         resolveLabel(res, childNode);
       }
+   }
 
-      for (TreeNodeData child : node.getChildren())
+   public void selectPageNodeByUri(String uri)
+   {
+      if (edittedTreeNodeData == null)
       {
-         addToCached(child);
+         return;
       }
-      return node;
+      UITree tree = getChild(UITree.class);
+      List<?> sibbling = tree.getSibbling();
+      tree.setSibbling(null);
+      tree.setParentSelected(null);
+      edittedTreeNodeData.setNode(searchPageNodeByUri(edittedTreeNodeData.getPageNavigation(), uri));
+      if (edittedTreeNodeData.getNode() != null)
+      {
+         tree.setSelected(edittedTreeNodeData.getNode());
+         tree.setChildren(edittedTreeNodeData.getNode().getChildren());
+         return;
+      }
+      tree.setSelected(null);
+      tree.setChildren(null);
+      tree.setSibbling(sibbling);
    }
 
-   private TreeNodeData removeFromCached(TreeNodeData node)
+   public PageNode searchPageNodeByUri(PageNavigation pageNav, String uri)
    {
-      if (node == null)
+      if (pageNav == null || uri == null)
       {
          return null;
       }
-
-      TreeNodeData currentCopy = getCopyNode();
-      if (currentCopy != null && currentCopy.getURI().equals(node.getURI()))
+      List<PageNode> pageNodes = pageNav.getNodes();
+      UITree uiTree = getChild(UITree.class);
+      for (PageNode ele : pageNodes)
       {
-         setCopyNode(null);
-         UIRightClickPopupMenu popup = getChild(UITree.class).getUIRightClickPopupMenu();
-         popup.setActions(new String[]{"AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CutNode",
-            "CloneNode", "DeleteNode", "MoveUp", "MoveDown"});
+         PageNode returnPageNode = searchPageNodeByUri(ele, uri, uiTree);
+         if (returnPageNode == null)
+         {
+            continue;
+         }
+         if (uiTree.getSibbling() == null)
+         {
+            uiTree.setSibbling(pageNodes);
+         }
+         return returnPageNode;
       }
-      
-      cachedNodes.remove(node.getId());
-      for (TreeNodeData child : node.getChildren())
-      {
-         removeFromCached(child);
-      }
-      return node;
+      return null;
    }
 
-   private TreeNodeData lazyLoadData(TreeNodeData treeNode) throws Exception
+   private PageNode searchPageNodeByUri(PageNode pageNode, String uri, UITree tree)
    {
-      if (treeNode == null || treeNode.getNode() == null)
+      if (pageNode.getUri().equals(uri))
       {
-         return treeNode;
+         return pageNode;
       }
-
-      UserNode node = treeNode.getNode();
-      if (node.getId() == null ||  treeNode.isLoaded())
+      List<PageNode> children = pageNode.getChildren();
+      if (children == null)
       {
-         return treeNode;
+         return null;
       }
-
-      if (userPortal.getNode(node, NODE_SCOPE) == null)
+      for (PageNode ele : children)
       {
-         TreeNodeData parent = treeNode.getParent();
-         if (parent != null)
+         PageNode returnPageNode = searchPageNodeByUri(ele, uri, tree);
+         if (returnPageNode == null)
          {
-            parent.removeChild(treeNode);
-            selectNode(parent);  
+            continue;
          }
-         return null;
+         if (tree.getSibbling() == null)
+         {
+            tree.setSibbling(children);
+         }
+         if (tree.getParentSelected() == null)
+         {
+            tree.setParentSelected(pageNode);
+         }
+         edittedTreeNodeData.setParentNode(pageNode);
+         return returnPageNode;
       }
-      node.filter(nodeFilter);
-      treeNode.setLoaded(true);
-      return addToCached(treeNode);
+      return null;
    }
 
    public void processRender(WebuiRequestContext context) throws Exception
@@ -280,48 +321,13 @@
       this.copyOfTreeNodeData = copyNode;
    }
 
-   public TreeNodeData getRootNode()
-   {
-      if (userPortal == null)
-      {
-         throw new IllegalStateException("userPortal must be initialized first");
-      }                                                         
-      return rootNode;
-   }
-
-   public void setUserPortal(UserPortal userPortal) throws Exception
-   {
-      if (edittedNavigation == null)
-      {
-         throw new IllegalStateException("edittedNavigation must be initialized first");
-      }
-      this.userPortal = userPortal;
-
-      setNodeFilter(userPortal.createFilter(UserNodePredicate.builder().withAuthorizationCheck().build()));
-   }
-
-   private void setNodeFilter(NodeFilter nodeFilter)
-   {
-      this.nodeFilter = nodeFilter;
-   }
-
-   public void setEdittedNavigation(UserNavigation _filteredEdittedNavigation) throws Exception
-   {
-      this.edittedNavigation = _filteredEdittedNavigation;
-   }
-
-   public UserNavigation getEdittedNavigation()
-   {
-      return this.edittedNavigation;
-   }
-
    static public class ChangeNodeActionListener extends EventListener<UITree>
    {
       public void execute(Event<UITree> event) throws Exception
       {
-         String nodeID = event.getRequestContext().getRequestParameter(OBJECTID);
+         String uri = event.getRequestContext().getRequestParameter(OBJECTID);
          UINavigationNodeSelector uiNodeSelector = event.getSource().getParent();
-         uiNodeSelector.selectNode(nodeID);
+         uiNodeSelector.selectPageNodeByUri(uri);
 
          UINavigationManagement nodeManager = uiNodeSelector.getParent();
          event.getRequestContext().addUIComponentToUpdateByAjax(nodeManager);
@@ -336,25 +342,36 @@
    {
       public void execute(Event<UIRightClickPopupMenu> event) throws Exception
       {
-         String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+         String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
          UIRightClickPopupMenu uiPopupMenu = event.getSource();
 
          UINavigationNodeSelector uiNodeSelector = uiPopupMenu.getAncestorOfType(UINavigationNodeSelector.class);
-
-         TreeNodeData selectedNode = uiNodeSelector.searchNode(nodeID);
-         if (selectedNode == null || uiNodeSelector.lazyLoadData(selectedNode) == null)
-         {
-            return;
-         }
-
          UIPopupWindow uiManagementPopup = uiNodeSelector.getAncestorOfType(UIPopupWindow.class);
          UIPageNodeForm uiNodeForm = uiManagementPopup.createUIComponent(UIPageNodeForm.class, null, null);
          uiNodeForm.setValues(null);
          uiManagementPopup.setUIComponent(uiNodeForm);
 
-         uiNodeForm.setSelectedParent(selectedNode);
+         Object parent = null;
+         PageNavigation edittedNavigation = uiNodeSelector.getEdittedNavigation();
+         List<PageNode> pageNodes = edittedNavigation.getNodes();
+         if (uri != null && uri.trim().length() > 0)
+         {
+            for (PageNode pageNode : pageNodes)
+            {
+               parent = PageNavigationUtils.searchPageNodeByUri(pageNode, uri);
+               if (parent != null)
+               {
+                  break;
+               }
+            }
+         }
+         if (parent == null)
+         {
+            parent = edittedNavigation;
+         }
+         
+         uiNodeForm.setSelectedParent(parent);
 
-         UserNavigation edittedNavigation = uiNodeSelector.getEdittedNavigation();
          uiNodeForm.setContextPageNavigation(edittedNavigation);
          uiManagementPopup.setWindowSize(800, 500);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiManagementPopup.getParent());
@@ -365,27 +382,44 @@
    {
       public void execute(Event<UIRightClickPopupMenu> event) throws Exception
       {
-         // get nodeID
-         String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+         // get URI
+         String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
 
          // get UINavigationNodeSelector
          UIRightClickPopupMenu uiPopupMenu = event.getSource();
+
          UINavigationNodeSelector uiNodeSelector = uiPopupMenu.getAncestorOfType(UINavigationNodeSelector.class);
 
-         // get Selected Node
-         TreeNodeData selectedPageNode = uiNodeSelector.searchNode(nodeID);
+         // get Selected PageNode
+         PageNode selectedPageNode = null;
+         List<PageNode> pageNodes = uiNodeSelector.getEdittedNavigation().getNodes();
+         if (uri != null && uri.trim().length() > 0)
+         {
+            for (PageNode pageNode : pageNodes)
+            {
+               selectedPageNode = PageNavigationUtils.searchPageNodeByUri(pageNode, uri);
+               if (selectedPageNode != null)
+               {
+                  break;
+               }
+            }
+         }
 
          UIPortalApplication uiApp = Util.getUIPortalApplication();
-         if (selectedPageNode == null || selectedPageNode.getPageRef() == null)
+
+         if (selectedPageNode.getPageReference() == null)
          {
             uiApp.addMessage(new ApplicationMessage("UIPageNodeSelector.msg.notAvailable", null));
             return;
          }
 
-         UserPortalConfigService userService = uiNodeSelector.getApplicationComponent(UserPortalConfigService.class);
+         UIWorkingWorkspace uiWorkingWS = uiApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+         UIPortalToolPanel uiToolPanel =
+            uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class).setRendered(true);
+         UserPortalConfigService userService = uiToolPanel.getApplicationComponent(UserPortalConfigService.class);
 
          // get selected page
-         String pageId = selectedPageNode.getPageRef();
+         String pageId = selectedPageNode.getPageReference();
          Page selectPage = (pageId != null) ? userService.getPage(pageId) : null;
          if (selectPage != null)
          {
@@ -400,9 +434,6 @@
             //uiWorkingWS.setRenderedChild(UIPortalToolPanel.class);
             //uiWorkingWS.addChild(UIPortalComposer.class, "UIPageEditor", null);
 
-            UIWorkingWorkspace uiWorkingWS = uiApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
-            UIPortalToolPanel uiToolPanel =
-               uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class).setRendered(true);
             uiWorkingWS.setRenderedChild(UIEditInlineWorkspace.class);
 
             UIPortalComposer portalComposer =
@@ -417,6 +448,7 @@
             uiToolPanel.setWorkingComponent(UIPage.class, null);
             UIPage uiPage = (UIPage)uiToolPanel.getUIComponent();
 
+            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
             if(selectPage.getTitle() == null)
                selectPage.setTitle(selectedPageNode.getLabel());
 
@@ -428,6 +460,7 @@
          else
          {
             uiApp.addMessage(new ApplicationMessage("UIPageNodeSelector.msg.notAvailable", null));
+            return;
          }
       }
    }
@@ -439,36 +472,31 @@
          WebuiRequestContext ctx = event.getRequestContext();
          UIRightClickPopupMenu popupMenu = event.getSource();
          UIApplication uiApp = ctx.getUIApplication();
-         String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+         String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
          UINavigationNodeSelector uiNodeSelector = popupMenu.getAncestorOfType(UINavigationNodeSelector.class);
+         PageNavigation edittedNav = uiNodeSelector.getEdittedNavigation();
+         Object obj = PageNavigationUtils.searchParentNode(edittedNav, uri);
+         PageNode selectedNode = PageNavigationUtils.searchPageNodeByUri(edittedNav, uri);
+         String pageId = selectedNode.getPageReference();
 
-         UserNavigation edittedNav = uiNodeSelector.getEdittedNavigation();
-         TreeNodeData selectedNode = uiNodeSelector.searchNode(nodeID);
-         if (selectedNode == null)
-         {
-            return;
-         }
-         String pageId = selectedNode.getPageRef();
-
          UserPortalConfigService service = uiApp.getApplicationComponent(UserPortalConfigService.class);
-         Page page = (pageId != null) ? service.getPage(pageId) : null;
-         if (page != null)
+         Page node = (pageId != null) ? service.getPage(pageId) : null;
+         if (node != null)
          {
             UserACL userACL = uiApp.getApplicationComponent(UserACL.class);
-            if (!userACL.hasPermission(page))
+            if (!userACL.hasPermission(node))
             {
-               uiApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.UserNotPermission", new String[]{pageId}, 1));
+               uiApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.UserNotPermission", new String[]{pageId}, 1));;
                return;
             }
          }
-
          UIPopupWindow uiManagementPopup = uiNodeSelector.getAncestorOfType(UIPopupWindow.class);
          UIPageNodeForm uiNodeForm = uiApp.createUIComponent(UIPageNodeForm.class, null, null);
          uiManagementPopup.setUIComponent(uiNodeForm);
 
          uiNodeForm.setContextPageNavigation(edittedNav);
          uiNodeForm.setValues(selectedNode);
-         uiNodeForm.setSelectedParent(selectedNode.getParent());
+         uiNodeForm.setSelectedParent(obj);
          uiManagementPopup.setWindowSize(800, 500);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiManagementPopup.getParent());
       }
@@ -478,21 +506,26 @@
    {
       public void execute(Event<UIRightClickPopupMenu> event) throws Exception
       {
-         String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+         String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
          UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
          UINavigationManagement uiManagement = uiNodeSelector.getParent();
          Class<?>[] childrenToRender = new Class<?>[]{UINavigationNodeSelector.class};
          uiManagement.setRenderedChildrenOfTypes(childrenToRender);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
 
-         TreeNodeData node = uiNodeSelector.searchNode(nodeID);
-         if (node == null)
+         PageNavigation nav = uiNodeSelector.getEdittedNavigation();
+         if (nav == null)
          {
             return;
          }
-
-         node.setDeleteNode(false);
-         uiNodeSelector.setCopyNode(node);
+         PageNode[] pageNodes = PageNavigationUtils.searchPageNodesByUri(nav, uri);
+         if (pageNodes == null)
+         {
+            return;
+         }
+         TreeNodeData selectedNode = new TreeNodeData(nav, pageNodes[0], pageNodes[1]);
+         selectedNode.setDeleteNode(false);
+         uiNodeSelector.setCopyNode(selectedNode);
          event.getSource().setActions(
             new String[]{"AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CloneNode", "CutNode",
                "PasteNode", "DeleteNode", "MoveUp", "MoveDown"});
@@ -503,32 +536,46 @@
    {
       public void execute(Event<UIRightClickPopupMenu> event) throws Exception
       {
-         String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
-         WebuiRequestContext pcontext = event.getRequestContext();
-         UIApplication uiApp = pcontext.getUIApplication();
-         UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
-         UINavigationManagement uiManagement = uiNodeSelector.getParent();
-         Class<?>[] childrenToRender = new Class<?>[]{UINavigationNodeSelector.class};
-         uiManagement.setRenderedChildrenOfTypes(childrenToRender);
-         event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
+    	  String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+    	  WebuiRequestContext pcontext = event.getRequestContext();
+          UIApplication uiApp = pcontext.getUIApplication();
+          UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
+          UINavigationManagement uiManagement = uiNodeSelector.getParent();
+          Class<?>[] childrenToRender = new Class<?>[]{UINavigationNodeSelector.class};
+          uiManagement.setRenderedChildrenOfTypes(childrenToRender);
+          event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
 
-         TreeNodeData node = uiNodeSelector.searchNode(nodeID);
-         if (node == null)
-         {
-            return;
-         }
+          PageNavigation nav = uiNodeSelector.getEdittedNavigation();
+          if (nav == null)
+          {
+             return;
+          }
+          
+          PageNode[] pageNodes = PageNavigationUtils.searchPageNodesByUri(nav, uri);
+          if (pageNodes == null)
+          {
+             return;
+          }
+          
+          for (PageNode pageNode : pageNodes) {
+  			 if(pageNode != null && pageNode.isSystem()) {
+  				 uiApp.addMessage(new ApplicationMessage("UINavigationNodeSelector.msg.systemnode-move", null));
+  				 return;
+  			 }
+          }
+          
+          TreeNodeData selectedNode = new TreeNodeData(nav, pageNodes[0], pageNodes[1]);
+          selectedNode.setDeleteNode(false);
+          uiNodeSelector.setCopyNode(selectedNode);
+          event.getSource().setActions(
+             new String[]{"AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CloneNode", "CutNode",
+                "PasteNode", "DeleteNode", "MoveUp", "MoveDown"});         
 
-         if(Visibility.SYSTEM.equals(node.getVisibility()))
-         {
-            uiApp.addMessage(new ApplicationMessage("UINavigationNodeSelector.msg.systemnode-move", null));
-            return;
-         }
-
-         node.setDeleteNode(true);
-         uiNodeSelector.setCopyNode(node);
-         event.getSource().setActions(
-            new String[]{"AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CloneNode", "CutNode",
-               "PasteNode", "DeleteNode", "MoveUp", "MoveDown"});
+          if (uiNodeSelector.getCopyNode() == null)
+          {
+             return;
+          }
+          uiNodeSelector.getCopyNode().setDeleteNode(true);
       }
    }
 
@@ -544,108 +591,152 @@
 
    static public class PasteNodeActionListener extends EventListener<UIRightClickPopupMenu>
    {
-      private UINavigationNodeSelector uiNodeSelector;
-      private DataStorage dataStorage;
-      private UserPortalConfigService service;
-
       public void execute(Event<UIRightClickPopupMenu> event) throws Exception
       {
-         String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+         String targetUri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
          UIRightClickPopupMenu uiPopupMenu = event.getSource();
-         uiNodeSelector = uiPopupMenu.getAncestorOfType(UINavigationNodeSelector.class);
+         UINavigationNodeSelector uiNodeSelector = uiPopupMenu.getAncestorOfType(UINavigationNodeSelector.class);
          UINavigationManagement uiManagement = uiNodeSelector.getParent();
          Class<?>[] childrenToRender = new Class<?>[]{UINavigationNodeSelector.class};
          uiManagement.setRenderedChildrenOfTypes(childrenToRender);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
-
-         TreeNodeData targetNode = uiNodeSelector.searchNode(nodeID);
-         TreeNodeData sourceNode = uiNodeSelector.getCopyNode();
-         if (sourceNode == null || uiNodeSelector.lazyLoadData(targetNode) == null)
+         TreeNodeData selectedNode = uiNodeSelector.getCopyNode();
+         if (selectedNode == null)
          {
             return;
          }
 
-         if (targetNode != null && sourceNode.getURI().equals(targetNode.getURI()))
+         PageNode newNode = selectedNode.getNode().clone();
+         PageNavigation targetNav = uiNodeSelector.getEdittedNavigation();
+         PageNode targetNode = PageNavigationUtils.searchPageNodeByUri(targetNav, targetUri);
+
+         if (targetNode != null && newNode.getUri().equals(targetNode.getUri()))
          {
             UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
             uiApp.addMessage(new ApplicationMessage("UIPageNodeSelector.msg.paste.sameSrcAndDes", null));
             return;
          }
 
-         if (isExistChild(targetNode, sourceNode))
+         if (isExistChild(targetNode, newNode) || (targetNode == null && isExitChild(targetNav, newNode)))
          {
             UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
             uiApp.addMessage(new ApplicationMessage("UIPageNodeSelector.msg.paste.sameName", null));
             return;
          }
-
-         if (sourceNode.isDeleteNode())
+         if (selectedNode.isDeleteNode())
          {
-            sourceNode.getParent().removeChild(sourceNode);
+            if (selectedNode.getParentNode() != null)
+            {
+               selectedNode.getParentNode().getChildren().remove(selectedNode.getNode());
+            }
+            else
+            {
+               selectedNode.getPageNavigation().getNodes().remove(selectedNode.getNode());
+            }
          }
+         event.getRequestContext().addUIComponentToUpdateByAjax(uiNodeSelector);
          uiNodeSelector.setCopyNode(null);
-
          UITree uitree = uiNodeSelector.getChild(UITree.class);
          UIRightClickPopupMenu popup = uitree.getUIRightClickPopupMenu();
          popup.setActions(new String[]{"AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CutNode",
             "CloneNode", "DeleteNode", "MoveUp", "MoveDown"});
 
-         service = uiNodeSelector.getApplicationComponent(UserPortalConfigService.class);
-         dataStorage = uiNodeSelector.getApplicationComponent(DataStorage.class);
-
-         pasteNode(sourceNode, targetNode, sourceNode.isCloneNode());
-         uiNodeSelector.selectNode(targetNode);
+         UserPortalConfigService service = uiPopupMenu.getApplicationComponent(UserPortalConfigService.class);
+         if (targetNode == null)
+         {
+            newNode.setUri(newNode.getName());
+            targetNav.addNode(newNode);
+            if (selectedNode.isCloneNode())
+            {
+               clonePageFromNode(newNode, targetNav.getOwnerType(), targetNav.getOwnerId(), service);
+            }
+            return;
+         }
+         setNewUri(targetNode, newNode);
+         targetNode.getChildren().add(newNode);
+         if (selectedNode.isCloneNode())
+         {
+            clonePageFromNode(newNode, targetNav.getOwnerType(), targetNav.getOwnerId(), service);
+         }
+         uiNodeSelector.selectPageNodeByUri(targetNode.getUri());
       }
 
-      private TreeNodeData pasteNode(TreeNodeData sourceNode, TreeNodeData parent, boolean isClone) throws Exception
+      private void clonePageFromNode(PageNode node, String ownerType, String ownerId, UserPortalConfigService service)
+         throws Exception
       {
-         if (uiNodeSelector.lazyLoadData(sourceNode) == null)
+         String pageId = node.getPageReference();
+         if (pageId != null)
          {
-            return null;
+            Page page = service.getPage(pageId);
+            if (page != null)
+            {
+               String newName = "page" + node.hashCode();
+               page = service.renewPage(pageId, newName, ownerType, ownerId);
+               node.setPageReference(page.getPageId());
+            }
          }
-         TreeNodeData node = parent.addChild(sourceNode.getName());
-         node.setLabel(sourceNode.getLabel());
-         node.setVisibility(sourceNode.getVisibility());
-         node.setIcon(sourceNode.getIcon());
-         node.setStartPublicationTime(sourceNode.getStartPublicationTime());
-         node.setEndPublicationTime(sourceNode.getEndPublicationTime());
-
-         if (isClone)
+         List<PageNode> children = node.getChildren();
+         if (children == null || children.size() < 1)
          {
-            String pageName = "page" + node.hashCode();
-            node.setPageRef(clonePageFromNode(sourceNode, pageName, sourceNode.getPageNavigation().getKey()));
+            return;
          }
-         else
+         for (PageNode ele : children)
          {
-            node.setPageRef(sourceNode.getPageRef());            
+            clonePageFromNode(ele, ownerType, ownerId, service);
          }
+      }
 
-         for (TreeNodeData child : sourceNode.getChildren())
+      private void setNewUri(PageNode parent, PageNode child)
+      {
+         String newUri = (parent != null) ? parent.getUri() + "/" + child.getName() : child.getName();
+         child.setUri(newUri);
+         List<PageNode> children = child.getChildren();
+         if (children != null)
          {
-            pasteNode(child, node, isClone);
+            for (PageNode node : children)
+            {
+               setNewUri(child, node);
+            }
          }
-
-         return node;
       }
 
-      private String clonePageFromNode(TreeNodeData node,String pageName, SiteKey siteKey) throws Exception
+      private boolean isExistChild(PageNode parent, PageNode child)
       {
-         String pageId = node.getPageRef();
-         if (pageId != null)
+         if (parent == null)
          {
-            Page page = service.getPage(pageId);
-            if (page != null)
+            return false;
+         }
+         List<PageNode> nodes = parent.getChildren();
+         if (nodes == null)
+         {
+            parent.setChildren(new ArrayList<PageNode>());
+            return false;
+         }
+         for (PageNode node : nodes)
+         {
+            if (node.getName().equals(child.getName()))
             {
-               page = dataStorage.clonePage(pageId, siteKey.getTypeName(), siteKey.getName(), pageName);
-               return page.getPageId();
+               return true;
             }
          }
-         return null;
+         return false;
       }
 
-      private boolean isExistChild(TreeNodeData parent, TreeNodeData child)
+      private boolean isExitChild(PageNavigation nav, PageNode child)
       {
-         return parent != null && parent.getChild(child.getName()) != null;
+         List<PageNode> nodes = nav.getNodes();
+         if (nodes.size() == 0)
+         {
+            return false;
+         }
+         for (PageNode node : nodes)
+         {
+            if (node.getName().equals(child.getName()))
+            {
+               return true;
+            }
+         }
+         return false;
       }
    }
 
@@ -656,28 +747,25 @@
          moveNode(event, -1);
       }
 
-      protected void moveNode(Event<UIRightClickPopupMenu> event, int i) throws Exception
+      protected void moveNode(Event<UIRightClickPopupMenu> event, int i)
       {
-         String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+         String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
          UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiNodeSelector.getParent());
-         TreeNodeData targetNode = uiNodeSelector.searchNode(nodeID);
-         if (targetNode == null)
+         PageNavigation nav = uiNodeSelector.getEdittedNavigation();
+         PageNode targetNode = PageNavigationUtils.searchPageNodeByUri(nav, uri);
+         Object parentNode = PageNavigationUtils.searchParentNode(nav, uri);
+         List<PageNode> children = new ArrayList<PageNode>();
+         if (parentNode instanceof PageNavigation)
          {
-            return;
+            children = ((PageNavigation)parentNode).getNodes();
          }
-         TreeNodeData parentNode = targetNode.getParent();
-         Collection<TreeNodeData> children = parentNode.getChildren();
-
-         int k;
-         for (k = 0; k < children.size(); k++)
+         else if (parentNode instanceof PageNode)
          {
-            if (parentNode.getChild(k).getURI().equals(targetNode.getURI()))
-            {
-               break;
-            }
+            children = ((PageNode)parentNode).getChildren();
          }
-         if (k > children.size())
+         int k = children.indexOf(targetNode);
+         if (k < 0)
          {
             return;
          }
@@ -689,9 +777,8 @@
          {
             return;
          }
-         parentNode.addChild(k + i, targetNode);
-
-         uiNodeSelector.selectNode(targetNode);
+         children.remove(k);
+         children.add(k + i, targetNode);
       }
    }
 
@@ -707,39 +794,69 @@
    {
       public void execute(Event<UIRightClickPopupMenu> event) throws Exception
       {
-         String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+         String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
          WebuiRequestContext pcontext = event.getRequestContext();
          UIApplication uiApp = pcontext.getUIApplication();
          UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
          pcontext.addUIComponentToUpdateByAjax(uiNodeSelector);
 
-         TreeNodeData childNode = uiNodeSelector.searchNode(nodeID);
-         if (childNode == null)
+         PageNavigation nav = uiNodeSelector.getEdittedNavigation();
+         if (nav == null)
          {
             return;
          }
-         TreeNodeData parentNode = childNode.getParent();
 
-         if(Visibility.SYSTEM.equals(childNode.getVisibility())) {
+         ParentChildPair parentChildPair = PageNavigationUtils.searchParentChildPairByUri(nav, uri);
+         if (parentChildPair == null)
+         {
+            return;
+         }
+
+         PageNode parentNode = parentChildPair.getParentNode();
+         PageNode childNode = parentChildPair.getChildNode();
+         
+         if(childNode.isSystem()) {
         		uiApp.addMessage(new ApplicationMessage("UINavigationNodeSelector.msg.systemnode-delete", null));
         		return;
         	}
-
-         parentNode.removeChild(childNode);
-         uiNodeSelector.selectNode(parentNode);
+        	
+         if(parentNode == null)
+         {
+            nav.getNodes().remove(childNode);
+         }
+         else
+         {
+            parentNode.getNodes().remove(childNode);
+            uiNodeSelector.selectPageNodeByUri(parentNode.getUri());
+         }
       }
    }
 
    public TreeNodeData getSelectedNode()
    {
-      TreeNodeData selectedNode = getChild(UITree.class).getSelected();
-      if (selectedNode == null)
-      {
-         selectedNode = rootNode;
-      }
-      return selectedNode;
+      return edittedTreeNodeData;
    }
 
+   public PageNavigation getSelectedNavigation()
+   {
+      return edittedTreeNodeData == null ? null : edittedTreeNodeData.getPageNavigation();
+   }
+
+   public PageNode getSelectedPageNode()
+   {
+      return edittedTreeNodeData == null ? null : edittedTreeNodeData.getNode();
+   }
+
+   public String getUpLevelUri()
+   {
+      return edittedTreeNodeData.getParentNode().getUri();
+   }
+
+   public List<PageNavigation> getDeleteNavigations()
+   {
+      return deleteNavigations;
+   }
+
    /**
     *   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
@@ -751,270 +868,82 @@
    public static class TreeNodeData
    {
 
-      private UserNavigation nav;
+      private PageNavigation nav;
 
-      private UserNode node;
+      private PageNode parentNode;
 
-      private UINavigationNodeSelector selector;
+      private PageNode node;
 
       private boolean deleteNode = false;
 
       private boolean cloneNode = false;
 
-      private List<TreeNodeData> wrappedChilds;
-
-      private boolean loaded;
-
-      public TreeNodeData(UserNavigation nav, UserNode node, UINavigationNodeSelector selector)
+      public TreeNodeData(PageNavigation nav, PageNode parentNode, PageNode node)
       {
-         if (nav == null || node == null)
-         {
-            throw new IllegalArgumentException("nav or node is null");
-         }
          this.nav = nav;
+         this.parentNode = parentNode;
          this.node = node;
-         this.selector = selector;
       }
-
-      public UserNavigation getPageNavigation()
+      
+      public TreeNodeData(PageNavigation nav)
       {
-         return nav;
-      }
-
-      public UserNode getNode()
-      {
-         return node;
-      }
-
-      public boolean isDeleteNode()
-      {
-         return deleteNode;
-      }
-
-      public void setDeleteNode(boolean deleteNode)
-      {
-         this.deleteNode = deleteNode;
-      }
-
-      public boolean isCloneNode()
-      {
-         return cloneNode;
-      }
-
-      public void setCloneNode(boolean b)
-      {
-         cloneNode = b;
-      }
-
-      public List<TreeNodeData> getChildren()
-      {
-         if (wrappedChilds == null)
+         this.nav = nav;
+         List<PageNode> children = nav.getNodes();
+         if(children != null && children.size() > 0)
          {
-            wrappedChilds = new ArrayList<TreeNodeData>();
-            for (UserNode child : node.getChildren())
-            {
-               TreeNodeData node = selector.searchNode(child.getURI());
-               //This is for the first time rootNode is loaded
-               if (node == null)
-               {
-                  node = new TreeNodeData(nav, child, selector);
-               }
-               wrappedChilds.add(node);
-            }
+            this.node = children.get(0);
          }
-         return wrappedChilds;
       }
 
-      public TreeNodeData getChild(String name)
+      public PageNavigation getPageNavigation()
       {
-         UserNode child = node.getChild(name);
-         if (child == null)
-         {
-            return null;
-         }
-         return selector.searchNode(child.getURI());
+         return nav;
       }
 
-      public TreeNodeData addChild(String childName)
+      public void setPageNavigation(PageNavigation nav)
       {
-         wrappedChilds = null;
-         UserNode child = node.addChild(childName);
-         return selector.addToCached(new TreeNodeData(nav, child, selector));
+         this.nav = nav;
       }
 
-      public boolean removeChild(String childName)
+      public PageNode getParentNode()
       {
-         wrappedChilds = null;
-         UserNode child = node.getChild(childName);
-         if (child == null)
-         {
-            return false;
-         }
-         selector.removeFromCached(selector.searchNode(child.getURI()));
-         return node.removeChild(childName);
+         return parentNode;
       }
 
-      public boolean removeChild(TreeNodeData child)
+      public void setParentNode(PageNode parentNode)
       {
-         wrappedChilds = null;
-         if (child == null)
-         {
-            return false;
-         }
-         selector.removeFromCached(child);
-         return node.removeChild(child.getName());
+         this.parentNode = parentNode;
       }
 
-      public TreeNodeData getParent()
+      public PageNode getNode()
       {
-         if (node.getParent() == null)
-            return null;
-         return selector.searchNode(node.getParent().getURI());
+         return node;
       }
 
-      public String getPageRef()
+      public void setNode(PageNode node)
       {
-         return node.getPageRef();
+         this.node = node;
       }
 
-      public String getId()
+      public boolean isDeleteNode()
       {
-         return getURI();
+         return deleteNode;
       }
 
-      public String getURI()
+      public void setDeleteNode(boolean deleteNode)
       {
-         return node.getURI();
+         this.deleteNode = deleteNode;
       }
 
-      public String getIcon()
+      public boolean isCloneNode()
       {
-         return node.getIcon();
+         return cloneNode;
       }
 
-      public void setIcon(String icon)
+      public void setCloneNode(boolean b)
       {
-         node.setIcon(icon);
+         cloneNode = b;
       }
-
-      public String getEncodedResolvedLabel()
-      {
-         if (node.getParent() == null)
-         {
-            return "";
-         }
-         return node.getResolvedLabel();
-      }
-
-      public String getName()
-      {
-         return node.getName();
-      }
-
-      public void setName(String name)
-      {
-         node.setName(name);
-      }
-
-      public String getLabel()
-      {
-         return node.getLabel();
-      }
-
-      public void setLabel(String label)
-      {
-         node.setLabel(label);
-      }
-
-      public Visibility getVisibility()
-      {
-         return node.getVisibility();
-      }
-
-      public void setVisibility(Visibility visibility)
-      {
-         node.setVisibility(visibility);
-      }
-
-      public long getStartPublicationTime()
-      {
-         return node.getStartPublicationTime();
-      }
-
-      public void setStartPublicationTime(long startPublicationTime)
-      {
-         node.setStartPublicationTime(startPublicationTime);
-      }
-
-      public long getEndPublicationTime()
-      {
-         return node.getEndPublicationTime();
-      }
-
-      public void setEndPublicationTime(long endPublicationTime)
-      {
-         node.setEndPublicationTime(endPublicationTime);
-      }
-
-      public void setPageRef(String pageRef)
-      {
-         node.setPageRef(pageRef);
-      }
-
-      public String getResolvedLabel()
-      {
-         String resolvedLabel = node.getResolvedLabel();
-
-         return resolvedLabel == null ? "" : resolvedLabel;
-      }
-
-      public boolean hasChildrenRelationship()
-      {
-         return node.hasChildrenRelationship();
-      }
-
-      public int getChildrenCount()
-      {
-         return node.getChildrenCount();
-      }
-
-      public TreeNodeData getChild(int childIndex) throws IndexOutOfBoundsException
-      {
-         UserNode child = node.getChild(childIndex);
-         if (child == null)
-         {
-            return null;
-         }
-         return selector.searchNode(child.getURI());
-      }
-
-      public void addChild(TreeNodeData node)
-      {
-         addChild(node.getChildrenCount(), node);
-      }
-
-      public void addChild(int index, TreeNodeData child)
-      {
-         wrappedChilds = null;
-         node.addChild(index, child.getNode());
-         selector.addToCached(child);
-      }
-
-      public boolean isLoaded()
-      {
-         return loaded;
-      }
-
-      public void setLoaded(boolean loaded)
-      {
-         wrappedChilds = null;
-         this.loaded = loaded;
-      }
-
-      public void save() throws NavigationServiceException
-      {
-         selector.cachedNodes.clear();
-         node.save();
-      }
    }
+
 }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPageNavigationForm.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPageNavigationForm.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPageNavigationForm.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -1,16 +1,16 @@
 /**
  * Copyright (C) 2009 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
@@ -20,10 +20,8 @@
 package org.exoplatform.portal.webui.navigation;
 
 import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.mop.navigation.NavigationState;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PageNavigation;
 import org.exoplatform.portal.webui.util.Util;
 import org.exoplatform.portal.webui.workspace.UIPortalApplication;
 import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
@@ -31,24 +29,28 @@
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
 import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIApplication;
 import org.exoplatform.webui.core.UIComponent;
 import org.exoplatform.webui.core.UIPopupWindow;
 import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
 import org.exoplatform.webui.core.model.SelectItemOption;
 import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
 import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.event.EventListener;
 import org.exoplatform.webui.form.UIForm;
 import org.exoplatform.webui.form.UIFormSelectBox;
 import org.exoplatform.webui.form.UIFormStringInput;
+
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 /*
  * Created by The eXo Platform SAS
  * Author : tam.nguyen
  *          tamndrok at gmail.com
- * June 11, 2009
+ * June 11, 2009  
  */
 @ComponentConfig(lifecycle = UIFormLifecycle.class, template = "system:/groovy/webui/form/UIFormWithTitle.gtmpl", events = {
    @EventConfig(listeners = UIPageNavigationForm.SaveActionListener.class),
@@ -56,7 +58,7 @@
 public class UIPageNavigationForm extends UIForm
 {
 
-   private UserNavigation userNav;
+   private PageNavigation pageNav_;
 
    private String ownerId;
 
@@ -81,17 +83,17 @@
             new UIFormSelectBox("priority", null, priorties).setValue(getPriority()));
    }
 
-   public void setValues(UserNavigation userNavigation) throws Exception
+   public void setValues(PageNavigation pageNavigation) throws Exception
    {
-      setUserNav(userNavigation);
-      invokeGetBindingBean(userNavigation);
-      removeChildById("ownerId");
-      UIFormStringInput ownerId = new UIFormStringInput("ownerId", "ownerId", userNavigation.getKey().getName());
+      setPageNav(pageNavigation);
+      invokeGetBindingBean(pageNavigation);
+      removeChildById("ownerId");      
+      UIFormStringInput ownerId = new UIFormStringInput("ownerId", "ownerId", pageNavigation.getOwnerId());
       ownerId.setEditable(false);
       ownerId.setParent(this);
       getChildren().add(1, ownerId);
       UIFormSelectBox uiSelectBox = findComponentById("priority");
-      uiSelectBox.setValue(String.valueOf(userNavigation.getPriority()));
+      uiSelectBox.setValue(String.valueOf(pageNavigation.getPriority()));
    }
 
    public void setOwnerId(String ownerId)
@@ -124,14 +126,14 @@
       return priority;
    }
 
-   public void setUserNav(UserNavigation pageNav_)
+   public void setPageNav(PageNavigation pageNav_)
    {
-      this.userNav = pageNav_;
+      this.pageNav_ = pageNav_;
    }
 
-   public UserNavigation getUserNav()
+   public PageNavigation getPageNav()
    {
-      return userNav;
+      return pageNav_;
    }
 
    static public class SaveActionListener extends EventListener<UIPageNavigationForm>
@@ -139,18 +141,17 @@
       public void execute(Event<UIPageNavigationForm> event) throws Exception
       {
          UIPageNavigationForm uiForm = event.getSource();
-         UserNavigation userNav = uiForm.getUserNav();
+         PageNavigation pageNav = uiForm.getPageNav();
 
          // Check existed
          PortalRequestContext prContext = Util.getPortalRequestContext();
-         UserPortal userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal();
-
-         userNav = userPortal.getNavigation(userNav.getKey());
-
-         if (userNav == null)
+         DataStorage dataService = uiForm.getApplicationComponent(DataStorage.class);
+         PageNavigation persistNavigation = dataService.getPageNavigation(pageNav.getOwnerType(), pageNav.getOwnerId());
+         if (persistNavigation == null)
          {
+            UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
+            uiApp.addMessage(new ApplicationMessage("UINavigationManagement.msg.NavigationNotExistAnymore", null));
             UIPortalApplication uiPortalApp = (UIPortalApplication)prContext.getUIApplication();
-            uiPortalApp.addMessage(new ApplicationMessage("UINavigationManagement.msg.NavigationNotExistAnymore", null));
             UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
             UIPopupWindow uiPopup = uiForm.getParent();
             uiPopup.setShow(false);
@@ -158,24 +159,50 @@
             return;
          }
 
+         WebuiRequestContext pcontext = event.getRequestContext();
+         uiForm.invokeSetBindingBean(pageNav);
          UIFormSelectBox uiSelectBox = uiForm.findComponentById("priority");
          int priority = Integer.parseInt(uiSelectBox.getValue());
+         pageNav.setPriority(priority);
 
          // update navigation
-         NavigationService service = uiForm.getApplicationComponent(NavigationService.class);
-         service.saveNavigation(userNav.getKey(), new NavigationState(priority));
+         dataService.save(pageNav);
 
+         pageNav = dataService.getPageNavigation(pageNav.getOwnerType(), pageNav.getOwnerId());
+
+         UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
+         updateNavPriority(uiPortalApp.getNavigations(), pageNav);
+
+         uiPortalApp.localizeNavigations();
+
          UIPopupWindow uiPopup = uiForm.getParent();
          uiPopup.setShow(false);
          UIComponent opener = uiPopup.getParent();
-
          UIWorkingWorkspace uiWorkingWS =
             Util.getUIPortal().getAncestorOfType(UIPortalApplication.class).getChild(UIWorkingWorkspace.class);
          uiWorkingWS.updatePortletsByName("UserToolbarGroupPortlet");
-
-         WebuiRequestContext pcontext = event.getRequestContext();
          pcontext.addUIComponentToUpdateByAjax(opener);
       }
+      
+      private void updateNavPriority(List<PageNavigation> navs, PageNavigation nav)
+      {
+         for (int i = 0; i < navs.size(); i++)
+         {
+            if (navs.get(i).getId() == nav.getId())
+            {
+               navs.set(i, nav);
+               break;
+            }
+         }
+
+         Collections.sort(navs, new Comparator<PageNavigation>()
+         {
+            public int compare(PageNavigation nav1, PageNavigation nav2)
+            {
+               return nav1.getPriority() - nav2.getPriority();
+            }
+         });
+      }
    }
 
    static public class CloseActionListener extends EventListener<UIPageNavigationForm>

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPageNodeSelector.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPageNodeSelector.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPageNodeSelector.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -19,116 +19,172 @@
 
 package org.exoplatform.portal.webui.navigation;
 
-import org.exoplatform.portal.mop.navigation.NodeFilter;
-import org.exoplatform.portal.mop.navigation.Scope;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserNode;
-import org.exoplatform.portal.mop.user.UserNodePredicate;
-import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.config.UserPortalConfigService;
+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.webui.page.UIPage;
+import org.exoplatform.portal.webui.page.UIPageBody;
 import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+import org.exoplatform.portal.webui.workspace.UIPortalToolPanel;
+import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
 import org.exoplatform.webui.core.UIContainer;
 import org.exoplatform.webui.core.UIRightClickPopupMenu;
 import org.exoplatform.webui.core.UITree;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
 
-import java.util.Iterator;
+import java.util.List;
 
- at ComponentConfig(
-   template = "system:/groovy/portal/webui/navigation/UIPageNodeSelector.gtmpl"
-)
+/** Created by The eXo Platform SARL Author : chungnv nguyenchung136 at yahoo.com Jun 23, 2006 10:07:15 AM */
+ at ComponentConfig(template = "system:/groovy/portal/webui/navigation/UIPageNodeSelector.gtmpl", events = {@EventConfig(listeners = UIPageNodeSelector.ChangeNodeActionListener.class)})
 public class UIPageNodeSelector extends UIContainer
 {
-   private UserNavigation navigation;
 
-   private UserNode selectedNode;
+   //  private List<PageNavigation> navigations;
+   private PageNavigation selectedNavigation;
 
-   private final NodeFilter NODE_SELECTOR_FILTER;
+   private SelectedNode selectedNode;
 
-   private UserPortal userPortal;
+   private SelectedNode copyNode;
 
    public UIPageNodeSelector() throws Exception
    {
       UITree uiTree = addChild(UITree.class, null, "TreePageSelector");
       uiTree.setIcon("DefaultPageIcon");
       uiTree.setSelectedIcon("DefaultPageIcon");
-      uiTree.setBeanIdField("URI");
+      uiTree.setBeanIdField("uri");
       uiTree.setBeanLabelField("encodedResolvedLabel");
       uiTree.setBeanIconField("icon");
-      uiTree.setBeanChildCountField("childrenCount");
 
-      userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal();
-      UserNodePredicate.Builder scopeBuilder = UserNodePredicate.builder();
-      scopeBuilder.withAuthorizationCheck();
-      NODE_SELECTOR_FILTER = userPortal.createFilter(scopeBuilder.build());
+      loadNavigations();
    }
 
-   public void setNavigation(UserNavigation nav) throws Exception
+   private void loadNavigations() throws Exception
    {
-      navigation = nav;
-      UserNode selectedNode = Util.getUIPortal().getSelectedUserNode();
-      setSelectedNode(selectedNode);
+      PageNavigation portalSelectedNav = Util.getUIPortal().getSelectedNavigation();
+      if (portalSelectedNav != null)
+      {
+         selectNavigation(portalSelectedNav);
+         PageNode portalSelectedNode = Util.getUIPortal().getSelectedNode();
+         if (portalSelectedNode != null)
+         {
+            selectPageNodeByUri(portalSelectedNode.getUri());
+         }
+         return;
+      }
+      selectNavigation();
    }
 
-   private UserNode load(UserNode node) throws Exception
+   private void selectNavigation()
    {
-      return userPortal.getNode(node, Scope.GRANDCHILDREN).filter(NODE_SELECTOR_FILTER);
+      if (selectedNavigation == null)
+      {
+         return;
+      }
+      if (selectedNode == null || selectedNavigation.getId() != selectedNode.getPageNavigation().getId())
+      {
+         selectedNode = new SelectedNode(selectedNavigation, null, null);
+         if (selectedNavigation.getNodes().size() > 0)
+         {
+            selectedNode.setNode(selectedNavigation.getNodes().get(0));
+         }
+      }
+      selectNavigation(selectedNode.getPageNavigation());
+      if (selectedNode.getNode() != null)
+      {
+         selectPageNodeByUri(selectedNode.getNode().getUri());
+      }
    }
-   
-   private void setSelectedNode(UserNode node) throws Exception
+
+   public void selectNavigation(PageNavigation pageNav)
    {
-      if (node == null)
+      selectedNavigation = pageNav;
+      selectedNode = new SelectedNode(pageNav, null, null);
+      selectPageNodeByUri(null);
+      UITree uiTree = getChild(UITree.class);
+      uiTree.setSibbling(pageNav.getNodes());
+   }
+
+   public void selectPageNodeByUri(String uri)
+   {
+      if (selectedNode == null || (selectedNavigation.getId() != selectedNode.getPageNavigation().getId()))
       {
          return;
       }
       UITree tree = getChild(UITree.class);
-      if (node.getParent() != null)
+      List<?> sibbling = tree.getSibbling();
+      tree.setSibbling(null);
+      tree.setParentSelected(null);
+      selectedNode.setNode(searchPageNodeByUri(selectedNode.getPageNavigation(), uri));
+      if (selectedNode.getNode() != null)
       {
-         node = load(node);
-         tree.setSelected(node);
-         tree.setChildren(node.getChildren());
-         UserNode parent = load(node.getParent());
-         tree.setSibbling(parent.getChildren());
-         tree.setParentSelected(parent);
+         tree.setSelected(selectedNode.getNode());
+         tree.setChildren(selectedNode.getNode().getChildren());
+         return;
       }
-      else
-      {
-         tree.setSelected(null);
-         tree.setChildren(null);
-      }
-      selectedNode = node;
+      tree.setSelected(null);
+      tree.setChildren(null);
+      tree.setSibbling(sibbling);
    }
-   
-   public void setSelectedURI(String uri) throws Exception
+
+   public PageNode searchPageNodeByUri(PageNavigation pageNav, String uri)
    {
-      UserNode node;
-      if (selectedNode.getParent() != null)
+      if (pageNav == null || uri == null)
       {
-         node = findUserNodeByURI(selectedNode.getParent(), uri);
+         return null;
       }
-      else
+      List<PageNode> pageNodes = pageNav.getNodes();
+      UITree uiTree = getChild(UITree.class);
+      for (PageNode ele : pageNodes)
       {
-         node = findUserNodeByURI(selectedNode, uri);
+         PageNode returnPageNode = searchPageNodeByUri(ele, uri, uiTree);
+         if (returnPageNode == null)
+         {
+            continue;
+         }
+         if (uiTree.getSibbling() == null)
+         {
+            uiTree.setSibbling(pageNodes);
+         }
+         return returnPageNode;
       }
-      setSelectedNode(node);
+      return null;
    }
-   
-   private UserNode findUserNodeByURI(UserNode rootNode, String uri)
+
+   private PageNode searchPageNodeByUri(PageNode pageNode, String uri, UITree tree)
    {
-      if (rootNode.getURI().equals(uri))
+      if (pageNode.getUri().equals(uri))
       {
-         return rootNode;
+         return pageNode;
       }
-      Iterator<UserNode> iterator = rootNode.getChildren().iterator();
-      while (iterator.hasNext())
+      List<PageNode> children = pageNode.getChildren();
+      if (children == null)
       {
-         UserNode next = iterator.next();
-         UserNode node = findUserNodeByURI(next, uri);
-         if (node == null)
+         return null;
+      }
+      for (PageNode ele : children)
+      {
+         PageNode returnPageNode = searchPageNodeByUri(ele, uri, tree);
+         if (returnPageNode == null)
          {
             continue;
          }
-         return node;
+         if (tree.getSibbling() == null)
+         {
+            tree.setSibbling(children);
+         }
+         if (tree.getParentSelected() == null)
+         {
+            tree.setParentSelected(pageNode);
+         }
+         selectedNode.setParentNode(pageNode);
+         return returnPageNode;
       }
       return null;
    }
@@ -143,13 +199,172 @@
       super.processRender(context);
    }
 
-   public UserNode getSelectedNode()
+   public SelectedNode getCopyNode()
    {
+      return copyNode;
+   }
+
+   public void setCopyNode(SelectedNode copyNode)
+   {
+      this.copyNode = copyNode;
+   }
+
+   public SelectedNode getSelectedNode()
+   {
       return selectedNode;
    }
 
-   public UserNavigation getNavigation()
+   public PageNavigation getSelectedNavigation()
    {
-      return navigation;
+      return selectedNavigation;
    }
+
+   public PageNode getSelectedPageNode()
+   {
+      return selectedNode == null ? null : selectedNode.getNode();
+   }
+
+   public String getUpLevelUri()
+   {
+      return selectedNode.getParentNode().getUri();
+   }
+
+   //  private List<PageNavigation> getExistedNavigation(List<PageNavigation> navis) throws Exception {
+   //    Iterator<PageNavigation> itr = navis.iterator() ;
+   //    UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
+   //    while(itr.hasNext()) {
+   //      PageNavigation nav = itr.next() ;
+   //      if(configService.getPageNavigation(nav.getOwnerType(), nav.getOwnerId()) == null) itr.remove() ;
+   //    }
+   //    return navis ;
+   //  }
+
+   static public class ChangeNodeActionListener extends EventListener<UITree>
+   {
+      public void execute(Event<UITree> event) throws Exception
+      {
+         String uri = event.getRequestContext().getRequestParameter(OBJECTID);
+         UIPageNodeSelector uiPageNodeSelector = event.getSource().getParent();
+         uiPageNodeSelector.selectPageNodeByUri(uri);
+
+         PortalRequestContext pcontext = (PortalRequestContext)event.getRequestContext();
+         UIPortalApplication uiPortalApp = uiPageNodeSelector.getAncestorOfType(UIPortalApplication.class);
+         UIPortalToolPanel uiToolPanel = Util.getUIPortalToolPanel();
+         uiToolPanel.setRenderSibling(UIPortalToolPanel.class);
+         uiToolPanel.setShowMaskLayer(true);
+         UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+         pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
+         pcontext.setFullRender(true);
+
+         UIContainer uiParent = uiPageNodeSelector.getParent();
+         PageNode node = null;
+         if (uiPageNodeSelector.getSelectedNode() == null)
+         {
+            node = Util.getUIPortal().getSelectedNode();
+         }
+         else
+         {
+            node = uiPageNodeSelector.getSelectedNode().getNode();
+         }
+         if (node == null)
+         {
+            uiPageNodeSelector.selectNavigation(uiPageNodeSelector.getSelectedNavigation());
+            uiToolPanel.setUIComponent(null);
+            return;
+         }
+
+         UserPortalConfigService configService = uiParent.getApplicationComponent(UserPortalConfigService.class);
+         Page page = null;
+         if (node.getPageReference() != null)
+         {
+            page = configService.getPage(node.getPageReference(), event.getRequestContext().getRemoteUser());
+         }
+
+         if (page == null)
+         {
+            uiToolPanel.setUIComponent(null);
+            return;
+         }
+
+         UIPage uiPage = Util.toUIPage(node, uiToolPanel);
+         UIPageBody uiPageBody = uiPortalApp.findFirstComponentOfType(UIPageBody.class);
+         if (uiPageBody.getUIComponent() != null)
+         {
+            uiPageBody.setUIComponent(null);
+         }
+         uiToolPanel.setUIComponent(uiPage);
+      }
+   }
+
+   public static class SelectedNode
+   {
+
+      private PageNavigation nav;
+
+      private PageNode parentNode;
+
+      private PageNode node;
+
+      private boolean deleteNode = false;
+
+      private boolean cloneNode = false;
+
+      public SelectedNode(PageNavigation nav, PageNode parentNode, PageNode node)
+      {
+         this.nav = nav;
+         this.parentNode = parentNode;
+         this.node = node;
+      }
+
+      public PageNavigation getPageNavigation()
+      {
+         return nav;
+      }
+
+      public void setPageNavigation(PageNavigation nav)
+      {
+         this.nav = nav;
+      }
+
+      public PageNode getParentNode()
+      {
+         return parentNode;
+      }
+
+      public void setParentNode(PageNode parentNode)
+      {
+         this.parentNode = parentNode;
+      }
+
+      public PageNode getNode()
+      {
+         return node;
+      }
+
+      public void setNode(PageNode node)
+      {
+         this.node = node;
+      }
+
+      public boolean isDeleteNode()
+      {
+         return deleteNode;
+      }
+
+      public void setDeleteNode(boolean deleteNode)
+      {
+         this.deleteNode = deleteNode;
+      }
+
+      public boolean isCloneNode()
+      {
+         return cloneNode;
+      }
+
+      public void setCloneNode(boolean b)
+      {
+         cloneNode = b;
+      }
+   }
+
 }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -20,25 +20,18 @@
 package org.exoplatform.portal.webui.navigation;
 
 import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteType;
-import org.exoplatform.portal.mop.Visibility;
-import org.exoplatform.portal.mop.navigation.NodeFilter;
-import org.exoplatform.portal.mop.navigation.Scope;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserNode;
-import org.exoplatform.portal.mop.user.UserNodePredicate;
-import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
 import org.exoplatform.portal.webui.portal.PageNodeEvent;
 import org.exoplatform.portal.webui.portal.UIPortal;
 import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.web.application.JavascriptManager;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.core.UIComponent;
 import org.exoplatform.webui.event.Event;
 import org.exoplatform.webui.event.EventListener;
+
 import java.util.ArrayList;
-import java.util.LinkedList;
 import java.util.List;
 
 /**
@@ -51,26 +44,22 @@
 
    private boolean showUserNavigation = true;
 
+   protected PageNode selectedNode_;
+
+   protected Object selectedParent_;
+
    private TreeNode treeNode_;
 
    private String cssClassName = "";
 
    private String template;
+   
+   private final static String PORTAL_NAV = "portal";
+   
+   private final static String GROUP_NAV = "group";
+   
+   private final static String USER_NAV = "user";
 
-   private final NodeFilter NAVIGATION_FILTER;
-   private static final Scope PORTAL_NAVIGATION_SCOPE = Scope.GRANDCHILDREN;
-
-   private static final Scope SITEMAP_SCOPE = Scope.CHILDREN;
-
-   public UIPortalNavigation()
-   {
-      UserPortal userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal();
-      UserNodePredicate.Builder scopeBuilder = UserNodePredicate.builder();
-      scopeBuilder.withAuthorizationCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
-      scopeBuilder.withTemporalCheck();
-      NAVIGATION_FILTER = userPortal.createFilter(scopeBuilder.build());
-   }
-
    @Override
    public String getTemplate()
    {
@@ -117,89 +106,69 @@
       return cssClassName;
    }
 
-   public List<UserNode> getNavigations() throws Exception
+   public List<PageNavigation> getNavigations() throws Exception
    {
       WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
-      List<UserNode> nodes = new ArrayList<UserNode>();
+      List<PageNavigation> result = new ArrayList<PageNavigation>();
+
       if (context.getRemoteUser() != null)
       {
-         UserNode currRootNode = getCurrentNavigation();
-         if (currRootNode != null)
-         {
-            nodes.add(currRootNode);  
-         }
+         result.add(PageNavigationUtils.filter(getSelectedNavigation(), context.getRemoteUser()));
       }
       else
       {
-         UserPortal userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal();
-         List<UserNavigation> navigations = userPortal.getNavigations();
-         for (UserNavigation userNav : navigations)
+         for (PageNavigation nav : Util.getUIPortalApplication().getNavigations())
          {
-            if (!showUserNavigation && userNav.getKey().getType().equals(SiteType.USER))
-            {
+            if (!showUserNavigation && nav.getOwnerType().equals("user"))
                continue;
-            }
-
-            UserNode rootNode = userPortal.getNode(userNav, PORTAL_NAVIGATION_SCOPE);
-            if (rootNode != null)
-            {
-               rootNode.filter(NAVIGATION_FILTER);
-               nodes.add(rootNode);
-            }
+            result.add(PageNavigationUtils.filter(nav, null));
          }
       }
-      return nodes;
+      return result;
    }
 
    public void loadTreeNodes() throws Exception
    {
-      treeNode_ = new TreeNode();
-
-      UserPortal userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal();
-      List<UserNavigation> listNavigations = userPortal.getNavigations();
-
-      List<UserNode> childNodes = new LinkedList<UserNode>();
-      for (UserNavigation nav : rearrangeNavigations(listNavigations))
+      WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+      treeNode_ = new TreeNode(new PageNode(), new PageNavigation(), true);
+      List<PageNavigation> listNavigations = Util.getUIPortalApplication().getNavigations();
+      
+      for (PageNavigation nav : rearrangeNavigations(listNavigations))
       {
-         if (!showUserNavigation && nav.getKey().getTypeName().equals(PortalConfig.USER_TYPE))
+         if (!showUserNavigation && nav.getOwnerType().equals("user"))
          {
             continue;
          }
-         UserNode rootNode = userPortal.getNode(nav, SITEMAP_SCOPE);
-         if (rootNode != null)
-         {
-            rootNode.filter(NAVIGATION_FILTER);
-            childNodes.addAll(rootNode.getChildren());
-         }
+         PageNavigation filterNav = PageNavigationUtils.filter(nav, context.getRemoteUser());
+         treeNode_.setChildren(filterNav.getNodes(), filterNav);
       }
-      treeNode_.setChildren(childNodes);
    }
-
+   
    /**
     * 
     * @param listNavigation
     * @return
     */
-   private List<UserNavigation> rearrangeNavigations(List<UserNavigation> listNavigation)
+   private List<PageNavigation> rearrangeNavigations(List<PageNavigation> listNavigation)
    {
-      List<UserNavigation> returnNavs = new ArrayList<UserNavigation>();
+      List<PageNavigation> returnNavs = new ArrayList<PageNavigation>();
 
-      List<UserNavigation> portalNavs = new ArrayList<UserNavigation>();
-      List<UserNavigation> groupNavs = new ArrayList<UserNavigation>();
-      List<UserNavigation> userNavs = new ArrayList<UserNavigation>();
+      List<PageNavigation> portalNavs = new ArrayList<PageNavigation>();
+      List<PageNavigation> groupNavs = new ArrayList<PageNavigation>();
+      List<PageNavigation> userNavs = new ArrayList<PageNavigation>();
 
-      for (UserNavigation nav : listNavigation)
+      for (PageNavigation nav : listNavigation)
       {
-         String ownerType = nav.getKey().getTypeName();
-         if (PortalConfig.PORTAL_TYPE.equals(ownerType))
+         String ownerType = nav.getOwnerType();
+         if (PORTAL_NAV.equals(ownerType))
          {
             portalNavs.add(nav);
          }
-         else if (PortalConfig.GROUP_TYPE.equals(ownerType))
+         else if (GROUP_NAV.equals(ownerType))
          {
             groupNavs.add(nav);
          }
-         else if (PortalConfig.USER_TYPE.equals(ownerType))
+         else if (USER_NAV.equals(ownerType))
          {
             userNavs.add(nav);
          }
@@ -217,40 +186,105 @@
       return treeNode_;
    }
 
-   public UserNode getCurrentNavigation() throws Exception
+   public PageNavigation getSelectedNavigation() throws Exception
    {
-      UserPortal userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal();
-      UserNavigation userNavigation = Util.getUIPortal().getUserNavigation();
-      UserNode rootNode = userPortal.getNode(userNavigation, PORTAL_NAVIGATION_SCOPE);
-      if (rootNode != null)
+      PageNavigation nav = Util.getUIPortal().getSelectedNavigation();
+      if (nav != null)
+         return nav;
+      if (Util.getUIPortal().getNavigations().size() < 1)
+         return null;
+      return Util.getUIPortal().getNavigations().get(0);
+   }
+
+   public Object getSelectedParent()
+   {
+      return selectedParent_;
+   }
+
+   public PageNode getSelectedPageNode() throws Exception
+   {
+      if (selectedNode_ != null)
+         return selectedNode_;
+      selectedNode_ = Util.getUIPortal().getSelectedNode();
+      return selectedNode_;
+   }
+
+   public boolean isSelectedNode(PageNode node)
+   {
+      if (selectedNode_ != null && node.getUri().equals(selectedNode_.getUri()))
+         return true;
+      if (selectedParent_ == null || selectedParent_ instanceof PageNavigation)
+         return false;
+      PageNode pageNode = (PageNode)selectedParent_;
+      return node.getUri().equals(pageNode.getUri());
+   }
+
+   public void processRender(WebuiRequestContext context) throws Exception
+   {
+      UIPortal uiPortal = Util.getUIPortal();
+      if ((uiPortal.getSelectedNode() != null) && (uiPortal.getSelectedNode() != selectedNode_))
       {
-         rootNode.filter(NAVIGATION_FILTER);
+         setSelectedPageNode(uiPortal.getSelectedNode());
       }
-      return rootNode;
+      super.processRender(context);
    }
 
-   public UserNode getSelectedPageNode() throws Exception
+   private void setSelectedPageNode(PageNode selectedNode) throws Exception
    {
-      return  Util.getUIPortal().getSelectedUserNode();
+      selectedNode_ = selectedNode;
+      selectedParent_ = null;
+      String seletctUri = selectedNode.getUri();
+      int index = seletctUri.lastIndexOf("/");
+      String parentUri = null;
+      if (index > 0)
+         parentUri = seletctUri.substring(0, seletctUri.lastIndexOf("/"));
+      List<PageNavigation> pageNavs = getNavigations();
+      for (PageNavigation pageNav : pageNavs)
+      {
+         if (PageNavigationUtils.searchPageNodeByUri(pageNav, selectedNode.getUri()) != null)
+         {
+            if (parentUri == null || parentUri.length() < 1)
+               selectedParent_ = pageNav;
+            else
+               selectedParent_ = PageNavigationUtils.searchPageNodeByUri(pageNav, parentUri);
+            break;
+         }
+      }
    }
 
    static public class SelectNodeActionListener extends EventListener<UIPortalNavigation>
    {
       public void execute(Event<UIPortalNavigation> event) throws Exception
       {
+         UIPortalNavigation uiNavigation = event.getSource();
          UIPortal uiPortal = Util.getUIPortal();
-         String treePath = event.getRequestContext().getRequestParameter(OBJECTID);
-
-         TreeNode selectedode = event.getSource().getTreeNodes().findNodes(treePath);
-         //There're may be interuption between browser and server
-         if (selectedode == null)
+         String uri = event.getRequestContext().getRequestParameter(OBJECTID);
+         int index = uri.lastIndexOf("::");
+         String id = uri.substring(index + 2);
+         PageNavigation selectNav = null;
+         if (index <= 0)
          {
-            event.getRequestContext().addUIComponentToUpdateByAjax(event.getSource());
-            return;
+            selectNav = uiPortal.getSelectedNavigation();
          }
-         
+         else
+         {
+            String navId = uri.substring(0, index);
+            //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+            selectNav = uiPortal.getSelectedNavigation();
+         }
+         PageNode selectNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
+         uiNavigation.selectedNode_ = selectNode;
+         String parentUri = null;
+         index = uri.lastIndexOf("/");
+         if (index > 0)
+            parentUri = uri.substring(0, index);
+         if (parentUri == null || parentUri.length() < 1)
+            uiNavigation.selectedParent_ = selectNav;
+         else
+            uiNavigation.selectedParent_ = PageNavigationUtils.searchPageNodeByUri(selectNav, parentUri);
+
          PageNodeEvent<UIPortal> pnevent;
-         pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, selectedode.getNode().getURI());
+         pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
          uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
       }
    }
@@ -259,34 +293,41 @@
    {
       public void execute(Event<UIPortalNavigation> event) throws Exception
       {
-         String treePath = event.getRequestContext().getRequestParameter(OBJECTID);
-                                                        
-         TreeNode treeNode = event.getSource().getTreeNodes();
-         TreeNode expandTree = treeNode.findNodes(treePath);
-         //There're may be interuption between browser and server
-         if (expandTree == null)
+         UIPortalNavigation uiNavigation = event.getSource();
+
+         TreeNode treeNode = uiNavigation.getTreeNodes();
+         List<PageNavigation> all_Navigations = Util.getUIPortalApplication().getNavigations();
+         
+         // get URI
+         String uri = event.getRequestContext().getRequestParameter(OBJECTID);
+         int index = uri.lastIndexOf("::");
+         String id = uri.substring(index + 2);
+
+         // get PageNavigation by uri
+         PageNavigation selectNav = null;
+
+         String navId = uri.substring(0, index);
+         selectNav = PageNavigationUtils.findNavigationByID(all_Navigations, Integer.parseInt(navId));
+         if(selectNav == null)
          {
-            event.getRequestContext().addUIComponentToUpdateByAjax(event.getSource());
             return;
          }
+         
+         // get PageNode by uri
+         PageNode expandNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
 
-         UserPortal userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal();
-
-         UserNode expandNode = userPortal.getNode(expandTree.getNode(), SITEMAP_SCOPE);
-         if (expandNode == null)
+         TreeNode expandTree = null;
+         if (treeNode.getChildren() != null)
          {
-            event.getSource().loadTreeNodes();
-            event.getRequestContext().getUIApplication().addMessage(new
-               ApplicationMessage("UIPortalNavigation.msg.staleData", null, ApplicationMessage.WARNING));
+            expandTree = treeNode.getChildByPath(uri, treeNode);
          }
-         else
+
+         if(expandTree != null)
          {
-            expandNode.filter(event.getSource().NAVIGATION_FILTER);
-            expandTree.setChildren(expandNode.getChildren());
-            expandTree.setExpanded(true);
+            expandTree.setChildren(expandNode.getChildren(), selectNav);
          }
-                               
-         event.getRequestContext().addUIComponentToUpdateByAjax(event.getSource());
+         
+         event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
       }
    }
 
@@ -294,19 +335,41 @@
    {
       public void execute(Event<UIPortalNavigation> event) throws Exception
       {
+         UIPortalNavigation uiNavigation = event.getSource();
+
+         TreeNode treeNode = uiNavigation.getTreeNodes();
+         UIPortal uiPortal = Util.getUIPortal();
+
          // get URI
-         String treePath = event.getRequestContext().getRequestParameter(OBJECTID);
+         String uri = event.getRequestContext().getRequestParameter(OBJECTID);
 
-         UIPortalNavigation uiNavigation = event.getSource();
-         TreeNode rootNode = uiNavigation.getTreeNodes();
+         int index = uri.lastIndexOf("::");
+         String id = uri.substring(index + 2);
+
+         // get PageNavigation by uri
+         PageNavigation selectNav = null;
+
+         String navId = uri.substring(0, index);
          
-         TreeNode collapseTree = rootNode.findNodes(treePath);
-         if (collapseTree != null)
+         //TODO: Minh Hoang TO
+         //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+         selectNav = uiPortal.getSelectedNavigation();
+         
+         // get PageNode by uri
+         PageNode expandNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
+
+         TreeNode expandTree = null;
+         if (treeNode.getChildren() != null)
          {
-            collapseTree.setExpanded(false);
-         }         
+            expandTree = treeNode.getChildByPath(uri, treeNode);
+         }
          
-         Util.getPortalRequestContext().setResponseComplete(true);
+         if(expandTree != null) 
+         {
+            expandTree.setExpanded(false);
+         }
+         
+         event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
       }
    }
 
@@ -314,7 +377,9 @@
    {
       public void execute(Event<UIPortalNavigation> event) throws Exception
       {
+         PortalRequestContext prContext = Util.getPortalRequestContext();
          UIPortalNavigation uiNavigation = event.getSource();
+
          uiNavigation.loadTreeNodes();
 
          event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
@@ -343,19 +408,19 @@
          {
             for (TreeNode child : treeNode.getChildren())
             {
-//               PageNode expandNode = child.getNode();
-//               PageNavigation selectNav = child.getNavigation();
-//
-//               // set node to child tree
-//               if (expandNode.getChildren().size() > 0)
-//               {
-//                  child.setChildren(expandNode.getChildren(), selectNav);
-//               }
+               PageNode expandNode = child.getNode();
+               PageNavigation selectNav = child.getNavigation();
 
+               // set node to child tree
+               if (expandNode.getChildren().size() > 0)
+               {
+                  child.setChildren(expandNode.getChildren(), selectNav);
+               }
+
                // expand child tree
                expandAllNode(child);
             }
          }
       }
-   }   
+   }
 }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/PageQueryAccessList.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/PageQueryAccessList.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/PageQueryAccessList.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -27,6 +27,8 @@
 import org.exoplatform.portal.config.Query;
 import org.exoplatform.portal.config.model.Page;
 
+import java.util.Comparator;
+
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
@@ -44,6 +46,12 @@
    {
       ExoContainer container = PortalContainer.getInstance();
       DataStorage service = (DataStorage)container.getComponentInstance(DataStorage.class);
-      return service.find2(state);
+      return service.find2(state, new Comparator<Page>()
+      {
+         public int compare(Page page1, Page page2)
+         {
+            return page1.getName().compareTo(page2.getName());
+         }
+      });
    }
 }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIDesktopPage.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIDesktopPage.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIDesktopPage.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -22,11 +22,12 @@
 import org.exoplatform.portal.config.DataStorage;
 import org.exoplatform.portal.config.model.ModelObject;
 import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.mop.user.UserNavigation;
+import org.exoplatform.portal.config.model.PageNavigation;
 import org.exoplatform.portal.webui.application.UIAddNewApplication;
 import org.exoplatform.portal.webui.application.UIApplication;
 import org.exoplatform.portal.webui.application.UIGadget;
 import org.exoplatform.portal.webui.application.UIPortlet;
+import org.exoplatform.portal.webui.navigation.PageNavigationUtils;
 import org.exoplatform.portal.webui.page.UIPageActionListener.DeleteGadgetActionListener;
 import org.exoplatform.portal.webui.page.UIPageActionListener.RemoveChildActionListener;
 import org.exoplatform.portal.webui.portal.PageNodeEvent;
@@ -74,10 +75,16 @@
       return true;
    }
 
-   //TODO: This is not used anymore in WebOS 2.0
-   public List<UserNavigation> getNavigations() throws Exception
+   public List<PageNavigation> getNavigations() throws Exception
    {
-      throw new UnsupportedOperationException("This is not used anymore in WebOS 2.0");
+      List<PageNavigation> allNav = Util.getUIPortal().getNavigations();
+      String removeUser = Util.getPortalRequestContext().getRemoteUser();
+      List<PageNavigation> result = new ArrayList<PageNavigation>();
+      for (PageNavigation nav : allNav)
+      {
+         result.add(PageNavigationUtils.filter(nav, removeUser));
+      }
+      return result;
    }
 
    static public class SaveGadgetPropertiesActionListener extends EventListener<UIPage>

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -19,21 +19,22 @@
 
 package org.exoplatform.portal.webui.page;
 
+import org.exoplatform.container.ExoContainer;
 import org.exoplatform.portal.application.PortalRequestContext;
 import org.exoplatform.portal.config.DataStorage;
 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.ModelObject;
 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.mop.SiteKey;
-import org.exoplatform.portal.mop.user.NavigationPath;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserPortal;
 import org.exoplatform.portal.webui.application.UIGadget;
 import org.exoplatform.portal.webui.portal.PageNodeEvent;
 import org.exoplatform.portal.webui.portal.UIPortal;
 import org.exoplatform.portal.webui.util.PortalDataMapper;
+import org.exoplatform.portal.webui.util.Util;
 import org.exoplatform.portal.webui.workspace.UIPortalApplication;
 import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
 import org.exoplatform.web.application.ApplicationMessage;
@@ -51,81 +52,331 @@
  */
 public class UIPageActionListener
 {
+
    static public class ChangePageNodeActionListener extends EventListener<UIPortal>
    {
+      @Override
       public void execute(Event<UIPortal> event) throws Exception
       {
          UIPortal showedUIPortal = event.getSource();
          UIPortalApplication uiPortalApp = showedUIPortal.getAncestorOfType(UIPortalApplication.class);
          
-         UserPortal userPortal = uiPortalApp.getUserPortalConfig().getUserPortal();
+         //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.setFullRender(true);
+         pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
          
-         String uri = ((PageNodeEvent<UIPortal>)event).getTargetNodeUri();
-         NavigationPath naviPath = userPortal.resolvePath(uri);
-         UserNavigation targetNav = naviPath.getNavigation();
+         PageNavigation currentNav = showedUIPortal.getSelectedNavigation();
+         String currentUri = showedUIPortal.getSelectedNode().getUri();
+         if(currentUri.startsWith("/"))
+         {
+            currentUri = currentUri.substring(1);
+         }
          
-         NavigationPath currentNavPath = showedUIPortal.getNavPath();
+         //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)
+         {
+            List<PageNode> currentSelectedPath = findPath(currentNav, currentUri.split("/"));
+            showedUIPortal.setSelectedPath(currentSelectedPath);
+         }
          
-         if(currentNavPath != null && currentNavPath.getNavigation().getKey().equals(targetNav.getKey()))
+         String targetedUri = ((PageNodeEvent<UIPortal>)event).getTargetNodeUri();
+         if(targetedUri.startsWith("/"))
          {
+            targetedUri = targetedUri.substring(1);
+         }
+         
+         PageNavigation targetedNav = getTargetedNav(uiPortalApp, targetedUri);
+         
+         if(targetedNav == null)
+         {
+            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(!currentNavPath.getTarget().getURI().equals(naviPath.getTarget().getURI()))
+            if(!currentUri.equals(targetedUri))
             {
-               showedUIPortal.setNavPath(naviPath);
+               showedUIPortal.setSelectedNode(targetPageNode);
+               showedUIPortal.setSelectedPath(targetedPathNodes);
             }
          }
          else
          {
             // Case 2: Either navigation type or id has been changed
             // First, we try to find a cached UIPortal
-            UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
             uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
             uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
-            showedUIPortal = uiPortalApp.getCachedUIPortal(targetNav.getKey());
+            showedUIPortal = uiPortalApp.getCachedUIPortal(newNavType, newNavId);
             if (showedUIPortal != null)
             {
-               showedUIPortal.setNavPath(naviPath);
+               showedUIPortal.setSelectedNode(targetPageNode);
+               showedUIPortal.setSelectedPath(targetedPathNodes);
                uiPortalApp.setShowedUIPortal(showedUIPortal);
                
                //Temporary solution to fix edit inline error while switching between navigations
                DataStorage storageService = uiPortalApp.getApplicationComponent(DataStorage.class);
-               PortalConfig associatedPortalConfig = storageService.getPortalConfig(targetNav.getKey().getTypeName(), targetNav.getKey().getName());
+               PortalConfig associatedPortalConfig = storageService.getPortalConfig(newNavType, newNavId);
                UserPortalConfig userPortalConfig = uiPortalApp.getUserPortalConfig();
                
                //Update layout-related data on UserPortalConfig
                userPortalConfig.setPortal(associatedPortalConfig);
+
+               //Update selected navigation on UserPortalConfig, that is mandatory as at the moment the PortalConfig
+               //does not hold any navigation data.
+               userPortalConfig.updateSelectedNavigation(newNavType, newNavId);
             }
             else
             {
-               showedUIPortal = buildUIPortal(targetNav.getKey(), uiPortalApp, uiPortalApp.getUserPortalConfig());
+               showedUIPortal = buildUIPortal(targetedNav, uiPortalApp, uiPortalApp.getUserPortalConfig());
                if(showedUIPortal == null)
                {
                   return;
                }
-               showedUIPortal.setNavPath(naviPath);
+               showedUIPortal.setSelectedNode(targetPageNode);
+               showedUIPortal.setSelectedPath(targetedPathNodes);
                uiPortalApp.setShowedUIPortal(showedUIPortal);
                uiPortalApp.putCachedUIPortal(showedUIPortal);
             }
          }
-         
          showedUIPortal.refreshUIPage();
       }
+      
+      /**
+       * 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)
+         {
+            return uiPortalApp.getNavigations().get(0);
+         }
+         
+         String[] pathNodes = targetedUri.split("/");
+         
+         return getBestMatchNavigation(allNavs, pathNodes);
+      }
+      
+      /**
+       * Get the navigation containing longest subpath of 'pathNodes'
+       * 
+       * @param listNav
+       * @param pathNodes
+       * @return
+       */
+      private PageNavigation getBestMatchNavigation(List<PageNavigation> listNav, String[] pathNodes)
+      {
+         int temporalMaximalMatching = 0;
+         PageNavigation temporalBestNavigation = listNav.get(0);
+         
+         for(PageNavigation nav : listNav)
+         {
+            int currentNumberOfMatching = countNumberOfMatchedPathNodes(nav, pathNodes);
+            
+            //The whole pathNodes matches current navigation
+            if(currentNumberOfMatching == pathNodes.length)
+            {
+               return nav;
+            }
+            
+            if(currentNumberOfMatching > temporalMaximalMatching)
+            {
+               temporalMaximalMatching = currentNumberOfMatching;
+               temporalBestNavigation = nav;
+            }
+         }
+         return temporalBestNavigation;
+      }
+      
+      /**
+       * Count the maximal number of nodes matching the pathNodes while descending the navigation 'nav'
+       * 
+       * @param nav
+       * @param pathNodes
+       * @return
+       */
+      private int countNumberOfMatchedPathNodes(PageNavigation nav, String[] pathNodes)
+      {
+         if(pathNodes.length == 0)
+         {
+            return 0;
+         }
+         
+         PageNode currentNode = nav.getNode(pathNodes[0]);
+         int numberOfMatch = (currentNode != null)? 1 : 0 ;
+         
+         for(int i = 1; i < pathNodes.length; i++)
+         {
+            if(currentNode == null)
+            {
+               break;
+            }
+            currentNode = currentNode.getChild(pathNodes[i]);
+         }
+         return numberOfMatch;
+      }
+      
+      /**
+       * Fetch the currently selected pageNode under a PageNavigation. It is the last node encountered
+       * while descending the pathNodes
+       * 
+       * This method returns <code>null</code> iff only 'notfound' node remains in the navigation
+       * 
+       * @param targetedNav
+       * @param pathNodes
+       * @return
+       */
+      private PageNode getTargetedNode(PageNavigation targetedNav, String[] pathNodes)
+      {
+         //Case users browses to a URL of the form  */portal/public/classic
+         if(pathNodes.length == 0)
+         {
+           return getDefaultNode(targetedNav);
+         }
+         
+         PageNode currentNode = targetedNav.getNode(pathNodes[0]);
+         if(currentNode == null)
+         {
+            return getDefaultNode(targetedNav);
+         }
+         
+         PageNode tempNode = null;
+         
+         for(int i = 1; i < pathNodes.length; i++)
+         {
+            tempNode = currentNode.getChild(pathNodes[i]);
+            if (tempNode == null)
+            {
+               break;
+            }
+            else
+            {
+               currentNode = tempNode;
+            }
+         }
+         return currentNode;
+      }
+      
+      /**
+       * Default node of a navigation. This method returns
+       * 
+       * 1. The first node in the list of 'nav' 's children if the list contains
+       * at least one child other than 'notfound'
+       * 
+       * 2. <code>null</code> otherwise
+       * 
+       * @param nav
+       * @return
+       */
+      private PageNode getDefaultNode(PageNavigation nav)
+      {
+         PageNode defaultNode = null;
+         try
+         {
+            if (nav != null && nav.getNodes().size() > 0)
+            {
+               WebuiRequestContext context = Util.getPortalRequestContext();
+               ExoContainer appContainer = context.getApplication().getApplicationServiceContainer();
+               UserPortalConfigService userPortalConfigService = (UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
+               
+               for (PageNode pageNode : nav.getNodes())
+               {
+                  Page page = userPortalConfigService.getPage(pageNode.getPageReference(), context.getRemoteUser());
+                  if (page != null)
+                  {
+                     defaultNode = pageNode;
+                     break;
+                  }
+               }
+            }
+            else
+            {
+               return null;
+            }
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+            return null;
+         }
+         if (defaultNode != null && !("notfound".equals(defaultNode.getName())))
+         {
+            return defaultNode;
+         }
+         else
+         {
+            return null;
+         }
+      }
+      
+      private List<PageNode> findPath(PageNavigation nav, String[] pathNodes)
+      {
+         List<PageNode> nodes = new ArrayList<PageNode>(4);
+         
+         //That happens when user browses to a URL like /portal/public/classic
+         if(pathNodes.length == 0)
+         {
+            nodes.add(getDefaultNode(nav));
+            return nodes;
+         }
+         PageNode startNode = nav.getNode(pathNodes[0]);
+         if (startNode == null)
+         {
+            nodes.add(getDefaultNode(nav));
+            return nodes;
+         }
+         nodes.add(startNode);
 
-      private UIPortal buildUIPortal(SiteKey newPageNav, UIPortalApplication uiPortalApp, UserPortalConfig userPortalConfig) throws Exception
+         for (int i = 1; i < pathNodes.length; i++)
+         {
+            startNode = startNode.getChild(pathNodes[i]);
+            if(startNode == null)
+            {
+               break;
+            }
+            else
+            {
+               nodes.add(startNode);
+            }
+         }
+         return nodes;
+      }
+
+      private UIPortal buildUIPortal(PageNavigation newPageNav, UIPortalApplication uiPortalApp, UserPortalConfig userPortalConfig) throws Exception
       {
          DataStorage storage = uiPortalApp.getApplicationComponent(DataStorage.class);
          if(storage == null){
             return null;
          }
-         PortalConfig portalConfig = storage.getPortalConfig(newPageNav.getTypeName(), newPageNav.getName());
+         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);
          PortalDataMapper.toUIPortal(uiPortal, userPortalConfig);
          return uiPortal;
       }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -23,11 +23,13 @@
 import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.Page;
 import org.exoplatform.portal.config.model.PageBody;
-import org.exoplatform.portal.mop.user.UserNode;
+import org.exoplatform.portal.config.model.PageNode;
 import org.exoplatform.portal.webui.portal.UIPortal;
 import org.exoplatform.portal.webui.portal.UIPortalComponent;
 import org.exoplatform.portal.webui.util.PortalDataMapper;
 import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+import org.exoplatform.web.application.ApplicationMessage;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
 import org.exoplatform.webui.core.UIComponent;
@@ -44,6 +46,7 @@
 
    private String storageId;
 
+   @SuppressWarnings("unused")
    public UIPageBody(PageBody model) throws Exception
    {
       setId("UIPageBody");
@@ -64,12 +67,13 @@
       setId("UIPageBody");
    }
 
+   @SuppressWarnings("unused")
    public void init(PageBody model) throws Exception
    {
       setId("UIPageBody");
    }
 
-   public void setPageBody(UserNode pageNode, UIPortal uiPortal) throws Exception
+   public void setPageBody(PageNode pageNode, UIPortal uiPortal) throws Exception
    {
       WebuiRequestContext context = Util.getPortalRequestContext();
       uiPortal.setMaximizedUIComponent(null);
@@ -110,7 +114,7 @@
     * @param uiPortal
     * @return
     */
-   private UIPage getUIPage(UserNode pageNode, UIPortal uiPortal, WebuiRequestContext context)
+   private UIPage getUIPage(PageNode pageNode, UIPortal uiPortal, WebuiRequestContext context)
       throws Exception
    {
       Page page = null;
@@ -118,7 +122,7 @@
       
       if (pageNode != null)
       {
-         pageReference = pageNode.getPageRef();
+         pageReference = pageNode.getPageReference();
          if (pageReference != null)
          {
             ExoContainer appContainer = context.getApplication().getApplicationServiceContainer();

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -29,13 +29,9 @@
 import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.ModelObject;
 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.mop.SiteKey;
-import org.exoplatform.portal.mop.navigation.Scope;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserNode;
-import org.exoplatform.portal.mop.user.UserNodePredicate;
-import org.exoplatform.portal.mop.user.UserPortal;
 import org.exoplatform.portal.webui.application.UIPortlet;
 import org.exoplatform.portal.webui.portal.PageNodeEvent;
 import org.exoplatform.portal.webui.portal.UIPortal;
@@ -61,8 +57,8 @@
 import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
 import org.exoplatform.webui.core.model.SelectItemOption;
 import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
 import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.event.EventListener;
 import org.exoplatform.webui.form.UIForm;
 import org.exoplatform.webui.form.UIFormInputItemSelector;
 import org.exoplatform.webui.form.UIFormInputSet;
@@ -282,11 +278,6 @@
          PageListAccess datasource = (PageListAccess)repeater.getDataSource();
          int currentPage = datasource.getCurrentPage();
 
-         //Update navigation and UserToolbarGroupPortlet if deleted page is dashboard page
-         if(page.getOwnerType().equals(PortalConfig.USER_TYPE)){
-            removePageNode(page, event);
-         }
-
          dataService.remove(page);
          //Minh Hoang TO: The cached UIPage objects corresponding to removed Page should be removed here.
          //As we have multiple UIPortal, which means multiple caches of UIPage. It 's unwise to garbage
@@ -294,11 +285,11 @@
          //removed
          
          UIPortal uiPortal = Util.getUIPortal();
-         UserNode userNode = uiPortal.getSelectedUserNode();
-         if (userNode.getPageRef().equals(page.getPageId()))
+         if (uiPortal.getSelectedNode().getPageReference().equals(page.getPageId()))
          {
             PageNodeEvent<UIPortal> pnevent =
-               new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, userNode.getURI());
+               new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uiPortal.getSelectedNode()
+                  .getUri());
             uiPortal.broadcast(pnevent, Phase.PROCESS);
          }
          else
@@ -313,6 +304,11 @@
             datasource.getPage(currentPage);
             event.getRequestContext().addUIComponentToUpdateByAjax(uiPageBrowser);
          }
+         
+         //Update navigation and UserToolbarGroupPortlet if deleted page is dashboard page
+         if(page.getOwnerType().equals(PortalConfig.USER_TYPE)){
+            removePageNode(page, event);
+         }
       }
       
       /**
@@ -327,40 +323,58 @@
        */
       private void removePageNode(Page page, Event<UIPageBrowser> event) throws Exception
       {
+         UIPageBrowser uiPageBrowser = event.getSource();
+         DataStorage dataService = uiPageBrowser.getApplicationComponent(DataStorage.class);
+
+         PageNavigation pageNavigation = null;
          UIPortalApplication portalApplication = Util.getUIPortalApplication();
-         UserPortal userPortal = portalApplication.getUserPortalConfig().getUserPortal();
 
-         UserNavigation userNav = userPortal.getNavigation(SiteKey.user(event.getRequestContext().getRemoteUser()));
-         UserNode rootNode = userPortal.getNode(userNav, Scope.CHILDREN);
-         if (rootNode == null)
+         List<PageNavigation> listPageNavigation = portalApplication.getNavigations();
+
+         for (PageNavigation pageNvg : listPageNavigation)
          {
-            return;
+            if (pageNvg.getOwnerType().equals(PortalConfig.USER_TYPE))
+            {
+               pageNavigation = pageNvg;
+               break;
+            }
          }
-         rootNode.filter(userPortal.createFilter(UserNodePredicate.builder().build()));
+         UIPortal uiPortal = Util.getUIPortal();
 
-         for (UserNode userNode : rootNode.getChildren())
+         PageNode tobeRemoved = null;
+         List<PageNode> nodes = pageNavigation.getNodes();
+         for (PageNode pageNode : nodes)
          {
-            if (page.getPageId().equals(userNode.getPageRef()))
+            String pageReference = pageNode.getPageReference();
+            String pageId = page.getPageId();
+
+            if (pageReference != null && pageReference.equals(pageId))
             {
-               // Remove pageNode
-               rootNode.removeChild(userNode.getName());
-               rootNode.save();
+               tobeRemoved = pageNode;
+               break;
+            }
+         }
 
-               // Update navigation and UserToolbarGroupPortlet
+         if (tobeRemoved != null)
+         {
+            // Remove pageNode
+            pageNavigation.getNodes().remove(tobeRemoved);
 
-               String pageRef = page.getPageId();
-               if (pageRef != null && pageRef.length() > 0)
-               {
-                  // Remove from cache
-                  UIPortal uiPortal = Util.getUIPortal();
-                  uiPortal.clearUIPage(pageRef);
-               }
+            // Update navigation and UserToolbarGroupPortlet
 
-               //Update UserToolbarGroupPortlet
-               UIWorkingWorkspace uiWorkingWS = portalApplication.getChild(UIWorkingWorkspace.class);
-               uiWorkingWS.updatePortletsByName("UserToolbarDashboardPortlet");
-               return;
+            String pageRef = tobeRemoved.getPageReference();
+            if (pageRef != null && pageRef.length() > 0)
+            {
+               // Remove from cache
+               uiPortal.clearUIPage(pageRef);
             }
+
+            dataService.save(pageNavigation);
+
+            //Update UserToolbarGroupPortlet
+            UIWorkingWorkspace uiWorkingWS = portalApplication.getChild(UIWorkingWorkspace.class);
+            uiWorkingWS.updatePortletsByName("UserToolbarDashboardPortlet");
+
          }
       }
    }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -23,9 +23,9 @@
 import org.exoplatform.portal.config.DataStorage;
 import org.exoplatform.portal.config.UserACL;
 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.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserNode;
 import org.exoplatform.portal.webui.navigation.UIPageNodeSelector;
 import org.exoplatform.portal.webui.portal.PageNodeEvent;
 import org.exoplatform.portal.webui.portal.UIPortal;
@@ -36,16 +36,18 @@
 import org.exoplatform.portal.webui.workspace.UIPortalToolPanel;
 import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
 import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.web.application.JavascriptManager;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
 import org.exoplatform.webui.config.annotation.ComponentConfigs;
 import org.exoplatform.webui.config.annotation.EventConfig;
 import org.exoplatform.webui.event.Event;
 import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.form.UIFormStringInput;
 
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
 
 /** Created by The eXo Platform SARL Author : Dang Van Minh minhdv81 at yahoo.com Jun 23, 2006 */
 @ComponentConfigs(@ComponentConfig(template = "system:/groovy/webui/core/UIWizard.gtmpl", events = {
@@ -73,38 +75,62 @@
       setNumberSteps(NUMBER_OF_STEPs);
       viewStep(FIRST_STEP);
       setShowWelcomeComponent(false);
-      boolean isUserNav = Util.getUIPortal().getSiteKey().getTypeName().equals(PortalConfig.USER_TYPE);
-      UserNavigation navigation = Util.getUIPortal().getNavPath().getNavigation();
-      uiPageInfo.getChild(UIPageNodeSelector.class).setNavigation(navigation);
-
+      boolean isUserNav = Util.getUIPortal().getSelectedNavigation().getOwnerType().equals(PortalConfig.USER_TYPE);
       if (isUserNav)
       {
          uiPageInfo.getChild(UIPageNodeSelector.class).setRendered(false);
       }
    }
 
-   private UserNode saveData() throws Exception
+   private void saveData() throws Exception
    {
       UIPagePreview uiPagePreview = getChild(UIPagePreview.class);
       UIPage uiPage = (UIPage)uiPagePreview.getUIComponent();
+      
 
       UIWizardPageSetInfo uiPageInfo = getChild(UIWizardPageSetInfo.class);
       UIPageNodeSelector uiNodeSelector = uiPageInfo.getChild(UIPageNodeSelector.class);
-      UserNode selectedNode = uiNodeSelector.getSelectedNode();
+      PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
+      PageNavigation pageNav = uiNodeSelector.getSelectedNavigation();
+      if (PortalConfig.USER_TYPE.equals(pageNav.getOwnerType()))
+         selectedNode = null;
 
       Page page = (Page)PortalDataMapper.buildModelObject(uiPage);
-      UserNode pageNode = uiPageInfo.createUserNode(selectedNode);
-      
-      pageNode.setPageRef(page.getPageId());
+      PageNode pageNode = uiPageInfo.getPageNode();
+      pageNode.setPageReference(page.getPageId());
       if (selectedNode != null)
       {
-         selectedNode.addChild(pageNode);
+         List<PageNode> children = selectedNode.getChildren();
+         if (children == null)
+         {
+            children = new ArrayList<PageNode>();
+         }
+         children.add(pageNode);
+         selectedNode.setChildren((ArrayList<PageNode>)children);
       }
+      else
+      {
+         pageNav.addNode(pageNode);
+      }
+      uiNodeSelector.selectPageNodeByUri(pageNode.getUri());
+
       DataStorage dataService = getApplicationComponent(DataStorage.class); 
       dataService.create(page);
-      selectedNode.save();
-      return pageNode;
+      dataService.save(pageNav);
+      UIPortal uiPortal = Util.getUIPortal();
+      setNavigation(uiPortal.getNavigations(), uiNodeSelector.getSelectedNavigation());
+   }
 
+   private void setNavigation(List<PageNavigation> navs, PageNavigation nav)
+   {
+      for (int i = 0; i < navs.size(); i++)
+      {
+         if (navs.get(i).getId() == nav.getId())
+         {
+            navs.set(i, nav);
+            return;
+         }
+      }
    }
 
    /**
@@ -117,12 +143,29 @@
    private boolean isSelectedNodeExist() throws Exception
    {
       UIWizardPageSetInfo uiPageSetInfo = getChild(UIWizardPageSetInfo.class);
-      String pageName = uiPageSetInfo.getUIStringInput(UIWizardPageSetInfo.PAGE_NAME).getValue();
-      UserNode selectedPageNode = uiPageSetInfo.getSelectedPageNode();
-      if (selectedPageNode.getChild(pageName) != null)
+      PageNavigation navigation = uiPageSetInfo.getChild(UIPageNodeSelector.class).getSelectedNavigation();
+      PageNode pageNode = uiPageSetInfo.getPageNode();
+      PageNode selectedPageNode = uiPageSetInfo.getSelectedPageNode();
+      List<PageNode> sibbling = null;
+      if (selectedPageNode != null)
       {
-         return true;
+         sibbling = selectedPageNode.getChildren();
       }
+      else
+      {
+         sibbling = navigation.getNodes();
+      }
+      if (sibbling != null)
+      {
+         for (PageNode ele : sibbling)
+         {
+            if (ele.getUri().equals(pageNode.getUri()))
+            {
+               return true;
+            }
+         }
+      }
+
       return false;
    }
 
@@ -172,7 +215,7 @@
          UIWizardPageSetInfo uiPageSetInfo = uiWizard.getChild(UIWizardPageSetInfo.class);
          UIPageNodeSelector uiNodeSelector = uiPageSetInfo.getChild(UIPageNodeSelector.class);
          uiWizard.updateWizardComponent();
-         UserNavigation navigation = uiNodeSelector.getNavigation();
+         PageNavigation navigation = uiNodeSelector.getSelectedNavigation();
          if (navigation == null)
          {
             uiPortalApp.addMessage(new ApplicationMessage("UIPageCreationWizard.msg.notSelectedPageNavigation",
@@ -275,14 +318,14 @@
          UIWizardPageSetInfo uiPageInfo = uiWizard.getChild(UIWizardPageSetInfo.class);
 
          UIPageNodeSelector uiNodeSelector = uiPageInfo.getChild(UIPageNodeSelector.class);
-         UserNavigation pageNavi = uiNodeSelector.getNavigation();
-         String ownerType = pageNavi.getKey().getTypeName();
-         String ownerId = pageNavi.getKey().getName();
+         PageNavigation pageNavi = uiNodeSelector.getSelectedNavigation();
+         String ownerType = pageNavi.getOwnerType();
+         String ownerId = pageNavi.getOwnerId();
 
-         UIFormStringInput pageName = uiPageInfo.getUIStringInput(UIWizardPageSetInfo.PAGE_NAME);
+         PageNode pageNode = uiPageInfo.getPageNode();
          Page page = uiPageTemplateOptions.createPageFromSelectedOption(ownerType, ownerId);
          page.setName("page" + page.hashCode());
-         String pageId = ownerType + "::" + ownerId + "::" + page.getName();
+         String pageId = pageNavi.getOwnerType() + "::" + pageNavi.getOwnerId() + "::" + page.getName();
          DataStorage storage = uiWizard.getApplicationComponent(DataStorage.class);
          if (storage.getPage(pageId) != null)
          {
@@ -297,7 +340,7 @@
 
          if (page.getTitle() == null || page.getTitle().trim().length() == 0)
          {
-            page.setTitle(pageName.getValue());
+            page.setTitle(pageNode.getName());
          }
 
          boolean isDesktopPage = Page.DESKTOP_PAGE.equals(page.getFactoryId());
@@ -322,9 +365,10 @@
 
          if (isDesktopPage)
          {
-            UserNode newNode = uiWizard.saveData();
+            uiWizard.saveData();
+            PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
             UIPortal uiPortal = Util.getUIPortal();
-            PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, newNode.getURI());
+            PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, selectedNode.getUri());
             uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
             uiWizard.updateUIPortal(event);
             return;
@@ -353,13 +397,16 @@
          }
          uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
          uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
-         UserNode newNode = uiWizard.saveData();
+         uiWizard.saveData();
          UIPortalToolPanel toolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
          toolPanel.setUIComponent(null);
          uiWizard.updateUIPortal(event);
+         UIWizardPageSetInfo uiPageInfo = uiWizard.getChild(UIWizardPageSetInfo.class);
+         UIPageNodeSelector uiNodeSelector = uiPageInfo.getChild(UIPageNodeSelector.class);
+         PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
          
          PortalRequestContext pcontext = Util.getPortalRequestContext();
-         String uri = pcontext.getPortalURI() + newNode.getURI();
+         String uri = pcontext.getPortalURI() + selectedNode.getUri();
          pcontext.getResponse().sendRedirect(uri);
       }
    }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -24,10 +24,12 @@
 import org.exoplatform.portal.config.UserACL;
 import org.exoplatform.portal.config.model.ModelObject;
 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.mop.Visibility;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.webui.navigation.UINavigationNodeSelector.TreeNodeData;
+import org.exoplatform.portal.webui.navigation.PageNavigationUtils;
+import org.exoplatform.portal.webui.navigation.ParentChildPair;
 import org.exoplatform.portal.webui.portal.UIPortal;
 import org.exoplatform.portal.webui.util.Util;
 import org.exoplatform.portal.webui.workspace.UIPortalApplication;
@@ -37,8 +39,8 @@
 import org.exoplatform.webui.core.UIComponent;
 import org.exoplatform.webui.core.UIPopupWindow;
 import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
 import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.event.EventListener;
 import org.exoplatform.webui.exception.MessageException;
 import org.exoplatform.webui.form.UIFormCheckBoxInput;
 import org.exoplatform.webui.form.UIFormDateTimeInput;
@@ -56,7 +58,6 @@
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
-import java.util.EnumSet;
 import java.util.List;
 
 /**
@@ -65,14 +66,23 @@
 public class UIPageNodeForm extends UIFormTabPane
 {
 
-   private TreeNodeData pageNode_;
+   private PageNode pageNode_;
 
+   private String owner_;
+
+   private String ownerType_;
+
    private Object selectedParent;
+
+   /**
+    * Wrapper of editted PageNode and its parent
+    */
+   private ParentChildPair contextParentChildPair;
    
    /**
     * PageNavigation to which editted PageNode belongs
     */
-   private UserNavigation contextPageNavigation;
+   private PageNavigation contextPageNavigation;
    
    final private static String SHOW_PUBLICATION_DATE = "showPublicationDate";
 
@@ -88,12 +98,12 @@
 
       UIFormInputSet uiSettingSet = new UIFormInputSet("PageNodeSetting");
       UIFormCheckBoxInput<Boolean> uiDateInputCheck =
-         new UIFormCheckBoxInput<Boolean>(SHOW_PUBLICATION_DATE, null, false);
-      UIFormCheckBoxInput<Boolean> uiVisibleCheck = new UIFormCheckBoxInput<Boolean>(VISIBLE, null, true);
+         new UIFormCheckBoxInput<Boolean>(SHOW_PUBLICATION_DATE, SHOW_PUBLICATION_DATE, false);
+      UIFormCheckBoxInput<Boolean> uiVisibleCheck = new UIFormCheckBoxInput<Boolean>(VISIBLE, VISIBLE, true);
       
       uiDateInputCheck.setOnChange("SwitchPublicationDate");
       uiVisibleCheck.setOnChange("SwitchVisible");
-      uiSettingSet.addUIFormInput(new UIFormStringInput("URI", "URI", null).setEditable(false))
+      uiSettingSet.addUIFormInput(new UIFormStringInput("uri", "uri", null).setEditable(false))
       				.addUIFormInput(new UIFormStringInput("name", "name", null).addValidator(MandatoryValidator.class).addValidator(StringLengthValidator.class, 3, 30).addValidator(IdentifierValidator.class))
       				.addUIFormInput(new UIFormStringInput("label", "label", null).addValidator(StringLengthValidator.class, 3, 120))
       				.addUIFormInput(uiVisibleCheck.setChecked(true))
@@ -104,8 +114,8 @@
       addUIFormInput(uiSettingSet);
       setSelectedTab(uiSettingSet.getId());
 
-      UIPageSelector uiPageSelector = createUIComponent(UIPageSelector.class, null, null);
-      uiPageSelector.configure("UIPageSelector", "pageRef");
+      UIPageSelector2 uiPageSelector = createUIComponent(UIPageSelector2.class, null, null);
+      uiPageSelector.configure("UIPageSelector2", "pageReference");
       addUIFormInput(uiPageSelector);
 
       UIFormInputIconSelector uiIconSelector = new UIFormInputIconSelector("Icon", "icon");
@@ -113,12 +123,12 @@
       setActions(new String[]{"Save", "Back"});
    }
 
-   public TreeNodeData getPageNode()
+   public PageNode getPageNode()
    {
       return pageNode_;
    }
 
-   public void setValues(TreeNodeData pageNode) throws Exception
+   public void setValues(PageNode pageNode) throws Exception
    {
       pageNode_ = pageNode;
       if (pageNode == null)
@@ -135,13 +145,12 @@
    public void invokeGetBindingBean(Object bean) throws Exception
    {
       super.invokeGetBindingBean(bean);
-      TreeNodeData pageNode = (TreeNodeData)bean;
-
-      String icon = pageNode.getIcon();
+      PageNode pageNode = (PageNode)bean;
+      String icon = pageNode_.getIcon();
       if (icon == null || icon.length() < 0)
          icon = "Default";
       getChild(UIFormInputIconSelector.class).setSelectedIcon(icon);
-      getUIStringInput("label").setValue(pageNode.getLabel());
+      getUIStringInput("label").setValue(pageNode_.getLabel());
       if(pageNode.getVisibility() == Visibility.SYSTEM)
       {
          UIFormInputSet uiSettingSet = getChildById("PageNodeSetting");
@@ -152,22 +161,20 @@
       }
       else
       {
-         Visibility visibility = pageNode.getVisibility();
-         boolean isVisible = visibility == null || EnumSet.of(Visibility.DISPLAYED, Visibility.TEMPORAL).contains(visibility);
-         getUIFormCheckBoxInput(VISIBLE).setChecked(isVisible);
-         getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).setChecked(Visibility.TEMPORAL.equals(visibility));
-         setShowCheckPublicationDate(isVisible);
+         getUIFormCheckBoxInput(VISIBLE).setChecked(pageNode_.isVisible());
+         getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).setChecked(pageNode.isShowPublicationDate());
+         setShowCheckPublicationDate(pageNode_.isVisible());
          Calendar cal = Calendar.getInstance();
-         if (pageNode.getStartPublicationTime() != -1)
+         if (pageNode.getStartPublicationDate() != null)
          {
-            cal.setTime(new Date(pageNode.getStartPublicationTime()));
+            cal.setTime(pageNode.getStartPublicationDate());
             getUIFormDateTimeInput(START_PUBLICATION_DATE).setCalendar(cal);
          }
          else
             getUIFormDateTimeInput(START_PUBLICATION_DATE).setValue(null);
-         if (pageNode.getEndPublicationTime() != -1)
+         if (pageNode.getEndPublicationDate() != null)
          {
-            cal.setTime(new Date(pageNode.getEndPublicationTime()));
+            cal.setTime(pageNode.getEndPublicationDate());
             getUIFormDateTimeInput(END_PUBLICATION_DATE).setCalendar(cal);
          }
          else
@@ -178,46 +185,17 @@
 
    public void invokeSetBindingBean(Object bean) throws Exception
    {
-      UIFormStringInput nameTextBox = getUIStringInput("name");
-      //this help to ignore name textbox
-      nameTextBox.setEditable(false);
       super.invokeSetBindingBean(bean);
-      nameTextBox.setEditable(true);
-      
-      TreeNodeData node = (TreeNodeData) bean;
-
-      Visibility visibility;
-      if (getUIFormCheckBoxInput(VISIBLE).isChecked())
-      {
-         UIFormCheckBoxInput showPubDate = getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE);
-         visibility = showPubDate.isChecked() ?  Visibility.TEMPORAL : Visibility.DISPLAYED;  
-      }
-      else
-      {
-         visibility = Visibility.HIDDEN;
-      }
-      node.setVisibility(visibility);
-
+      PageNode node = (PageNode) bean;
       if (node.getVisibility() != Visibility.SYSTEM)
       {
          Calendar cal = getUIFormDateTimeInput(START_PUBLICATION_DATE).getCalendar();
          Date date = (cal != null) ? cal.getTime() : null;
-         node.setStartPublicationTime(date == null ? -1 : date.getTime());
+         node.setStartPublicationDate(date);
          cal = getUIFormDateTimeInput(END_PUBLICATION_DATE).getCalendar();
          date = (cal != null) ? cal.getTime() : null;
-         node.setEndPublicationTime(date == null ? -1 : date.getTime());
+         node.setEndPublicationDate(date);
       }
-
-      UIPageSelector pageSelector = getChild(UIPageSelector.class);
-      if (pageSelector.getPage() == null)
-         node.setPageRef(null);
-      UIFormInputIconSelector uiIconSelector = getChild(UIFormInputIconSelector.class);
-      if (uiIconSelector.getSelectedIcon().equals("Default"))
-         node.setIcon(null);
-      else
-         node.setIcon(uiIconSelector.getSelectedIcon());
-      if (node.getLabel() == null)
-         node.setLabel(node.getName());
    }
 
    public void setShowCheckPublicationDate(boolean show)
@@ -243,12 +221,22 @@
    {
       this.selectedParent = obj;
    }
+
+   public void setContextParentChildPair(ParentChildPair _contextParentChildPair)
+   {
+      this.contextParentChildPair = _contextParentChildPair;
+   }
    
+   public ParentChildPair getContextParentChildPair()
+   {
+      return this.contextParentChildPair;
+   }
+   
    public void processRender(WebuiRequestContext context) throws Exception
    {
       super.processRender(context);
 
-      UIPageSelector uiPageSelector = getChild(UIPageSelector.class);
+      UIPageSelector2 uiPageSelector = getChild(UIPageSelector2.class);
       if (uiPageSelector == null)
          return;
       UIPopupWindow uiPopupWindowPage = uiPageSelector.getChild(UIPopupWindow.class);
@@ -259,20 +247,20 @@
 
    public String getOwner()
    {
-      return contextPageNavigation.getKey().getName();
+      return contextPageNavigation.getOwnerId();
    }
 
    public String getOwnerType()
    {
-      return contextPageNavigation.getKey().getTypeName();
+      return contextPageNavigation.getOwnerType();
    }
    
-   public void setContextPageNavigation(UserNavigation _contextPageNav)
+   public void setContextPageNavigation(PageNavigation _contextPageNav)
    {
       this.contextPageNavigation = _contextPageNav;
    }
    
-   public UserNavigation getContextPageNavigation()
+   public PageNavigation getContextPageNavigation()
    {
       return this.contextPageNavigation;
    }
@@ -284,10 +272,11 @@
          WebuiRequestContext ctx = event.getRequestContext();
          UIPageNodeForm uiPageNodeForm = event.getSource();
          UIApplication uiPortalApp = ctx.getUIApplication();
-         TreeNodeData pageNode = uiPageNodeForm.getPageNode();
+         PageNode pageNode = uiPageNodeForm.getPageNode();
+         if (pageNode == null)
+            pageNode = new PageNode();
          
-         if (pageNode == null || (pageNode.getVisibility() != Visibility.SYSTEM &&
-            uiPageNodeForm.getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).isChecked()))
+         if (pageNode.getVisibility() != Visibility.SYSTEM && uiPageNodeForm.getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).isChecked())
          {
             Calendar currentCalendar = Calendar.getInstance();
             currentCalendar.set(currentCalendar.get(Calendar.YEAR), currentCalendar.get(Calendar.MONTH), currentCalendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
@@ -323,24 +312,56 @@
             }
             
          }
+         
+         uiPageNodeForm.invokeSetBindingBean(pageNode);
+         UIPageSelector2 pageSelector = uiPageNodeForm.getChild(UIPageSelector2.class);
+         if (pageSelector.getPage() == null)
+            pageNode.setPageReference(null);
+         UIFormInputIconSelector uiIconSelector = uiPageNodeForm.getChild(UIFormInputIconSelector.class);
+         if (uiIconSelector.getSelectedIcon().equals("Default"))
+            pageNode.setIcon(null);
+         else
+            pageNode.setIcon(uiIconSelector.getSelectedIcon());
+         if (pageNode.getLabel() == null)
+            pageNode.setLabel(pageNode.getName());
 
-         UIFormStringInput nameInput = uiPageNodeForm.getUIStringInput("name");
-         String nodeName = nameInput.getValue();
+         Object selectedParent = uiPageNodeForm.getSelectedParent();
+         PageNavigation pageNav = null;
 
-         TreeNodeData selectedParent = (TreeNodeData)uiPageNodeForm.getSelectedParent();
-         if (pageNode == null && selectedParent.getChild(nodeName) != null)
+         if (selectedParent instanceof PageNavigation)
          {
-            uiPortalApp.addMessage(new ApplicationMessage("UIPageNodeForm.msg.SameName", null));
-            return;
+            pageNav = (PageNavigation)selectedParent;
+            pageNode.setUri(pageNode.getName());
+            if (!pageNav.getNodes().contains(pageNode))
+            {
+               if (PageNavigationUtils.searchPageNodeByUri(pageNav, pageNode.getUri()) != null)
+               {
+                  uiPortalApp.addMessage(new ApplicationMessage("UIPageNodeForm.msg.SameName", null));
+                  return;
+               }
+               pageNav.addNode(pageNode);
+            }
          }
-
-         if (pageNode == null)
+         else if (selectedParent instanceof PageNode)
          {
-            pageNode = selectedParent.addChild(nodeName);
+            PageNode parentNode = (PageNode)selectedParent;
+            List<PageNode> children = parentNode.getChildren();
+            if (children == null)
+            {
+               children = new ArrayList<PageNode>();
+               parentNode.setChildren((ArrayList<PageNode>)children);
+            }
+            pageNode.setUri(parentNode.getUri() + "/" + pageNode.getName());
+            if (!children.contains(pageNode))
+            {
+               if (PageNavigationUtils.searchPageNodeByUri(parentNode, pageNode.getUri()) != null)
+               {
+                  uiPortalApp.addMessage(new ApplicationMessage("UIPageNodeForm.msg.SameName", null));
+                  return;
+               }
+               children.add(pageNode);
+            }
          }
-
-         uiPageNodeForm.invokeSetBindingBean(pageNode);
-
          uiPageNodeForm.createEvent("Back", Phase.DECODE, ctx).broadcast();
       }
    }
@@ -382,7 +403,7 @@
       public void execute(Event<UIPageNodeForm> event) throws Exception
       {
          UIPageNodeForm uiForm = event.getSource();
-         UIPageSelector pageSelector = uiForm.findFirstComponentOfType(UIPageSelector.class);
+         UIPageSelector2 pageSelector = uiForm.findFirstComponentOfType(UIPageSelector2.class);
          pageSelector.setPage(null);
          event.getRequestContext().addUIComponentToUpdateByAjax(pageSelector);
       }
@@ -393,7 +414,7 @@
       public void execute(Event<UIPageNodeForm> event) throws Exception
       {
          UIPageNodeForm uiForm = event.getSource();
-         UIPageSelector pageSelector = uiForm.findFirstComponentOfType(UIPageSelector.class);
+         UIPageSelector2 pageSelector = uiForm.findFirstComponentOfType(UIPageSelector2.class);
 
          PortalRequestContext pcontext = Util.getPortalRequestContext();
          UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
@@ -452,7 +473,7 @@
          page.setOwnerType(uiForm.getOwnerType());
          page.setOwnerId(ownerId);
          page.setName(uiPageName.getValue());
-         String title = uiPageTitle.getValue();
+         String title = uiPageTitle.getValue();;
          if (title == null || title.trim().length() < 1)
             title = page.getName();
          page.setTitle(title);

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageSelector.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageSelector.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageSelector.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -30,8 +30,6 @@
 import org.exoplatform.webui.config.annotation.ComponentConfigs;
 import org.exoplatform.webui.config.annotation.EventConfig;
 import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.core.UIPopupWindow;
 import org.exoplatform.webui.core.UIRepeater;
 import org.exoplatform.webui.core.UIVirtualList;
 import org.exoplatform.webui.event.Event;
@@ -39,22 +37,16 @@
 import org.exoplatform.webui.form.UIForm;
 import org.exoplatform.webui.form.UIFormInput;
 import org.exoplatform.webui.form.UIFormInputContainer;
-import org.exoplatform.webui.form.UIFormInputSet;
 import org.exoplatform.webui.form.UIFormPopupWindow;
-import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.validator.IdentifierValidator;
-import org.exoplatform.webui.form.validator.MandatoryValidator;
-import org.exoplatform.webui.form.validator.StringLengthValidator;
-import java.util.List;
 
 /**
- * Author : Dang Van Minh minhdv81 at yahoo.com Jun 14, 2006
+ * Author : Dang Van Minh
+ *          minhdv81 at yahoo.com
+ * Jun 14, 2006
  */
 @ComponentConfigs({
-   @ComponentConfig(template = "system:/groovy/portal/webui/page/UIPageSelector.gtmpl", events = @EventConfig(listeners = UIPageSelector.OpenSelectPagePopUp.class)),
-   @ComponentConfig(id = "SelectPage", type = UIPageBrowser.class, template = "system:/groovy/portal/webui/page/UIPageBrowser.gtmpl", events = @EventConfig(listeners = UIPageSelector.SelectPageActionListener.class)),
-   @ComponentConfig(type = UIFormPopupWindow.class, template = "system:/groovy/webui/core/UIPopupWindow.gtmpl",
-      events = @EventConfig(listeners = UIPageSelector.CloseActionListener.class, name = "CloseFormPopup", phase = Event.Phase.DECODE))})
+   @ComponentConfig(template = "system:/groovy/portal/webui/page/UIPageSelector.gtmpl"),
+   @ComponentConfig(id = "SelectPage", type = UIPageBrowser.class, template = "system:/groovy/portal/webui/page/UIPageBrowser.gtmpl", events = @EventConfig(listeners = UIPageSelector.SelectPageActionListener.class))})
 public class UIPageSelector extends UIFormInputContainer<String>
 {
 
@@ -65,19 +57,15 @@
    public UIPageSelector() throws Exception
    {
       super("UIPageSelector", null);
-      UIFormPopupWindow uiPopup = addChild(UIFormPopupWindow.class, null, "PopupPageSelector2");
+      UIFormPopupWindow uiPopup = addChild(UIFormPopupWindow.class, null, "PopupPageSelector");
       uiPopup.setWindowSize(900, 400);
-      uiPopup.setShow(false);
-
-      UIFormInputSet uiInputSet = new UIFormInputSet("PageNodeSetting");
-
-      uiInputSet.addChild(new UIFormStringInput("pageId", "pageId", null));
-      uiInputSet.addChild(new UIFormStringInput("pageName", "pageName", null).addValidator(StringLengthValidator.class,
-         3, 30).addValidator(IdentifierValidator.class).addValidator(MandatoryValidator.class));
-      uiInputSet.addChild(new UIFormStringInput("pageTitle", "pageTitle", null).addValidator(
-         StringLengthValidator.class, 3, 120));
-
-      addChild(uiInputSet);
+      uiPopup.setRendered(false);
+      UIPageBrowser uiPageBrowser = createUIComponent(UIPageBrowser.class, "SelectPage", null);
+      uiPopup.setUIComponent(uiPageBrowser);
+      //UIGrid uiGrid = uiPageBrowser.getChild(UIGrid.class);
+      //uiGrid.configure("pageId", UIPageBrowser.BEAN_FIELD, new String[]{"SelectPage"});
+      UIVirtualList uiVirtualList = uiPageBrowser.getChild(UIVirtualList.class);
+      configureVirtualList(uiVirtualList);
    }
 
    private static void configureVirtualList(UIVirtualList vList)
@@ -130,56 +118,9 @@
    {
       super.processDecode(context);
       UIPageBrowser uiPageBrowser = findFirstComponentOfType(UIPageBrowser.class);
-      if (uiPageBrowser != null)
-      {
-         uiPageBrowser.processDecode(context);
-      }
-      
-      UIFormInputSet uiInputSet = getChild(UIFormInputSet.class);
-
-      List<UIComponent> children = uiInputSet.getChildren();
-      for (UIComponent ele : children)
-      {
-         ele.processDecode(context);
-      }
-      //    UIFormStringInput uiPageId = getChildById("pageId");
-      //    uiPageId.processDecode(context);
-      //
-      //    UIFormStringInput uiPageName = getChildById("pageName");
-      //    uiPageName.processDecode(context);
-      //
-      //    UIFormStringInput uiPageTitle = getChildById("pageTitle");
-      //    uiPageTitle.processDecode(context);
+      uiPageBrowser.processDecode(context);
    }
 
-   static public class OpenSelectPagePopUp extends EventListener<UIPageSelector>
-   {
-      @Override
-      public void execute(Event<UIPageSelector> event) throws Exception
-      {
-         UIPageSelector pageSelector = event.getSource();
-         UIFormPopupWindow uiPopup = pageSelector.getChild(UIFormPopupWindow.class);
-
-         UIPageBrowser uiPageBrowser = pageSelector.createUIComponent(UIPageBrowser.class, "SelectPage", null);
-         uiPopup.setUIComponent(uiPageBrowser);
-         uiPopup.setShow(true);
-
-         UIVirtualList uiVirtualList = uiPageBrowser.getChild(UIVirtualList.class);
-         configureVirtualList(uiVirtualList);
-      }
-   }
-
-   static public class CloseActionListener extends UIFormPopupWindow.CloseActionListener
-   {
-      @Override
-      public void execute(Event<UIPopupWindow> event) throws Exception
-      {
-         UIPopupWindow popWindow = event.getSource();
-         popWindow.setUIComponent(null);
-         super.execute(event);
-      }
-   }
-
    static public class SelectPageActionListener extends EventListener<UIPageBrowser>
    {
       public void execute(Event<UIPageBrowser> event) throws Exception
@@ -196,7 +137,7 @@
             uiApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.NoPermission", new String[]{id}));;
          }
          uiPageSelector.setValue(id);
-//         uiPageBrowser.feedDataWithQuery(null);
+         uiPageBrowser.feedDataWithQuery(null);
 
          UIForm uiForm = uiPageSelector.getAncestorOfType(UIForm.class);
          if (uiForm != null)
@@ -208,7 +149,6 @@
             ctx.addUIComponentToUpdateByAjax(uiPageSelector.getParent());
          }
          UIFormPopupWindow uiPopup = uiPageSelector.getChild(UIFormPopupWindow.class);
-         uiPopup.setUIComponent(null);
          uiPopup.setShow(false);
       }
    }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -19,18 +19,27 @@
 
 package org.exoplatform.portal.webui.page;
 
-import org.exoplatform.portal.mop.Visibility;
-import org.exoplatform.portal.mop.user.UserNode;
+import org.exoplatform.portal.config.UserPortalConfigService;
+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.navigation.UIPageNodeSelector;
+import org.exoplatform.portal.webui.portal.UIPortal;
+import org.exoplatform.portal.webui.util.Util;
 import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+import org.exoplatform.web.application.ApplicationMessage;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.ComponentConfigs;
 import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.core.UITree;
 import org.exoplatform.webui.core.UIWizard;
 import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
 import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
 import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.event.EventListener;
 import org.exoplatform.webui.form.UIForm;
 import org.exoplatform.webui.form.UIFormCheckBoxInput;
 import org.exoplatform.webui.form.UIFormDateTimeInput;
@@ -41,6 +50,7 @@
 import org.exoplatform.webui.form.validator.StringLengthValidator;
 
 import java.util.Calendar;
+import java.util.Date;
 
 /**
  * Created by The eXo Platform SARL
@@ -48,10 +58,10 @@
  *          hoa.nguyen at exoplatform.com
  * Oct 31, 2006  
  */
- at ComponentConfig(lifecycle = UIFormLifecycle.class, template = "system:/groovy/portal/webui/page/UIWizardPageSetInfo.gtmpl", events = {
+ at ComponentConfigs({@ComponentConfig(lifecycle = UIFormLifecycle.class, template = "system:/groovy/portal/webui/page/UIWizardPageSetInfo.gtmpl", events = {
    @EventConfig(listeners = UIWizardPageSetInfo.ChangeNodeActionListener.class, phase = Phase.DECODE),
    @EventConfig(listeners = UIWizardPageSetInfo.SwitchVisibleActionListener.class, phase = Phase.DECODE),
-   @EventConfig(listeners = UIWizardPageSetInfo.SwitchPublicationDateActionListener.class, phase = Phase.DECODE)})
+   @EventConfig(listeners = UIWizardPageSetInfo.SwitchPublicationDateActionListener.class, phase = Phase.DECODE)})})
 public class UIWizardPageSetInfo extends UIForm
 {
 
@@ -73,24 +83,23 @@
 
    public UIWizardPageSetInfo() throws Exception
    {
-      UIFormCheckBoxInput<Boolean> uiDateInputCheck =
-         new UIFormCheckBoxInput<Boolean>(SHOW_PUBLICATION_DATE, null, false);
-      UIFormCheckBoxInput<Boolean> uiVisibleCheck = new UIFormCheckBoxInput<Boolean>(VISIBLE, null, false);
-      uiDateInputCheck.setOnChange("SwitchPublicationDate");
-      uiVisibleCheck.setOnChange("SwitchVisible");
-
+   	UIFormCheckBoxInput<Boolean> uiDateInputCheck =
+         new UIFormCheckBoxInput<Boolean>(SHOW_PUBLICATION_DATE, SHOW_PUBLICATION_DATE, false);
+   	UIFormCheckBoxInput<Boolean> uiVisibleCheck = new UIFormCheckBoxInput<Boolean>(VISIBLE, VISIBLE, false);
+   	uiDateInputCheck.setOnChange("SwitchPublicationDate");
+   	uiVisibleCheck.setOnChange("SwitchVisible");
+   	
       addChild(UIPageNodeSelector.class, null, null);
       addUIFormInput(new UIFormStringInput(PAGE_NAME, "name", null).addValidator(MandatoryValidator.class)
-         .addValidator(StringLengthValidator.class, 3, 30).addValidator(IdentifierValidator.class));
-      addUIFormInput(new UIFormStringInput(PAGE_DISPLAY_NAME, "label", null).setMaxLength(255).addValidator(
-         StringLengthValidator.class, 3, 120));
+                     .addValidator(StringLengthValidator.class, 3, 30).addValidator(IdentifierValidator.class));
+      addUIFormInput(new UIFormStringInput(PAGE_DISPLAY_NAME, "label", null)
+      		.setMaxLength(255).addValidator(StringLengthValidator.class, 3, 120));
       addUIFormInput(uiVisibleCheck.setChecked(true));
       addUIFormInput(uiDateInputCheck);
       addUIFormInput(new UIFormDateTimeInput(START_PUBLICATION_DATE, null, null).addValidator(DateTimeValidator.class));
       addUIFormInput(new UIFormDateTimeInput(END_PUBLICATION_DATE, null, null).addValidator(DateTimeValidator.class));
    }
 
-   //TODO: it looks like this method is not used
    public void setEditMode() throws Exception
    {
       isEditMode = true;
@@ -106,37 +115,55 @@
    public void invokeSetBindingBean(Object bean) throws Exception
    {
       super.invokeSetBindingBean(bean);
-      UserNode node = (UserNode)bean;
-      
-      Visibility visibility;
-      if (getUIFormCheckBoxInput(VISIBLE).isChecked())
+      PageNode node = (PageNode)bean;
+      if(!getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).isChecked())
       {
-         UIFormCheckBoxInput showPubDate = getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE);
-         visibility = showPubDate.isChecked() ?  Visibility.TEMPORAL : Visibility.DISPLAYED;
+      	node.setVisible(getUIFormCheckBoxInput(VISIBLE).isChecked());	
       }
-      else
-      {
-         visibility = Visibility.HIDDEN;
-      }
-      node.setVisibility(visibility);
-
       Calendar cal = getUIFormDateTimeInput(START_PUBLICATION_DATE).getCalendar();
-      long time = (cal != null) ? cal.getTimeInMillis() : -1;
-      node.setStartPublicationTime(time);
+      Date date = (cal != null) ? cal.getTime() : null;
+      node.setStartPublicationDate(date);
       cal = getUIFormDateTimeInput(END_PUBLICATION_DATE).getCalendar();
-      time = (cal != null) ? cal.getTimeInMillis() : -1;
-      node.setEndPublicationTime(time);
+      date = (cal != null) ? cal.getTime() : null;
+      node.setEndPublicationDate(date);
    }
 
-   public UserNode createUserNode(UserNode parent) throws Exception
+   public PageNode getPageNode() throws Exception
    {
-      UserNode child = parent.addChild("temp");
-      invokeSetBindingBean(child);
-      if (child.getLabel() == null || child.getLabel().trim().length() == 0)
+      if (isEditMode)
       {
-         child.setLabel(child.getName());
+         PageNode pageNode = getSelectedPageNode();
+         PageNode clonedNode = (pageNode != null) ? pageNode.clone() : null;
+         invokeSetBindingBean(clonedNode);
+         if (clonedNode.getLabel() == null || clonedNode.getLabel().trim().length() == 0)
+         {
+            clonedNode.setLabel(clonedNode.getName());
+         }
+         return clonedNode;
       }
-      return child;
+
+      PageNode pageNode = new PageNode();
+      invokeSetBindingBean(pageNode);
+      if (pageNode.getLabel() == null || pageNode.getLabel().trim().length() == 0)
+      {
+         pageNode.setLabel(pageNode.getName());
+      }
+
+      UIPageNodeSelector uiNodeSelector = getChild(UIPageNodeSelector.class);
+      PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
+      PageNavigation nav = uiNodeSelector.getSelectedNavigation();
+      if(nav.getOwnerType().equals(PortalConfig.USER_TYPE))
+         pageNode.setUri(pageNode.getName());
+      else
+      {
+         if (selectedNode != null)
+         {
+            pageNode.setUri(selectedNode.getUri() + "/" + pageNode.getName());
+         }
+         else
+            pageNode.setUri(pageNode.getName());
+      }
+      return pageNode;
    }
 
    public void setShowCheckPublicationDate(boolean show)
@@ -146,26 +173,63 @@
       uiForm.setRendered(show);
       setShowPublicationDate(show && uiForm.isChecked());
    }
-
+   
    public void setShowPublicationDate(boolean show)
    {
       getUIFormDateTimeInput(START_PUBLICATION_DATE).setRendered(show);
       getUIFormDateTimeInput(END_PUBLICATION_DATE).setRendered(show);
    }
 
-   public UserNode getSelectedPageNode()
+   public void setPageNode(PageNode pageNode) throws Exception
    {
+      if (pageNode.getName() != null)
+         getUIStringInput(PAGE_NAME).setValue(pageNode.getName());
+      if (pageNode.getLabel() != null)
+         getUIStringInput(PAGE_DISPLAY_NAME).setValue(pageNode.getLabel());
+      getUIFormCheckBoxInput(VISIBLE).setChecked(pageNode.isVisible());
+      setShowPublicationDate(pageNode.isShowPublicationDate());
+      Calendar cal = Calendar.getInstance();
+      if (pageNode.getStartPublicationDate() != null)
+      {
+         cal.setTime(pageNode.getStartPublicationDate());
+         getUIFormDateTimeInput(START_PUBLICATION_DATE).setCalendar(cal);
+      }
+      else
+         getUIFormDateTimeInput(START_PUBLICATION_DATE).setValue(null);
+      if (pageNode.getEndPublicationDate() != null)
+      {
+         cal.setTime(pageNode.getEndPublicationDate());
+         getUIFormDateTimeInput(END_PUBLICATION_DATE).setCalendar(cal);
+      }
+      else
+         getUIFormDateTimeInput(END_PUBLICATION_DATE).setValue(null);
+   }
+
+   public PageNode getSelectedPageNode()
+   {
       UIPageNodeSelector uiPageNodeSelector = getChild(UIPageNodeSelector.class);
-      return uiPageNodeSelector.getSelectedNode();
+      PageNavigation nav = uiPageNodeSelector.getSelectedNavigation();
+      if(nav.getOwnerType().equals(PortalConfig.USER_TYPE))
+         return null;
+      return uiPageNodeSelector.getSelectedPageNode();
    }
 
    public void processRender(WebuiRequestContext context) throws Exception
    {
-      if (isEditMode && getChild(UIPageNodeSelector.class).getSelectedNode() == null)
+      if (isEditMode && getChild(UIPageNodeSelector.class).getSelectedPageNode() == null)
          reset();
       super.processRender(context);
    }
 
+   public void processDecode(WebuiRequestContext context) throws Exception
+   {
+      super.processDecode(context);
+      String action = context.getRequestParameter(UIForm.ACTION);
+      Event<UIComponent> event = createEvent(action, Event.Phase.DECODE, context);
+      if (event != null)
+         event.broadcast();
+   }
+
    public boolean isFirstTime()
    {
       return firstTime;
@@ -181,13 +245,61 @@
       public void execute(Event<UIWizardPageSetInfo> event) throws Exception
       {
          String uri = event.getRequestContext().getRequestParameter(OBJECTID);
+         UIWizardPageSetInfo uiForm = event.getSource();
 
          UIPageNodeSelector uiPageNodeSelector = event.getSource().getChild(UIPageNodeSelector.class);
-         uiPageNodeSelector.setSelectedURI(uri);
+         UITree tree = uiPageNodeSelector.getChild(UITree.class);
 
+         if (tree.getParentSelected() == null && (uri == null || uri.length() < 1))
+         {
+            uiPageNodeSelector.selectNavigation(uiPageNodeSelector.getSelectedNavigation());
+         }
+         else
+         {
+            uiPageNodeSelector.selectPageNodeByUri(uri);
+         }
+
          UIPortalApplication uiPortalApp = uiPageNodeSelector.getAncestorOfType(UIPortalApplication.class);
          UIWizard uiWizard = uiPortalApp.findFirstComponentOfType(UIWizard.class);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiWizard);
+
+         if (!event.getSource().isEditMode())
+         {
+            return;
+         }
+         PageNode pageNode = uiPageNodeSelector.getSelectedPageNode();
+
+         if (pageNode == null && uiForm.isFirstTime())
+         {
+            uiForm.setShowPublicationDate(false);
+            uiForm.setFirstTime(false);
+            UIPortal uiPortal = Util.getUIPortal();
+            uiPageNodeSelector.selectNavigation(uiPortal.getSelectedNavigation());
+            if (uiPortal.getSelectedNode() != null)
+            {
+               uiPageNodeSelector.selectPageNodeByUri(uiPortal.getSelectedNode().getUri());
+            }
+            pageNode = uiPageNodeSelector.getSelectedPageNode();
+         }
+
+         if (pageNode == null)
+         {
+            uiForm.setShowPublicationDate(false);
+            return;
+         }
+         UserPortalConfigService configService = uiWizard.getApplicationComponent(UserPortalConfigService.class);
+         String accessUser = event.getRequestContext().getRemoteUser();
+         Page page = null;
+         if (pageNode.getPageReference() != null)
+            page = configService.getPage(pageNode.getPageReference(), accessUser);
+         if (page == null)
+         {
+            uiPortalApp.addMessage(new ApplicationMessage("UIWizardPageSetInfo.msg.null", null));
+            uiForm.reset();
+            uiForm.setShowPublicationDate(false);
+            return;
+         }
+         uiForm.setPageNode(pageNode);
       }
    }
 
@@ -204,17 +316,17 @@
       }
 
    }
-
+   
    static public class SwitchVisibleActionListener extends EventListener<UIWizardPageSetInfo>
    {
-      @Override
-      public void execute(Event<UIWizardPageSetInfo> event) throws Exception
-      {
-         UIWizardPageSetInfo uiForm = event.getSource();
-         boolean isCheck = uiForm.getUIFormCheckBoxInput(VISIBLE).isChecked();
-         uiForm.setShowCheckPublicationDate(isCheck);
-         event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
-      }
+		@Override
+		public void execute(Event<UIWizardPageSetInfo> event) throws Exception
+		{
+			UIWizardPageSetInfo uiForm = event.getSource();
+			boolean isCheck = uiForm.getUIFormCheckBoxInput(VISIBLE).isChecked();
+			uiForm.setShowCheckPublicationDate(isCheck);
+			event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
+		}
    }
 
 }

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -178,6 +178,8 @@
             localeConfig = localeConfigService.getDefaultLocaleConfig();
          PortalRequestContext prqCtx = PortalRequestContext.getCurrentInstance();
          prqCtx.setLocale(localeConfig.getLocale());
+         //uiApp.setOrientation(localeConfig.getOrientation());
+         //uiApp.localizeNavigations();
       }
    }
 

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -21,17 +21,16 @@
 
 import org.exoplatform.portal.account.UIAccountSetting;
 import org.exoplatform.portal.application.PortalRequestContext;
+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.PortalProperties;
 import org.exoplatform.portal.config.model.Properties;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.user.NavigationPath;
-import org.exoplatform.portal.mop.user.UserNavigation;
-import org.exoplatform.portal.mop.user.UserNode;
 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.page.UIPageBody;
 import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeApplicationListActionListener;
 import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeLanguageActionListener;
 import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeSkinActionListener;
@@ -44,7 +43,7 @@
 import org.exoplatform.portal.webui.workspace.UIPortalApplication;
 import org.exoplatform.services.organization.OrganizationService;
 import org.exoplatform.services.organization.User;
-import org.exoplatform.web.application.JavascriptManager;
+import org.exoplatform.services.resources.ResourceBundleManager;
 import org.exoplatform.web.login.InitiateLoginServlet;
 import org.exoplatform.web.security.security.AbstractTokenService;
 import org.exoplatform.web.security.security.CookieTokenService;
@@ -54,10 +53,15 @@
 import org.exoplatform.webui.core.UIComponent;
 import org.exoplatform.webui.event.Event;
 import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.web.application.JavascriptManager;
 
 import java.net.URLEncoder;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
 import java.util.Map;
+import java.util.ResourceBundle;
 
 import javax.portlet.WindowState;
 import javax.servlet.http.Cookie;
@@ -91,19 +95,18 @@
 
    private Properties properties;
 
-   private NavigationPath navPath;
+   private PageNavigation navigation;
+   
+   private List<PageNode> selectedPath;
 
+   private PageNode selectedNode_;
+   
    private Map<String, UIPage> all_UIPages;
    
    private Map<String, String[]> publicParameters_ = new HashMap<String, String[]>();
 
    private UIComponent maximizedUIComponent;
 
-   public SiteKey getSiteKey()
-   {
-      return new SiteKey(ownerType, name_);
-   }
-   
    public String getOwner()
    {
       return owner;
@@ -163,20 +166,13 @@
    {
       publicParameters_ = publicParams;
    }
-
-   public NavigationPath getNavPath() throws Exception
-   {
-      if (navPath == null)
-      {
-         UIPortalApplication uiApp = Util.getUIPortalApplication();
-         navPath = uiApp.getUserPortalConfig().getUserPortal().getDefaultPath(); 
-      }
-      return navPath;
-   }
    
-   public void setNavPath(NavigationPath nav)
+   /** At the moment, this method ensure compatibility with legacy code */
+   public List<PageNavigation> getNavigations() throws Exception
    {
-      this.navPath = nav;
+      List<PageNavigation> listNavs = new ArrayList<PageNavigation>();
+      listNavs.add(navigation);
+      return listNavs;
    }
    
    /**
@@ -210,11 +206,9 @@
          this.all_UIPages.remove(pageReference);
    }
    
-   public UserNavigation getUserNavigation() throws Exception
+   public void setNavigation(PageNavigation _navigation)
    {
-      UIPortalApplication uiPortalApp = getAncestorOfType(UIPortalApplication.class);
-      SiteKey siteKey = new SiteKey(ownerType, owner);
-      return uiPortalApp.getUserPortalConfig().getUserPortal().getNavigation(siteKey);
+      this.navigation = _navigation;
    }
    
    /**
@@ -224,6 +218,11 @@
     */
    public void refreshUIPage() throws Exception
    {
+      if(selectedNode_ == null)
+      {
+         selectedNode_ = navigation.getNodes().get(0);
+      }
+      
       UIPageBody uiPageBody = findFirstComponentOfType(UIPageBody.class);
       if(uiPageBody == null)
       {
@@ -236,14 +235,84 @@
          currentPortlet.setCurrentWindowState(WindowState.NORMAL);
          uiPageBody.setMaximizedUIComponent(null);
       }
-      uiPageBody.setPageBody(getSelectedUserNode(), this);
+      uiPageBody.setPageBody(selectedNode_, this);
+      
+      //Refresh locale
+      Locale locale = Util.getPortalRequestContext().getLocale();
+      localizePageNavigation(navigation, locale);
    }
    
-   public UserNode getSelectedUserNode() throws Exception
+   public synchronized void setSelectedNode(PageNode node)
    {
-      return getNavPath().getTarget();
+      selectedNode_ = node;
    }
 
+   /*
+   public PageNode getSelectedNode() throws Exception
+   {
+      if (selectedNode_ != null)
+         return selectedNode_;
+      if (getSelectedNavigation() == null || selectedNavigation_.getNodes() == null
+         || selectedNavigation_.getNodes().size() < 1)
+         return null;
+      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> getSelectedPath()
+   {
+      return selectedPath;
+   }
+
+   public void setSelectedPath(List<PageNode> nodes)
+   {
+      selectedPath = nodes;
+   }
+   
+   public PageNavigation getSelectedNavigation() throws Exception
+   {
+      return navigation;
+   }
+   
+   public void setSelectedNavigation(PageNavigation _navigation)
+   {
+      this.navigation = _navigation;
+   }
+
+   /**
+   public PageNavigation getPageNavigation(int id)
+   {
+      for (PageNavigation nav : navigations)
+      {
+         if (nav.getId() == id)
+            return nav;
+      }
+      return null;
+   }
+
+*/
+   /*
+   public void setSelectedNavigation(PageNavigation selectedNavigation)
+   {
+      selectedNavigation_ = selectedNavigation;
+   }
+
+   */
+   
    public UIComponent getMaximizedUIComponent()
    {
       return maximizedUIComponent;
@@ -308,6 +377,30 @@
       setProperty(PortalProperties.SESSION_ALIVE, type);
    }
    
+   private void localizePageNavigation(PageNavigation nav,Locale locale)
+   {
+      ResourceBundleManager mgr = getApplicationComponent(ResourceBundleManager.class);
+      if (nav.getOwnerType().equals(PortalConfig.USER_TYPE))
+         return;
+      String localeLanguage = (locale.getCountry().length() > 0) ? locale.getLanguage() + "_" + locale.getCountry() : locale.getLanguage();
+      ResourceBundle res = mgr.getNavigationResourceBundle(localeLanguage, nav.getOwnerType(), nav.getOwnerId());
+      for (PageNode node : nav.getNodes())
+      {
+         resolveLabel(res, node);
+      }
+   }
+
+   private void resolveLabel(ResourceBundle res, PageNode node)
+   {
+      node.setResolvedLabel(res);
+      if (node.getChildren() == null)
+         return;
+      for (PageNode childNode : node.getChildren())
+      {
+         resolveLabel(res, childNode);
+      }
+   }
+
    static public class LogoutActionListener extends EventListener<UIComponent>
    {
       public void execute(Event<UIComponent> event) throws Exception

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -56,8 +56,8 @@
 import org.exoplatform.webui.core.UITabPane;
 import org.exoplatform.webui.core.UIWizard;
 import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.Event.Phase;
 import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.event.Event.Phase;
 
 import java.util.List;
 import java.util.ResourceBundle;
@@ -414,7 +414,7 @@
          UIPortal uiPortal = uiWorkingWS.getBackupUIPortal();
          siteBody.setUIComponent(uiPortal);
 
-         String uri = uiPortal.getSelectedUserNode() != null ? uiPortal.getSelectedUserNode().getURI() : null;
+         String uri = uiPortal.getSelectedNode() != null ? uiPortal.getSelectedNode().getUri() : null;
          PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
          uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
          prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
@@ -461,13 +461,14 @@
          uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
          prContext.setFullRender(true);
 
-         String uri = (uiPortal.getSelectedUserNode() != null)? (uiPortal.getSelectedUserNode().getURI()) : null;
+         String uri = (uiPortal.getSelectedNode() != null)? (uiPortal.getSelectedNode().getUri()) : null;
         
          if (uiComposer.isPortalExist(editPortal))
          {
             DataStorage storage = uiPortalApp.getApplicationComponent(DataStorage.class);
             PortalConfig pConfig =
-               storage.getPortalConfig(uiPortal.getSiteKey().getTypeName(), uiPortal.getSiteKey().getName());
+               storage.getPortalConfig(uiPortal.getSelectedNavigation().getOwnerType(), uiPortal
+                  .getSelectedNavigation().getOwnerId());
             if (pConfig != null)
             {
                uiPortalApp.getUserPortalConfig().setPortal(pConfig);
@@ -654,8 +655,7 @@
          UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
          uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
          uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
-         PortalRequestContext prContext = Util.getPortalRequestContext();
-         prContext.setFullRender(true);
+         Util.getPortalRequestContext().setFullRender(true);
 
          UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
          uiPortal.setRenderSibling(UIPortal.class);
@@ -665,10 +665,9 @@
          uiPortal.refreshUIPage();
          
          PageNodeEvent<UIPortal> pnevent =
-            new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, (uiPortal.getSelectedUserNode() != null
-               ? uiPortal.getSelectedUserNode().getURI() : null));
+            new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, (uiPortal.getSelectedNode() != null
+               ? uiPortal.getSelectedNode().getUri() : null));
          uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
-         prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
          JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
          jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
       }
@@ -689,8 +688,7 @@
          UIEditInlineWorkspace editInlineWS = event.getSource().getParent();
          UIWorkingWorkspace uiWorkingWS = editInlineWS.getParent();
          UIPortalToolPanel uiToolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
-         Util.getPortalRequestContext().addUIComponentToUpdateByAjax(uiWorkingWS);
-         
+
          UIPage uiPage = uiToolPanel.findFirstComponentOfType(UIPage.class);
          Page page = (Page)PortalDataMapper.buildModelObject(uiPage);
          String pageId = page.getPageId();
@@ -709,7 +707,7 @@
             Util.getPortalRequestContext().setFullRender(true);
             PageNodeEvent<UIPortal> pnevent =
                new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE,
-                  (uiPortal.getSelectedUserNode() != null ? uiPortal.getSelectedUserNode().getURI() : null));
+                  (uiPortal.getSelectedNode() != null ? uiPortal.getSelectedNode().getUri() : null));
             uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
             JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
             jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
@@ -765,8 +763,8 @@
          uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
          Util.getPortalRequestContext().setFullRender(true);
          PageNodeEvent<UIPortal> pnevent =
-            new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, (uiPortal.getSelectedUserNode() != null
-               ? uiPortal.getSelectedUserNode().getURI() : null));
+            new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, (uiPortal.getSelectedNode() != null
+               ? uiPortal.getSelectedNode().getUri() : null));
          uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
          JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
          jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -315,7 +315,7 @@
             {
                PortalConfig portalConfig = (PortalConfig)PortalDataMapper.buildModelObject(uiPortal);
                dataService.save(portalConfig);
-               prContext.setAttribute(UserPortalConfig.class, service.getUserPortalConfig(uiForm.getPortalOwner(), prContext.getRemoteUser(), PortalRequestContext.USER_PORTAL_CONTEXT));
+               prContext.setAttribute(UserPortalConfig.class, service.getUserPortalConfig(uiForm.getPortalOwner(), prContext.getRemoteUser()));
                uiPortalApp.reloadSkinPortal(prContext);
             }
             else
@@ -363,7 +363,9 @@
          UserPortalConfig userPortalConfig = service.getUserPortalConfig(portalName, pcontext.getRemoteUser());
          PortalConfig pconfig = userPortalConfig.getPortalConfig();
          uiForm.invokeSetBindingBean(pconfig);
+         PageNavigation navigation = dataService.getPageNavigation(PortalConfig.PORTAL_TYPE, portalName);
          dataService.save(pconfig);
+         dataService.save(navigation);
          UIPortalApplication uiPortalApp = event.getSource().getAncestorOfType(UIPortalApplication.class);
          UIMaskWorkspace uiMaskWS = uiPortalApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
          uiMaskWS.setUIComponent(null);

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -361,7 +361,7 @@
          }
       }
       //uiPortal.setNavigation(userPortalConfig.getNavigations());
-//      uiPortal.setNavigation(userPortalConfig.getSelectedNavigation());
+      uiPortal.setNavigation(userPortalConfig.getSelectedNavigation());
    }
 
    private static void buildUIContainer(UIContainer uiContainer, Object model, boolean dashboard) throws Exception

Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java	2011-03-16 20:42:18 UTC (rev 6046)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java	2011-03-16 20:49:35 UTC (rev 6047)
@@ -213,24 +213,10 @@
       }
    }
 
-   /**
-    * @deprecated use {@link #toUIPage(String, UIComponent)} instead
-    * 
-    * @param node
-    * @param uiParent
-    * @return
-    * @throws Exception
-    */
-   @Deprecated
    static public UIPage toUIPage(PageNode node, UIComponent uiParent) throws Exception
    {
-      return toUIPage(node.getPageReference(), uiParent);
-   }
-   
-   static public UIPage toUIPage(String pageRef, UIComponent uiParent) throws Exception
-   {
       UserPortalConfigService configService = uiParent.getApplicationComponent(UserPortalConfigService.class);
-      Page page = configService.getPage(pageRef, getPortalRequestContext().getRemoteUser());
+      Page page = configService.getPage(node.getPageReference(), getPortalRequestContext().getRemoteUser());
       return toUIPage(page, uiParent);
    }
 



More information about the gatein-commits mailing list