[gatein-commits] gatein SVN: r3202 - in portal/trunk: web/portal/src/main/webapp/groovy/portal/webui/portal and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed May 26 07:24:51 EDT 2010


Author: trong.tran
Date: 2010-05-26 07:24:50 -0400 (Wed, 26 May 2010)
New Revision: 3202

Added:
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIContainerList.java
Removed:
   portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIChangePortal.gtmpl
   portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalSelector.gtmpl
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIApplicationList.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerList.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalSelector.java
Modified:
   portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardSelectContainer.java
   portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposerContent.gtmpl
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIEditInlineWorkspace.java
Log:
Fix wrong usage of org.exoplatform.portal.webui.container.UIContainer
Clean up and remove useless code

Modified: portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardSelectContainer.java
===================================================================
--- portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardSelectContainer.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardSelectContainer.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -23,9 +23,9 @@
 import org.exoplatform.application.registry.ApplicationCategory;
 import org.exoplatform.application.registry.ApplicationRegistryService;
 import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.webui.container.UIContainer;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.core.UIContainer;
 import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
 
 import java.util.Collections;

Deleted: portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIChangePortal.gtmpl
===================================================================
--- portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIChangePortal.gtmpl	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIChangePortal.gtmpl	2010-05-26 11:24:50 UTC (rev 3202)
@@ -1,46 +0,0 @@
-<div class="UIChagnePortalForm" id="<%=uicomponent.getId();%>">
-	<div class="UIFormTabPane">
-		<div class="UITabPane">
-			<div class="UIBarStyle">
-				<div class="TitleBar">
-					<div class="LeftBar">
-						<div class="RightBar">
-							<div class="MiddleBar"><%=_ctx.appRes("UIChangePortal.lable.TitleBar")%></div>
-						</div>
-					</div>
-				</div>
-			</div>
-				
-			<div class="TabPaneContent">
-				<div class="WorkingArea">
-					<div class="HorizontalLayout">
-						<div class="UITabContentContainer">
-							<div class="UITabContent">	 
-								<%uicomponent.renderChildren() %>	
-							</div>
-						</div>
-					</div>
-				</div>
-			</div>
-				
-			<div class="UIAction"> 
-				<table class="ActionContainer">
-					<tr>
-						<td>
-							<div onclick="<%=uicomponent.event("Close")%>" class="ActionButton LightBlueStyle">
-								<div class="ButtonLeft">
-									<div class="ButtonRight">
-										<div class="ButtonMiddle">
-											<a href="javascript:void(0);"><%=_ctx.appRes("UIChangePortal.action.close")%></a>
-										</div>
-									</div>
-								</div>
-							</div>
-						</td>
-					</tr>
-		 		</table>
-			</div>
-		</div>
-	</div>
-	
-</div>
\ No newline at end of file

Modified: portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposerContent.gtmpl
===================================================================
--- portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposerContent.gtmpl	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposerContent.gtmpl	2010-05-26 11:24:50 UTC (rev 3202)
@@ -1,6 +1,6 @@
 <%	
-	import org.exoplatform.portal.webui.application.UIApplicationList;
-	import org.exoplatform.portal.webui.container.UIContainerList;
+	import org.exoplatform.portal.webui.portal.UIApplicationList;
+	import org.exoplatform.portal.webui.portal.UIContainerList;
 	
 	def rcontext = _ctx.getRequestContext(); 
 	rcontext.getJavascriptManager().importJavascript('eXo.webui.UIHorizontalTabs');

Deleted: portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalSelector.gtmpl
===================================================================
--- portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalSelector.gtmpl	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalSelector.gtmpl	2010-05-26 11:24:50 UTC (rev 3202)
@@ -1,87 +0,0 @@
-<%
-	import org.exoplatform.webui.core.UIComponent; 
-	import org.exoplatform.webui.form.UIForm;
-
-	String[] beanFields =	uicomponent.getBeanFields(); 	
-	String[] beanActions =	uicomponent.getBeanActions(); 
-	UIComponent uiParent = uicomponent.getParent(); 
-	String name = uicomponent.getLabel(); 
-	
-	def rcontext = _ctx.getRequestContext();  
-	rcontext.getJavascriptManager().importJavascript('eXo.portal.UIPortal'); 
-%>
-<div id="$uicomponent.id">
-<table class="UIGrid" cellspacing="0" borderspacing="0">
-	<thead>
-		<tr>
-			<%if(name != null) {%>
-				<%for(field in beanFields) { %>
-					<th><%=_ctx.appRes(name+".header."+field)%></th>
-				<%}%>
-				<%if(beanActions != null) { %>
-					<th><%=_ctx.appRes(name+".header.action")%></th>
-				<%}%>
-			<%}%>
-			<%if(name == null) {%>
-				<%for(field in beanFields) { %>
-					<th><%=_ctx.appRes(uiParent.getName()+".header."+field)%></th>
-				<%}%>
-				<%if(beanActions != null && beanActions.length > 0) { %>
-					<th><%=_ctx.appRes(uiParent.getName()+".header.action")%></th>
-				<%}%>
-			<%}%>
-		</tr>
-	</thead>
-	<tbody>
-	<%
-		def rowClass = null; 
-		boolean even = true; 
-		for (bean in uicomponent.getBeans())	{
-			if(even) rowClass = "EvenRow"; 	
-			else rowClass =	"OddRow";  
-			even = !even; 
-	%>
-		<tr class="$rowClass">
-			<%
-				for(field in beanFields) { 
-					def fieldValue = uicomponent.getFieldValue(bean, field); 
-					def cssClass = ""; 
-					if(fieldValue != null) {
-						def fieldClass = fieldValue.getClass(); 
-						if(fieldClass == Integer.class)	cssClass = "number"; 
-						else if(fieldClass == java.util.Date.class)	cssClass = "Datetime"; 
-						else cssClass = "text"; 
-					} else {
-						fieldValue = "";
-					}
-			%>
-					<td class="$cssClass">$fieldValue</td>
-					
-			<%}%>
-			<%if(beanActions != null && beanActions.length > 0) { %>
-				<td>				 
-					<div class="ActionContainer">
-						<%						
-							def beanIdField = uicomponent.getBeanIdField(); 			
-							def access = rcontext.getAccessPath();
-							def accessPath	= "public";
-							if(access == 1) accessPath	= "private";
-							for(action in beanActions) { 
-								def beanId = uicomponent.getFieldValue(bean, beanIdField)	;
-						%>		 
-							<img onclick="javascript:eXo.portal.UIPortal.changePortal('<%=accessPath%>', '<%=beanId%>');" title = "<%=_ctx.appRes(uicomponent.getParent().getName() + ".action.title." + action)%>" src="/eXoResources/skin/sharedImages/Blank.gif" class="${action}Icon" />					
-						<%}%>								 
-						</div>
-					</div>
-				</td>
-			<% } %>	
-		</tr>
-	<%}%>
-	</tbody>
-</table> <!--End UIGrid-->
-	<%
-	if(uicomponent.getUIPageIterator().getAvailablePage() > 1) {
-		_ctx.renderUIComponent(uicomponent.getUIPageIterator()); 
-	}
-	%>
-</div>
\ No newline at end of file

Deleted: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIApplicationList.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIApplicationList.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIApplicationList.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -1,195 +0,0 @@
-/**
- * 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.
- */
-
-package org.exoplatform.portal.webui.application;
-
-import org.exoplatform.application.gadget.Gadget;
-import org.exoplatform.application.gadget.GadgetRegistryService;
-import org.exoplatform.application.registry.Application;
-import org.exoplatform.application.registry.ApplicationCategory;
-import org.exoplatform.application.registry.ApplicationRegistryService;
-import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.services.security.Identity;
-import org.exoplatform.services.security.IdentityRegistry;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIContainer;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS
- * Author : Pham Thanh Tung
- *          thanhtungty at gmail.com
- * Jun 11, 2009  
- */
- at ComponentConfig(template = "system:/groovy/portal/webui/application/UIApplicationList.gtmpl", events = {@EventConfig(listeners = UIApplicationList.SelectCategoryActionListener.class)})
-public class UIApplicationList extends UIContainer
-{
-   private List<ApplicationCategory> categories;
-
-   private ApplicationCategory selectedCategory;
-
-   @SuppressWarnings("unchecked")
-   public UIApplicationList() throws Exception
-   {
-      ApplicationRegistryService service = getApplicationComponent(ApplicationRegistryService.class);
-      String remoteUser = Util.getPortalRequestContext().getRemoteUser();
-      if (remoteUser == null || remoteUser.equals(""))
-         return;
-      UserACL userACL = Util.getUIPortalApplication().getApplicationComponent(UserACL.class);
-      IdentityRegistry identityRegistry = Util.getUIPortalApplication().getApplicationComponent(IdentityRegistry.class);
-      Identity identity = identityRegistry.getIdentity(remoteUser);
-      if (identity == null)
-         return;
-
-      PortletComparator portletComparator = new PortletComparator();
-      categories = service.getApplicationCategories(remoteUser);
-
-      Iterator<ApplicationCategory> cateItr = categories.iterator();
-      while (cateItr.hasNext())
-      {
-         ApplicationCategory cate = cateItr.next();
-         List<Application> applications = cate.getApplications();
-         boolean hasPermission = false;
-         List<String> accessPermission = cate.getAccessPermissions();
-         if (accessPermission == null)
-         {
-            accessPermission = new ArrayList<String>();
-         }
-         if (accessPermission.size() == 0)
-         {
-            accessPermission.add(null);
-         }
-         for (String permssion : accessPermission)
-         {
-            hasPermission = userACL.hasPermission(identity, permssion);
-            if (hasPermission)
-               break;
-         }
-
-         if (!hasPermission || applications.size() < 1)
-            cateItr.remove();
-         else
-            Collections.sort(applications, portletComparator);
-      }
-      if (categories.size() > 0)
-         setSelectedCategory(categories.get(0).getName());
-
-      Collections.sort(categories, new PortletCategoryComparator());
-   }
-
-   public Application getApplication(String id) throws Exception
-   {
-      for (ApplicationCategory category : categories)
-      {
-         List<Application> items = category.getApplications();
-         for (Application item : items)
-         {
-            if (item.getId().equals(id))
-               return item;
-         }
-      }
-      return null;
-   }
-
-   public ApplicationCategory getSelectedCategory()
-   {
-      return selectedCategory;
-   }
-
-   public void setSelectedCategory(String categoryName)
-   {
-      for (ApplicationCategory category : categories)
-      {
-         if (category.getName().equals(categoryName))
-         {
-            selectedCategory = category;
-         }
-      }
-   }
-
-   public List<Application> getApplications()
-   {
-      if (selectedCategory == null)
-         return null;
-      List<Application> apps = selectedCategory.getApplications();
-
-      //Correct IconURL of Gadget
-      GadgetRegistryService gadgetService = getApplicationComponent(GadgetRegistryService.class);
-      for (Application app : apps)
-      {
-         if (ApplicationType.GADGET.equals(app.getType()))
-         {
-            try
-            {
-               Gadget gadget;
-               gadget = gadgetService.getGadget(app.getApplicationName());
-               if (gadget != null)
-                  app.setIconURL(gadget.getThumbnail());
-            }
-            catch (Exception e)
-            {
-            }
-         }
-      }
-      return apps;
-   }
-
-   public List<ApplicationCategory> getCategories()
-   {
-      return categories;
-   }
-
-   static class PortletCategoryComparator implements Comparator<ApplicationCategory>
-   {
-      public int compare(ApplicationCategory cat1, ApplicationCategory cat2)
-      {
-         return cat1.getDisplayName().compareToIgnoreCase(cat2.getDisplayName());
-      }
-   }
-
-   static class PortletComparator implements Comparator<Application>
-   {
-      public int compare(Application p1, Application p2)
-      {
-         return p1.getDisplayName().compareToIgnoreCase(p2.getDisplayName());
-      }
-   }
-
-   static public class SelectCategoryActionListener extends EventListener<UIApplicationList>
-   {
-      public void execute(Event<UIApplicationList> event) throws Exception
-      {
-         String category = event.getRequestContext().getRequestParameter(OBJECTID);
-         UIApplicationList uiApplicationList = event.getSource();
-         uiApplicationList.setSelectedCategory(category);
-         event.getRequestContext().addUIComponentToUpdateByAjax(uiApplicationList);
-      }
-
-   }
-}
\ No newline at end of file

Deleted: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerList.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerList.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerList.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -1,134 +0,0 @@
-/**
- * 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.
- */
-
-package org.exoplatform.portal.webui.container;
-
-import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.config.InitParams;
-import org.exoplatform.webui.config.Param;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.config.annotation.ParamConfig;
-import org.exoplatform.webui.core.model.SelectItemCategory;
-import org.exoplatform.webui.core.model.SelectItemOption;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-import org.jibx.runtime.BindingDirectory;
-import org.jibx.runtime.IBindingFactory;
-import org.jibx.runtime.IUnmarshallingContext;
-
-import java.io.ByteArrayInputStream;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS
- * Author : Pham Thanh Tung
- *          thanhtungty at gmail.com
- * Jun 11, 2009  
- */
- at ComponentConfig(template = "system:/groovy/portal/webui/container/UIContainerList.gtmpl", events = {@EventConfig(listeners = UIContainerList.SelectCategoryActionListener.class)}, initParams = @ParamConfig(name = "ContainerConfigOption", value = "system:/WEB-INF/conf/uiconf/portal/webui/container/ContainerConfigOption.groovy"))
-public class UIContainerList extends UIContainer
-{
-
-   private List<SelectItemCategory> categories_;
-
-   private SelectItemCategory selectedCategory_;
-
-   public UIContainerList(InitParams initParams) throws Exception
-   {
-      //    setComponentConfig(UIContainerConfigOptions.class, null);    
-      selectedCategory_ = null;
-      if (initParams == null)
-         return;
-      WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
-      Param param = initParams.getParam("ContainerConfigOption");
-      categories_ = (List<SelectItemCategory>)param.getMapGroovyObject(context);
-      if (categories_ == null)
-         return;
-      setSelectedCategory(categories_.get(0));
-   }
-
-   public void setSelectedCategory(SelectItemCategory selectedCategory)
-   {
-      selectedCategory_ = selectedCategory;
-   }
-
-   public void setSelectedCategory(String name)
-   {
-      for (SelectItemCategory itemCategory : categories_)
-      {
-         if (itemCategory.getName().equals(name))
-         {
-            selectedCategory_ = itemCategory;
-            return;
-         }
-      }
-   }
-
-   public SelectItemCategory getSelectedCategory()
-   {
-      return selectedCategory_;
-   }
-
-   public List<SelectItemCategory> getCategories()
-   {
-      return categories_;
-   }
-
-   public void setCategories(List<SelectItemCategory> categories)
-   {
-      categories_ = categories;
-   }
-
-   public Container getContainer(String id) throws Exception
-   {
-      for (SelectItemCategory category : categories_)
-      {
-         List<SelectItemOption> items = category.getSelectItemOptions();
-         for (SelectItemOption item : items)
-         {
-            if (item.getLabel().equals(id))
-               return toContainer(item.getValue().toString());
-         }
-      }
-      return null;
-   }
-
-   private Container toContainer(String xml) throws Exception
-   {
-      ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes());
-      IBindingFactory bfact = BindingDirectory.getFactory(Container.class);
-      IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
-      return (Container)uctx.unmarshalDocument(is, null);
-   }
-
-   static public class SelectCategoryActionListener extends EventListener<UIContainerList>
-   {
-      public void execute(Event<UIContainerList> event) throws Exception
-      {
-         String category = event.getRequestContext().getRequestParameter(OBJECTID);
-         UIContainerList uiContainerList = event.getSource();
-         uiContainerList.setSelectedCategory(category);
-         event.getRequestContext().addUIComponentToUpdateByAjax(uiContainerList);
-      }
-
-   }
-
-}
\ No newline at end of file

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -33,32 +33,18 @@
 {
 
    /** . */
-   private String storageId;
-
    private String pageId;
 
    private String ownerId;
 
    private String ownerType;
 
-   private String[] accessPermissions;
-
    private String editPermission;
 
    private boolean showMaxWindow = false;
 
    private UIPortlet maximizedUIPortlet;
 
-   public String getStorageId()
-   {
-      return storageId;
-   }
-
-   public void setStorageId(String storageId)
-   {
-      this.storageId = storageId;
-   }
-
    public String getOwnerId()
    {
       return ownerId;
@@ -79,16 +65,6 @@
       this.showMaxWindow = showMaxWindow;
    }
 
-   public String[] getAccessPermissions()
-   {
-      return accessPermissions;
-   }
-
-   public void setAccessPermissions(String[] accessGroups)
-   {
-      this.accessPermissions = accessGroups;
-   }
-
    public String getEditPermission()
    {
       return editPermission;

Copied: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java (from rev 3199, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIApplicationList.java)
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java	                        (rev 0)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -0,0 +1,194 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.portal.webui.portal;
+
+import org.exoplatform.application.gadget.Gadget;
+import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.registry.Application;
+import org.exoplatform.application.registry.ApplicationCategory;
+import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.exoplatform.portal.config.UserACL;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.services.security.Identity;
+import org.exoplatform.services.security.IdentityRegistry;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIContainer;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Pham Thanh Tung
+ *          thanhtungty at gmail.com
+ * Jun 11, 2009  
+ */
+ at ComponentConfig(template = "system:/groovy/portal/webui/application/UIApplicationList.gtmpl", events = {@EventConfig(listeners = UIApplicationList.SelectCategoryActionListener.class)})
+public class UIApplicationList extends UIContainer
+{
+   private List<ApplicationCategory> categories;
+
+   private ApplicationCategory selectedCategory;
+
+   public UIApplicationList() throws Exception
+   {
+      ApplicationRegistryService service = getApplicationComponent(ApplicationRegistryService.class);
+      String remoteUser = Util.getPortalRequestContext().getRemoteUser();
+      if (remoteUser == null || remoteUser.equals(""))
+         return;
+      UserACL userACL = Util.getUIPortalApplication().getApplicationComponent(UserACL.class);
+      IdentityRegistry identityRegistry = Util.getUIPortalApplication().getApplicationComponent(IdentityRegistry.class);
+      Identity identity = identityRegistry.getIdentity(remoteUser);
+      if (identity == null)
+         return;
+
+      PortletComparator portletComparator = new PortletComparator();
+      categories = service.getApplicationCategories(remoteUser);
+
+      Iterator<ApplicationCategory> cateItr = categories.iterator();
+      while (cateItr.hasNext())
+      {
+         ApplicationCategory cate = cateItr.next();
+         List<Application> applications = cate.getApplications();
+         boolean hasPermission = false;
+         List<String> accessPermission = cate.getAccessPermissions();
+         if (accessPermission == null)
+         {
+            accessPermission = new ArrayList<String>();
+         }
+         if (accessPermission.size() == 0)
+         {
+            accessPermission.add(null);
+         }
+         for (String permssion : accessPermission)
+         {
+            hasPermission = userACL.hasPermission(identity, permssion);
+            if (hasPermission)
+               break;
+         }
+
+         if (!hasPermission || applications.size() < 1)
+            cateItr.remove();
+         else
+            Collections.sort(applications, portletComparator);
+      }
+      if (categories.size() > 0)
+         setSelectedCategory(categories.get(0).getName());
+
+      Collections.sort(categories, new PortletCategoryComparator());
+   }
+
+   public Application getApplication(String id) throws Exception
+   {
+      for (ApplicationCategory category : categories)
+      {
+         List<Application> items = category.getApplications();
+         for (Application item : items)
+         {
+            if (item.getId().equals(id))
+               return item;
+         }
+      }
+      return null;
+   }
+
+   public ApplicationCategory getSelectedCategory()
+   {
+      return selectedCategory;
+   }
+
+   public void setSelectedCategory(String categoryName)
+   {
+      for (ApplicationCategory category : categories)
+      {
+         if (category.getName().equals(categoryName))
+         {
+            selectedCategory = category;
+         }
+      }
+   }
+
+   public List<Application> getApplications()
+   {
+      if (selectedCategory == null)
+         return null;
+      List<Application> apps = selectedCategory.getApplications();
+
+      //Correct IconURL of Gadget
+      GadgetRegistryService gadgetService = getApplicationComponent(GadgetRegistryService.class);
+      for (Application app : apps)
+      {
+         if (ApplicationType.GADGET.equals(app.getType()))
+         {
+            try
+            {
+               Gadget gadget;
+               gadget = gadgetService.getGadget(app.getApplicationName());
+               if (gadget != null)
+                  app.setIconURL(gadget.getThumbnail());
+            }
+            catch (Exception e)
+            {
+            }
+         }
+      }
+      return apps;
+   }
+
+   public List<ApplicationCategory> getCategories()
+   {
+      return categories;
+   }
+
+   static class PortletCategoryComparator implements Comparator<ApplicationCategory>
+   {
+      public int compare(ApplicationCategory cat1, ApplicationCategory cat2)
+      {
+         return cat1.getDisplayName().compareToIgnoreCase(cat2.getDisplayName());
+      }
+   }
+
+   static class PortletComparator implements Comparator<Application>
+   {
+      public int compare(Application p1, Application p2)
+      {
+         return p1.getDisplayName().compareToIgnoreCase(p2.getDisplayName());
+      }
+   }
+
+   static public class SelectCategoryActionListener extends EventListener<UIApplicationList>
+   {
+      public void execute(Event<UIApplicationList> event) throws Exception
+      {
+         String category = event.getRequestContext().getRequestParameter(OBJECTID);
+         UIApplicationList uiApplicationList = event.getSource();
+         uiApplicationList.setSelectedCategory(category);
+         event.getRequestContext().addUIComponentToUpdateByAjax(uiApplicationList);
+      }
+
+   }
+}
\ No newline at end of file

Copied: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIContainerList.java (from rev 3199, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerList.java)
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIContainerList.java	                        (rev 0)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIContainerList.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -0,0 +1,134 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.portal.webui.portal;
+
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.config.InitParams;
+import org.exoplatform.webui.config.Param;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.config.annotation.ParamConfig;
+import org.exoplatform.webui.core.UIContainer;
+import org.exoplatform.webui.core.model.SelectItemCategory;
+import org.exoplatform.webui.core.model.SelectItemOption;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.jibx.runtime.BindingDirectory;
+import org.jibx.runtime.IBindingFactory;
+import org.jibx.runtime.IUnmarshallingContext;
+
+import java.io.ByteArrayInputStream;
+import java.util.List;
+
+/**
+ * @author <a href="trongtt at gmail.com">Trong Tran</a>
+ * @version $Revision$
+ */
+
+ at ComponentConfig(template = "system:/groovy/portal/webui/container/UIContainerList.gtmpl", events = {@EventConfig(listeners = UIContainerList.SelectCategoryActionListener.class)}, initParams = @ParamConfig(name = "ContainerConfigOption", value = "system:/WEB-INF/conf/uiconf/portal/webui/container/ContainerConfigOption.groovy"))
+public class UIContainerList extends UIContainer
+{
+
+   private List<SelectItemCategory> categories_;
+
+   private SelectItemCategory selectedCategory_;
+
+   public UIContainerList(InitParams initParams) throws Exception
+   {
+      //    setComponentConfig(UIContainerConfigOptions.class, null);    
+      selectedCategory_ = null;
+      if (initParams == null)
+         return;
+      WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+      Param param = initParams.getParam("ContainerConfigOption");
+      categories_ = (List<SelectItemCategory>)param.getMapGroovyObject(context);
+      if (categories_ == null)
+         return;
+      setSelectedCategory(categories_.get(0));
+   }
+
+   public void setSelectedCategory(SelectItemCategory selectedCategory)
+   {
+      selectedCategory_ = selectedCategory;
+   }
+
+   public void setSelectedCategory(String name)
+   {
+      for (SelectItemCategory itemCategory : categories_)
+      {
+         if (itemCategory.getName().equals(name))
+         {
+            selectedCategory_ = itemCategory;
+            return;
+         }
+      }
+   }
+
+   public SelectItemCategory getSelectedCategory()
+   {
+      return selectedCategory_;
+   }
+
+   public List<SelectItemCategory> getCategories()
+   {
+      return categories_;
+   }
+
+   public void setCategories(List<SelectItemCategory> categories)
+   {
+      categories_ = categories;
+   }
+
+   public Container getContainer(String id) throws Exception
+   {
+      for (SelectItemCategory category : categories_)
+      {
+         List<SelectItemOption> items = category.getSelectItemOptions();
+         for (SelectItemOption item : items)
+         {
+            if (item.getLabel().equals(id))
+               return toContainer(item.getValue().toString());
+         }
+      }
+      return null;
+   }
+
+   private Container toContainer(String xml) throws Exception
+   {
+      ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes());
+      IBindingFactory bfact = BindingDirectory.getFactory(Container.class);
+      IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
+      return (Container)uctx.unmarshalDocument(is, null);
+   }
+
+   static public class SelectCategoryActionListener extends EventListener<UIContainerList>
+   {
+      public void execute(Event<UIContainerList> event) throws Exception
+      {
+         String category = event.getRequestContext().getRequestParameter(OBJECTID);
+         UIContainerList uiContainerList = event.getSource();
+         uiContainerList.setSelectedCategory(category);
+         event.getRequestContext().addUIComponentToUpdateByAjax(uiContainerList);
+      }
+
+   }
+
+}
\ No newline at end of file

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -83,17 +83,12 @@
 public class UIPortal extends UIContainer
 {
 
-   /** Storage id. */
-   private String storageId;
-
    private String owner;
 
    private String ownerType;
 
    private String locale;
 
-   private String[] accessPermissions;
-
    private String editPermission;
 
    private String skin;
@@ -106,24 +101,12 @@
 
    private PageNode selectedNode_;
    
-   private UIPage showedUIPage;
-   
    private Map<String, UIPage> all_UIPages;
    
    private Map<String, String[]> publicParameters_ = new HashMap<String, String[]>();
 
    private UIComponent maximizedUIComponent;
 
-   public String getStorageId()
-   {
-      return storageId;
-   }
-
-   public void setStorageId(String storageId)
-   {
-      this.storageId = storageId;
-   }
-
    public String getOwner()
    {
       return owner;
@@ -144,16 +127,6 @@
       locale = s;
    }
 
-   public String[] getAccessPermissions()
-   {
-      return accessPermissions;
-   }
-
-   public void setAccessPermissions(String[] accessGroups)
-   {
-      this.accessPermissions = accessGroups;
-   }
-
    public String getEditPermission()
    {
       return editPermission;
@@ -516,32 +489,4 @@
          }
       }
    }
-   
-   private static class UIPageKey
-   {
-      private String ownerType;
-      
-      private String ownerId;
-      
-      UIPageKey(String _ownerType, String _ownerId)
-      {
-         this.ownerType = _ownerType;
-         this.ownerId = _ownerId;
-      }
-      
-      @Override
-      public boolean equals(Object obj)
-      {
-         if(this == null || obj == null)
-         {
-            return this == null && obj == null;
-         }
-         if(!(obj instanceof UIPageKey))
-         {
-            return false;
-         }
-         return this.ownerType.equals(((UIPageKey)obj).ownerType) && this.ownerId.equals(((UIPageKey)obj).ownerId);
-      }
-   }
-
 }

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -29,9 +29,7 @@
 import org.exoplatform.portal.config.model.Container;
 import org.exoplatform.portal.config.model.TransientApplicationState;
 import org.exoplatform.portal.webui.application.PortletState;
-import org.exoplatform.portal.webui.application.UIApplicationList;
 import org.exoplatform.portal.webui.application.UIPortlet;
-import org.exoplatform.portal.webui.container.UIContainerList;
 import org.exoplatform.portal.webui.container.UITabContainer;
 import org.exoplatform.portal.webui.login.UILogin;
 import org.exoplatform.portal.webui.login.UIResetPassword;

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -28,9 +28,7 @@
 import org.exoplatform.portal.config.model.PortalConfig;
 import org.exoplatform.portal.config.model.PortalProperties;
 import org.exoplatform.portal.resource.SkinService;
-import org.exoplatform.portal.webui.application.UIApplicationList;
 import org.exoplatform.portal.webui.application.UIPortlet;
-import org.exoplatform.portal.webui.container.UIContainerList;
 import org.exoplatform.portal.webui.page.UIPage;
 import org.exoplatform.portal.webui.page.UIPageForm;
 import org.exoplatform.portal.webui.page.UISiteBody;

Deleted: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalSelector.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalSelector.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalSelector.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -1,82 +0,0 @@
-/**
- * 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.
- */
-
-package org.exoplatform.portal.webui.portal;
-
-import org.exoplatform.commons.utils.LazyPageList;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.webui.container.UIContainer;
-import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
-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.UIGrid;
-
-import java.util.Iterator;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Pham Thanh Tung
- *          tung.pham at exoplatform.com
- * May 25, 2007  
- */
- at ComponentConfigs({
-   @ComponentConfig(template = "app:/groovy/portal/webui/portal/UIChangePortal.gtmpl", events = @EventConfig(listeners = UIMaskWorkspace.CloseActionListener.class)),
-   @ComponentConfig(id = "PortalSelector", type = UIGrid.class, template = "app:/groovy/portal/webui/portal/UIPortalSelector.gtmpl")})
-public class UIPortalSelector extends UIContainer
-{
-
-   public static String[] BEAN_FEILD = {"creator", "name", "skin"};
-
-   public static String[] SELECT_ACTIONS = {"SelectPortal"};
-
-   public UIPortalSelector() throws Exception
-   {
-      setName("UIChangePortal");
-      UIGrid uiGrid = addChild(UIGrid.class, "PortalSelector", null);
-      uiGrid.configure("name", BEAN_FEILD, SELECT_ACTIONS);
-      uiGrid.getUIPageIterator().setId("ChangePortalPageInterator");
-      addChild(uiGrid.getUIPageIterator());
-      uiGrid.getUIPageIterator().setRendered(false);
-      DataStorage dataService = getApplicationComponent(DataStorage.class);
-      Query<PortalData> query = new Query<PortalData>(null, null, null, null, PortalData.class);
-      LazyPageList<PortalData> pageList = dataService.find(query);
-      pageList.setPageSize(10);
-      pageList = extractPermissedPortal(pageList);
-      uiGrid.getUIPageIterator().setPageList(pageList);
-   }
-
-   private LazyPageList<PortalData> extractPermissedPortal(LazyPageList<PortalData> pageList) throws Exception
-   {
-      UserACL userACL = getApplicationComponent(UserACL.class);
-      Iterator<PortalData> itr = pageList.getAll().iterator();
-      while (itr.hasNext())
-      {
-         PortalData pConfig = itr.next();
-         if (!userACL.hasPermission(new PortalConfig(pConfig)))
-            itr.remove();
-      }
-      return pageList;
-   }
-
-}
\ No newline at end of file

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIEditInlineWorkspace.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIEditInlineWorkspace.java	2010-05-26 09:21:59 UTC (rev 3201)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIEditInlineWorkspace.java	2010-05-26 11:24:50 UTC (rev 3202)
@@ -19,10 +19,10 @@
 
 package org.exoplatform.portal.webui.workspace;
 
-import org.exoplatform.portal.webui.container.UIContainer;
 import org.exoplatform.portal.webui.portal.UIPortalComposer;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
 import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.core.UIContainer;
 import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
 
 /**



More information about the gatein-commits mailing list