[gatein-commits] gatein SVN: r2902 - in portal/trunk: webui/core/src/main/java/org/exoplatform/webui/core and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Apr 29 12:45:12 EDT 2010


Author: hoang_to
Date: 2010-04-29 12:45:12 -0400 (Thu, 29 Apr 2010)
New Revision: 2902

Modified:
   portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIFilterableTree.gtmpl
   portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIFilterableTree.java
Log:
GTNPORTAL-1139: Update java code and template

Modified: portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIFilterableTree.gtmpl
===================================================================
--- portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIFilterableTree.gtmpl	2010-04-29 16:22:50 UTC (rev 2901)
+++ portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIFilterableTree.gtmpl	2010-04-29 16:45:12 UTC (rev 2902)
@@ -1,13 +1,15 @@
 <%
 	import org.exoplatform.webui.core.UIRightClickPopupMenu;
 	import org.exoplatform.webui.application.WebuiRequestContext;
+
+	UIRightClickPopupMenu uiPopupMenu = uicomponent.getUIRightClickPopupMenu();
+	WebuiRequestContext rcontext = _ctx.getRequestContext();
 	
 	def selected = uicomponent.getSelected();
 	def sibling = uicomponent.getSibbling();
 	def children = uicomponent.getChildren();	
-
-	UIRightClickPopupMenu uiPopupMenu = uicomponent.getUIRightClickPopupMenu();
-	WebuiRequestContext rcontext = _ctx.getRequestContext();
+	def indexOfRightMostDisplayedSibbling = uicomponent.getRightMostDisplayedNodeIndex(sibling, rcontext);
+	def indexOfRightMostDisplayedChild = uicomponent.getRightMostDisplayedNodeIndex(children, rcontext);
 	
 	if(uiPopupMenu != null){
 		String id = uicomponent.getParent().getId();
@@ -26,7 +28,7 @@
 			int count=0;
 			for(object in sibling) {
 			if(uicomponent.displayThisNode(object, rcontext)){
-				if(count==sibling.size()-1) {
+				if(count == indexOfRightMostDisplayedSibbling) {
 			%>
 				<div class="LastNode Node">
 					<% 
@@ -41,7 +43,7 @@
 						int countChild=0;
 						for(child in children) {
 						if(uicomponent.displayThisNode(child, rcontext)){
-						if(countChild==children.size()-1) {
+						if(countChild == indexOfRightMostDisplayedChild) {
 						%>
 						 		<div class="LastNode Node">
 									<%=uicomponent.renderNode(child);%>
@@ -70,7 +72,7 @@
 						int countChild=0;
 						for(child in children) {
 						if(uicomponent.displayThisNode(child, rcontext)){
-									if(countChild==children.size()-1) {
+									if(countChild == indexOfRightMostDisplayedChild) {
 						 %>
 						 		<div class="LastNode Node">
 									<%=uicomponent.renderNode(child);%>

Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIFilterableTree.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIFilterableTree.java	2010-04-29 16:22:50 UTC (rev 2901)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIFilterableTree.java	2010-04-29 16:45:12 UTC (rev 2902)
@@ -18,6 +18,8 @@
  */
 package org.exoplatform.webui.core;
 
+import java.util.List;
+
 import org.exoplatform.commons.serialization.api.annotations.Serialized;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -49,6 +51,61 @@
       return !nodeFilter.filterThisNode(nodeObject, context);
    }
    
+   /**
+    *   Method returns index ( relative to unfiltered list of sibblings ) of most right displayed node. The index
+    * is needed for a fine UI
+    *  
+    * @param sibblings
+    * @param context
+    * @return
+    */
+   public int getRightMostDisplayedNodeIndex(List<Object> sibblings, WebuiRequestContext context)
+   {
+      int numberOfSibblings = sibblings.size();
+      if (nodeFilter == null)
+      {
+         return (numberOfSibblings - 1);
+      }
+      else
+      {
+         for (int i = (numberOfSibblings - 1); i >= 0; i--)
+         {
+            if (!nodeFilter.filterThisNode(sibblings.get(i), context))
+            {
+               return i;
+            }
+         }
+         return -1;
+      }
+   }
+   
+   /**
+    *   Method returns index ( relative to unfiltered list of sibblings ) of most left displayed node.
+    *  
+    * @param sibblings
+    * @param context
+    * @return
+    */
+   public int getLeftMostDisplayedNodeIndex(List<Object> sibblings, WebuiRequestContext context)
+   {
+      int numberOfSibblings = sibblings.size();
+      if (nodeFilter == null)
+      {
+         return 0;
+      }
+      else
+      {
+         for (int i = 0; i < numberOfSibblings; i++)
+         {
+            if (!nodeFilter.filterThisNode(sibblings.get(i), context))
+            {
+               return i;
+            }
+         }
+         return numberOfSibblings;
+      }
+   }
+   
    public void setTreeNodeFilter(TreeNodeFilter _nodeFilter)
    {
       this.nodeFilter = _nodeFilter;



More information about the gatein-commits mailing list