You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ct...@apache.org on 2008/03/30 19:09:40 UTC

svn commit: r642777 - in /myfaces/trinidad/trunk: src/site/xdoc/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/

Author: ctoth
Date: Sun Mar 30 10:09:38 2008
New Revision: 642777

URL: http://svn.apache.org/viewvc?rev=642777&view=rev
Log:
TRINIDAD-1034 breadCrumbs skinning improvement

Modified:
    myfaces/trinidad/trunk/src/site/xdoc/skin-selectors.xml
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BreadCrumbsRenderer.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SkinProperties.java

Modified: myfaces/trinidad/trunk/src/site/xdoc/skin-selectors.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/src/site/xdoc/skin-selectors.xml?rev=642777&r1=642776&r2=642777&view=diff
==============================================================================
--- myfaces/trinidad/trunk/src/site/xdoc/skin-selectors.xml (original)
+++ myfaces/trinidad/trunk/src/site/xdoc/skin-selectors.xml Sun Mar 30 10:09:38 2008
@@ -635,6 +635,18 @@
                 {-tr-show-last-item:false} will not show the last item in the
                 breadCrumbs.</td>
           </tr>
+          <tr>
+            <td>-tr-separator-on-new-line</td>
+            <td>Valid values are true or false. In the case the orientation is
+                vertical, it determines whether the separator will be shown on
+                the new line (in front of the next path element)</td>
+          </tr>
+          <tr>
+            <td>-tr-indent-spaces</td>
+            <td>Valid values are positive integers. In the case the orientation
+                is vertical, it determines whether the number of nbsp's rendered
+                as an indent</td>
+          </tr>
         </table>
       </subsection>
       <a name="chooseDate"></a>

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BreadCrumbsRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BreadCrumbsRenderer.java?rev=642777&r1=642776&r2=642777&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BreadCrumbsRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BreadCrumbsRenderer.java Sun Mar 30 10:09:38 2008
@@ -183,7 +183,7 @@
 
   protected void renderNode(
     FacesContext        context,
-    RenderingContext arc,
+    RenderingContext    arc,
     Icon                separatorIcon,
     UIComponent         child,
     int                 renderedCount,
@@ -194,9 +194,11 @@
     ) throws IOException
   {      
     
+    boolean separatorOnNewRow = shouldRenderSeparatorOnNewLineWhenVertical(arc);
+
     if (!isLastChild || shouldRenderLastChild)
     {
-      _renderStartOfLink(context, isVertical);
+      renderStartOfLink(context, isVertical);
       
       ResponseWriter writer = context.getResponseWriter();
       
@@ -206,7 +208,9 @@
         char[] chars = new char[1];
         chars[0] = XhtmlConstants.NBSP_CHAR;
 
-        for(int i = 0; i < renderedCount * _INDENT_SPACES; i++)
+        int indents = separatorOnNewRow ? renderedCount - 1 : renderedCount;
+        int indentSpaces = indents * getNumberOfIndentSpaces(arc);
+        for(int i = 0; i < indentSpaces; i++)
         {
           writer.writeText(chars, 0, 1);
         }
@@ -218,9 +222,14 @@
         writer.writeAttribute(XhtmlConstants.DIR_ATTRIBUTE_VALUE, "rtl", null);
       }
       
+      if (!isFirstChild && (isVertical && separatorOnNewRow) )
+      {
+        OutputUtils.renderIcon(context, arc, separatorIcon, "", null );
+      }
+
       renderLink(context, arc, child, renderedCount, isLastChild);
 
-      if (!isLastChild)
+      if (!isLastChild && (!isVertical || !separatorOnNewRow) )
       {
         OutputUtils.renderIcon(context, arc, separatorIcon, "", null );
       }      
@@ -230,7 +239,7 @@
          writer.endElement(XhtmlConstants.SPAN_ELEMENT);
       }
       
-      _renderEndOfLink(context, isVertical);                  
+      renderEndOfLink(context, isVertical);
       
     }
   }
@@ -317,7 +326,7 @@
    * @todo - not rendering style elements - see breadcrumbsrenderer
    * for explanation, do we still need this code?
    */
-  private void _renderStartOfLink(
+  protected final void renderStartOfLink(
     FacesContext        context,
     boolean             isVertical) throws IOException
   {
@@ -338,7 +347,7 @@
   //
   // Renders everything that goes after the link
   //
-  private void _renderEndOfLink(
+  protected final void renderEndOfLink(
     FacesContext        context,
     boolean             isVertical
     ) throws IOException
@@ -394,6 +403,40 @@
   {
     String orientation = getOrientation(bean);
     return XhtmlConstants.ORIENTATION_VERTICAL.equals(orientation);
+  }
+
+  protected boolean shouldRenderSeparatorOnNewLineWhenVertical(
+    RenderingContext arc
+  )
+  {
+    Object propValue = arc.getSkin().getProperty(
+                                  SkinProperties.AF_BREAD_CRUMBS_SEPARATOR_ON_NEW_LINE);
+    return Boolean.TRUE.equals(propValue) || "true".equals(propValue);
+  }
+
+  protected int getNumberOfIndentSpaces(
+      RenderingContext arc
+  )
+  {
+    Object propValue = arc.getSkin().getProperty(
+                                      SkinProperties.AF_BREAD_CRUMBS_INDENT_SPACES);
+
+    int intValue = _INDENT_SPACES;
+    if (propValue != null) {
+      if (propValue instanceof String) {
+        try
+        {
+          intValue = Integer.valueOf((String) propValue);
+        }
+        catch (Exception e) {}
+      }
+      if (propValue instanceof Integer)
+        intValue = (Integer) propValue;
+      if (intValue < 0)
+        intValue = _INDENT_SPACES;
+    }
+
+    return intValue;
   }
 
 

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SkinProperties.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SkinProperties.java?rev=642777&r1=642776&r2=642777&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SkinProperties.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SkinProperties.java Sun Mar 30 10:09:38 2008
@@ -33,6 +33,10 @@
   // FIXME: Name inconsistency, should be AF_NAVIGATION_PATH
   public static final String AF_NAVIGATIONPATH_SHOW_LAST_ITEM_PROPERTY_KEY =
     "af|breadCrumbs-tr-show-last-item";
+  public static final String AF_BREAD_CRUMBS_SEPARATOR_ON_NEW_LINE =
+    "af|breadCrumbs-tr-separator-on-new-line";
+  public static final String AF_BREAD_CRUMBS_INDENT_SPACES = 
+    "af|breadCrumbs-tr-indent-spaces";
   // FIXME: Name inconsistency, should be AF_PANEL_HEADER
   public static final String AF_PANELHEADER_INDENT_CONTENT = 
     "af|panelHeader-tr-indent-content";