You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2007/11/12 04:13:03 UTC

svn commit: r594015 - in /myfaces/trinidad/trunk/trinidad: trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/ trinidad-impl/src/main...

Author: arobinson74
Date: Sun Nov 11 19:13:02 2007
New Revision: 594015

URL: http://svn.apache.org/viewvc?rev=594015&view=rev
Log:
TRINIDAD-786 -- Support multiple root nodes or the ability to hide the root node of treeTable

Added a new property of rootNodeRendered that defaults to true. This gives the appearance of multiple root nodes


Modified:
    myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/TreeTable.xml
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/TreeTableRenderer.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeTableRenderingContext.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java

Modified: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/TreeTable.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/TreeTable.xml?rev=594015&r1=594014&r2=594015&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/TreeTable.xml (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/TreeTable.xml Sun Nov 11 19:13:02 2007
@@ -33,6 +33,22 @@
     <component-type>org.apache.myfaces.trinidad.TreeTable</component-type>
     <component-class>org.apache.myfaces.trinidad.component.UIXTreeTable</component-class>
     <property>
+      <description>
+        <![CDATA[
+          If the root node should be rendered or not. Defaults to true.
+        ]]>
+      </description>
+      <property-name>rootNodeRendered</property-name>
+      <property-class>boolean</property-class>
+      <default-value>true</default-value>
+      <property-extension>
+        <mfp:property-metadata>
+          <mfp:preferred>true</mfp:preferred>
+        </mfp:property-metadata>
+        <mfp:required>false</mfp:required>
+      </property-extension>
+    </property>
+    <property>
       <description><![CDATA[the maximum number of records that can be displayed at
               one time (range size).
               Each level of depth in the tree can have a different range size.

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/TreeTableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/TreeTableRenderer.java?rev=594015&r1=594014&r2=594015&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/TreeTableRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/TreeTableRenderer.java Sun Nov 11 19:13:02 2007
@@ -35,12 +35,14 @@
 import org.apache.myfaces.trinidad.component.UIXTree;
 import org.apache.myfaces.trinidad.component.UIXTreeTable;
 import org.apache.myfaces.trinidad.component.core.data.CoreTreeTable;
+import org.apache.myfaces.trinidad.context.FormData;
+import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.model.RowKeySet;
-import org.apache.myfaces.trinidad.context.RenderingContext;
-import org.apache.myfaces.trinidad.context.FormData;
 import org.apache.myfaces.trinidad.render.CoreRenderer;
+import org.apache.myfaces.trinidad.skin.Icon;
+import org.apache.myfaces.trinidad.util.IntegerUtils;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.OutputUtils;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.ResourceKeyUtils;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SkinSelectors;
@@ -56,8 +58,6 @@
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TreeTableNavRenderer;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TreeTableRenderingContext;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TreeUtils;
-import org.apache.myfaces.trinidad.skin.Icon;
-import org.apache.myfaces.trinidad.util.IntegerUtils;
 
 /**
  * Renderer for treeTable
@@ -77,10 +77,9 @@
     super.findTypeConstants(type);
     _immediateKey  = type.findKey("immediate");
     _expandAllEnabledKey  = type.findKey("expandAllEnabled");
+    _rootNodeRendered = type.findKey("rootNodeRendered");
   }
 
-
-
   /**
    * @todo Set "expanded" vs. "collapsed" correctly on the queued
    *  DisclosureEvent
@@ -165,7 +164,7 @@
 
     TreeUtils.setDefaultFocusRowKey((UIXTree) component);
     TreeUtils.expandFocusRowKey((UIXTree) component);
-
+    
     super.encodeAll(context, arc, component, bean);
 
     // have we rendered the script before?
@@ -344,7 +343,7 @@
     if (isEmptyTable)
       _renderEmptyTableRow(context, arc, ttrc);
     else
-      _renderTableRows(context, arc, ttrc);
+      _renderTableRows(context, arc, ttrc, bean);
 
     // render the footer
     renderFooter(context, arc, trc, component);
@@ -359,11 +358,18 @@
     return _FOCUS;
   }
 
+  protected boolean isRootNodeRendered(FacesBean bean)
+  {
+    if (_rootNodeRendered == null)
+      return true;
+
+    return !Boolean.FALSE.equals(bean.getProperty(_rootNodeRendered));
+  }
+  
   //
   // Private methods
   //
 
-
   // Renders the hGridLocator Icon
   private void _renderLocatorIcon(
     FacesContext          fc,
@@ -436,12 +442,15 @@
   private void _renderTableRows(
     FacesContext          context,
     final RenderingContext   arc,
-    final TreeTableRenderingContext ttrc) throws IOException
+    final TreeTableRenderingContext ttrc,
+    final FacesBean bean)
+    throws IOException
   {
     final UIXTreeTable treeTableBase = ttrc.getUIXTreeTable();
     final ResponseWriter writer = context.getResponseWriter();
     final RowKeySet treeState = treeTableBase.getDisclosedRowKeys();
     final int specialColCount = _getSpecialColCount(ttrc);
+    final boolean rootNodeRendered = isRootNodeRendered(bean);
 
     TableUtils.RowLoop loop = new TableUtils.RowLoop()
     {
@@ -458,9 +467,13 @@
       protected void processRowImpl(FacesContext context, CollectionComponent treeTable)
         throws IOException
       {
-        writer.startElement(XhtmlConstants.TABLE_ROW_ELEMENT, null);
-        renderSingleRow(context, arc, ttrc, treeTableBase);
-        writer.endElement(XhtmlConstants.TABLE_ROW_ELEMENT);
+        if (rootNodeRendered || treeTableBase.getDepth() > 0)
+        {
+          writer.startElement(XhtmlConstants.TABLE_ROW_ELEMENT, null);
+          renderSingleRow(context, arc, ttrc, treeTableBase);
+          writer.endElement(XhtmlConstants.TABLE_ROW_ELEMENT);
+        }
+        
 //
   //        if (hasInvisibleNodes)
   //        {
@@ -469,7 +482,7 @@
 
         if (treeTableBase.isContainer())
         {
-          if (treeState.isContained())
+          if (treeState.isContained() || (rootNodeRendered == false && treeTableBase.getDepth() == 0))
           {
             treeTableBase.enterContainer();
             int rows = treeTableBase.getRows();
@@ -653,6 +666,7 @@
 
   private PropertyKey _immediateKey;
   private PropertyKey _expandAllEnabledKey;
+  private PropertyKey _rootNodeRendered;
 
   private static final Object _JS_LIBS_KEY = new Object();
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(TreeTableRenderer.class);

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java?rev=594015&r1=594014&r2=594015&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java Sun Nov 11 19:13:02 2007
@@ -26,14 +26,14 @@
 import javax.faces.context.ResponseWriter;
 
 import org.apache.myfaces.trinidad.component.UIXTreeTable;
-import org.apache.myfaces.trinidad.model.RowKeySet;
 import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.model.RowKeySet;
+import org.apache.myfaces.trinidad.skin.Icon;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.ColumnRenderer;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.OutputUtils;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SkinSelectors;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlRenderer;
-import org.apache.myfaces.trinidad.skin.Icon;
 
 public class TreeNodeColumnRenderer extends ColumnRenderer
 {
@@ -71,6 +71,13 @@
 
     int focusPath = hGrid.getDepth(TreeUtils.getFocusRowKey(hGrid));
     int depth = hGrid.getDepth() + 1 - focusPath;
+    if (!ttrc.isRootNodeRendered())
+    {
+      // decrease the depth by one if the root node is not rendered to avoid
+      // unnecessary indentation 
+      --depth;
+    }
+    
     int spacerWidth = _getSpacerWidth(ttrc);
 
     ResponseWriter writer = context.getResponseWriter();

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeTableRenderingContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeTableRenderingContext.java?rev=594015&r1=594014&r2=594015&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeTableRenderingContext.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeTableRenderingContext.java Sun Nov 11 19:13:02 2007
@@ -24,9 +24,9 @@
 import org.apache.myfaces.trinidad.component.UIXColumn;
 import org.apache.myfaces.trinidad.component.UIXTree;
 import org.apache.myfaces.trinidad.component.UIXTreeTable;
+import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.model.RowKeySet;
-import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SkinProperties;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
 
@@ -83,6 +83,8 @@
     {
       _spacerWidth = _DEFAULT_SPACER_WIDTH;
     }
+    
+    _rootNodeRendered = _hGridBase.isRootNodeRendered();
   }
 
   /**
@@ -172,6 +174,14 @@
   {
     return _spacerWidth;
   }
+  
+  /**
+   * @return if the root node is rendered
+   */
+  public boolean isRootNodeRendered()
+  {
+    return _rootNodeRendered;
+  }
 
 //  protected boolean computeHasNavigation(UINode table, int rows)
 //  {
@@ -189,6 +199,7 @@
   private final Object _crumbs;
   private final UIComponent _nodeStamp, _pathStamp;
   private final int _spacerWidth;
+  private final boolean _rootNodeRendered;
 
   private static final int _DEFAULT_SPACER_WIDTH = 18;
 

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java?rev=594015&r1=594014&r2=594015&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java Sun Nov 11 19:13:02 2007
@@ -19,7 +19,6 @@
 package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table;
 
 import java.io.IOException;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -34,19 +33,19 @@
 import org.apache.myfaces.trinidad.component.UIXPage;
 import org.apache.myfaces.trinidad.component.UIXTree;
 import org.apache.myfaces.trinidad.component.UIXTreeTable;
+import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.event.FocusEvent;
 import org.apache.myfaces.trinidad.event.RowDisclosureEvent;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.model.RowKeySet;
-import org.apache.myfaces.trinidad.context.RenderingContext;
-import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.util.IntegerUtils;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.HiddenLabelUtils;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SkinSelectors;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.TableRenderer;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlRenderer;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
-import org.apache.myfaces.trinidad.util.IntegerUtils;
 
 /**
  * Class that handles all tree related events
@@ -110,7 +109,7 @@
   }
 
   /**
-   * Utility method to expand the focusRowKey during intial
+   * Utility method to expand the focusRowKey during initial
    * rendering.
    * @param tree
    */