Author: hoang_to
Date: 2010-04-29 08:14:27 -0400 (Thu, 29 Apr 2010)
New Revision: 2891
Added:
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: Create a UIFilterableTree in UI Framework
Added: portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIFilterableTree.gtmpl
===================================================================
--- portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIFilterableTree.gtmpl
(rev 0)
+++
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIFilterableTree.gtmpl 2010-04-29
12:14:27 UTC (rev 2891)
@@ -0,0 +1,93 @@
+<%
+ import org.exoplatform.webui.core.UIRightClickPopupMenu;
+ import org.exoplatform.webui.application.WebuiRequestContext;
+
+ def selected = uicomponent.getSelected();
+ def sibling = uicomponent.getSibbling();
+ def children = uicomponent.getChildren();
+
+ UIRightClickPopupMenu uiPopupMenu = uicomponent.getUIRightClickPopupMenu();
+ WebuiRequestContext rcontext = _ctx.getRequestContext();
+
+ if(uiPopupMenu != null){
+ String id = uicomponent.getParent().getId();
+ rcontext.getJavascriptManager().importJavascript('eXo.webui.UIRightClickPopupMenu');
+ rcontext.getJavascriptManager().addJavascript("eXo.webui.UIRightClickPopupMenu.disableContextMenu('"+id+"');");
+ uicomponent.renderUIComponent(uiPopupMenu);
+ }
+%>
+<div class="UITrees ScrollArea">
+ <div class="TreeContainer JSContainer">
+ <div style="padding-bottom: 12px">
+ <div class="HomeNode">
+ <a class="LevelUpArrowIcon"
href="<%=uicomponent.getActionLink();%>"
onmousedown="event.cancelBubble=true;"
title="<%=_ctx.appRes("UITree.tooltip.UpLevel")%>"
style="display: block;"><span></span></a>
+ </div>
+ <%
+ int count=0;
+ for(object in sibling) {
+ if(uicomponent.displayThisNode(object, rcontext)){
+ if(count==sibling.size()-1) {
+ %>
+ <div class="LastNode Node">
+ <%
+ String objId = String.valueOf(uicomponent.getId(object));
+ String actionLink = uicomponent.event("ChangeNode", objId);
+ %>
+ <%=uicomponent.renderNode(object);%>
+ <%
+ if(uicomponent.isSelected(object)){%>
+ <div class = "ChildrenContainer" actionLink="$actionLink"
display = "block">
+ <%
+ int countChild=0;
+ for(child in children) {
+ if(uicomponent.displayThisNode(child, rcontext)){
+ if(countChild==children.size()-1) {
+ %>
+ <div class="LastNode Node">
+ <%=uicomponent.renderNode(child);%>
+ </div>
+ <% } else { %>
+ <div class="Node">
+ <%=uicomponent.renderNode(child);%>
+ </div>
+ <% } %>
+ <% } %>
+ <%countChild++;} %>
+ </div>
+ <%}%>
+ </div>
+ <% } else { %>
+ <div class="Node">
+ <%
+ String objId = String.valueOf(uicomponent.getId(object));
+ String actionLink = uicomponent.event("ChangeNode", objId);
+ %>
+ <%=uicomponent.renderNode(object);%>
+ <%
+ if(uicomponent.isSelected(object)){%>
+ <div class = "ChildrenContainer" actionLink="$actionLink"
display = "block">
+ <%
+ int countChild=0;
+ for(child in children) {
+ if(uicomponent.displayThisNode(child, rcontext)){
+ if(countChild==children.size()-1) {
+ %>
+ <div class="LastNode Node">
+ <%=uicomponent.renderNode(child);%>
+ </div>
+ <% } else { %>
+ <div class="Node">
+ <%=uicomponent.renderNode(child);%>
+ </div>
+ <% } %>
+ <% } %>
+ <%countChild++;} %>
+ </div>
+ <%}%>
+ </div>
+ <% } %>
+ <% } %>
+ <%count++;}%>
+ </div>
+ </div>
+</div>
\ No newline at end of file
Added:
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
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIFilterableTree.java 2010-04-29
12:14:27 UTC (rev 2891)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 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.webui.core;
+
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @version $Id$
+ *
+ */
+@ComponentConfig(template = "system:/groovy/webui/core/UIFilterableTree.gtmpl",
events = @EventConfig(listeners = UITree.ChangeNodeActionListener.class))
+@Serialized
+public class UIFilterableTree extends UITree
+{
+
+ private TreeNodeFilter nodeFilter;
+
+ public UIFilterableTree() throws Exception
+ {
+ super();
+ }
+
+ public boolean displayThisNode(Object nodeObject, WebuiRequestContext context)
+ {
+ if(nodeFilter == null)
+ {
+ return true;
+ }
+ return !nodeFilter.filterThisNode(nodeObject, context);
+ }
+
+ public void setTreeNodeFilter(TreeNodeFilter _nodeFilter)
+ {
+ this.nodeFilter = _nodeFilter;
+ }
+
+ public static interface TreeNodeFilter
+ {
+ public boolean filterThisNode(Object nodeObject, WebuiRequestContext context);
+ }
+}