You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/08/16 16:15:22 UTC

svn commit: r985949 - in /myfaces/tobago/trunk: ./ tobago-example/tobago-example-demo/src/main/webapp/reference/tree/ tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ tobago-theme/to...

Author: lofwyr
Date: Mon Aug 16 14:15:22 2010
New Revision: 985949

URL: http://svn.apache.org/viewvc?rev=985949&view=rev
Log:
TOBAGO-377: new tree
 - defining on click handlers for the correct elements (for toggle and select and command)

Modified:
    myfaces/tobago/trunk/pom.xml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/tree/tree-select.jsp
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIconRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeSelectRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js

Modified: myfaces/tobago/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/pom.xml?rev=985949&r1=985948&r2=985949&view=diff
==============================================================================
--- myfaces/tobago/trunk/pom.xml (original)
+++ myfaces/tobago/trunk/pom.xml Mon Aug 16 14:15:22 2010
@@ -1698,8 +1698,8 @@
   </contributors>
 
   <properties>
-    <myfaces11.version>1.1.7</myfaces11.version>
-    <myfaces12.version>1.2.8</myfaces12.version>
+    <myfaces11.version>1.1.8</myfaces11.version>
+    <myfaces12.version>1.2.9</myfaces12.version>
     <myfaces20.version>2.0.0</myfaces20.version>
     <mojarra11.version>1.1_02</mojarra11.version>
     <mojarra12.version>1.2_14</mojarra12.version>

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/tree/tree-select.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/tree/tree-select.jsp?rev=985949&r1=985948&r2=985949&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/tree/tree-select.jsp (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/tree/tree-select.jsp Mon Aug 16 14:15:22 2010
@@ -31,7 +31,8 @@
         <tc:treeNode id="template" expanded="true">
           <tc:treeIndent/>
           <tc:treeIcon/>
-          <tc:treeSelect value="#{node.userObject.selected}"/>
+          <tc:treeSelect value="#{node.userObject.selected}" label="select"/>
+          <tc:treeLabel value="toggle" rendered="#{not node.leaf}"/>
           <tc:treeCommand label="#{node.userObject.name}" action="#{node.userObject.action}"/>
         </tc:treeNode>
       </tc:treeData>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIconRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIconRenderer.java?rev=985949&r1=985948&r2=985949&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIconRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIconRenderer.java Mon Aug 16 14:15:22 2010
@@ -91,6 +91,8 @@ public class TreeIconRenderer extends La
     if (folder) {
       writer.writeAttribute(HtmlAttributes.SRCOPEN, openSource, true);
       writer.writeAttribute(HtmlAttributes.SRCCLOSE, closedSource, true);
+
+      writer.writeAttribute("onclick", "tobagoTreeNodeToggle(this)", false);
     }
     writer.writeAttribute(HtmlAttributes.ALT, "", false);
     writer.endElement(HtmlElements.IMG);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java?rev=985949&r1=985948&r2=985949&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java Mon Aug 16 14:15:22 2010
@@ -127,6 +127,8 @@ public class TreeIndentRenderer extends 
       if (folder) {
         writer.writeAttribute(HtmlAttributes.SRCOPEN, srcOpen, true);
         writer.writeAttribute(HtmlAttributes.SRCCLOSE, srcClose, true);
+
+        writer.writeAttribute("onclick", "tobagoTreeNodeToggle(this)", false);
       }
       writer.writeAttribute(HtmlAttributes.ALT, "", false);
       writer.endElement(HtmlElements.IMG);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java?rev=985949&r1=985948&r2=985949&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java Mon Aug 16 14:15:22 2010
@@ -18,11 +18,13 @@ package org.apache.myfaces.tobago.render
  */
 
 import org.apache.myfaces.tobago.component.UITreeLabel;
+import org.apache.myfaces.tobago.component.UITreeNode;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.Style;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,13 +39,19 @@ public class TreeLabelRenderer extends L
 
   public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
 
-    UITreeLabel label = (UITreeLabel) component;
-    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+    final UITreeLabel label = (UITreeLabel) component;
+    final UITreeNode node = ComponentUtils.findAncestor(label, UITreeNode.class);
+    final boolean folder = node.isFolder();
+
+    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
     writer.startElement(HtmlElements.LABEL, label);
     writer.writeClassAttribute(Classes.create(label));
     writer.writeStyleAttribute(createStyle(facesContext, label));
     HtmlRendererUtils.renderTip(label, writer);
+    if (folder) {
+      writer.writeAttribute("onclick", "tobagoTreeNodeToggle(this)", false);
+    }
 
     if (label.getValue() != null) {
       writer.writeText((String) label.getValue());

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?rev=985949&r1=985948&r2=985949&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java Mon Aug 16 14:15:22 2010
@@ -153,10 +153,6 @@ public class TreeNodeRenderer extends La
       writer.writeStyleAttribute(widthString);
 
       if (folder) {
-        writer.writeAttribute("onclick", "tobagoTreeNodeToggle(this)", false);
-      }
-
-      if (folder) {
         encodeExpandedHidden(writer, node, id, expanded);
       }
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeSelectRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeSelectRenderer.java?rev=985949&r1=985948&r2=985949&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeSelectRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeSelectRenderer.java Mon Aug 16 14:15:22 2010
@@ -18,6 +18,7 @@ package org.apache.myfaces.tobago.render
  */
 
 import org.apache.myfaces.tobago.component.UITreeSelect;
+import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
@@ -40,7 +41,7 @@ public class TreeSelectRenderer extends 
     final boolean checked = "true".equals(currentValue);
 
     TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-    
+
     writer.startElement(HtmlElements.INPUT, null);
     writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.CHECKBOX, false);
     writer.writeAttribute(HtmlAttributes.VALUE, "true", false);
@@ -48,6 +49,14 @@ public class TreeSelectRenderer extends 
     writer.writeIdAttribute(id);
     writer.writeAttribute(HtmlAttributes.CHECKED, checked);
     writer.endElement(HtmlElements.INPUT);
+
+    // label
+    writer.startElement(HtmlElements.LABEL, null);
+    writer.writeClassAttribute(Classes.create(select, "label"));
+    HtmlRendererUtils.renderTip(select, writer);
+    writer.writeAttribute(HtmlAttributes.FOR, id, false);
+    writer.writeText(select.getLabel());
+    writer.endElement(HtmlElements.LABEL);
   }
 
   @Override

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js?rev=985949&r1=985948&r2=985949&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js Mon Aug 16 14:15:22 2010
@@ -74,8 +74,8 @@ Tobago.Tree.storeMarker = function(node,
 };
 
 function tobagoTreeNodeToggle(element) {
-  var node = jQuery(element);
-  var content = jQuery(Tobago.escapeClientId(element.id + Tobago.SUB_COMPONENT_SEP + "content"));
+  var node = jQuery(element).closest(".tobago-treeNode");
+  var content = jQuery(Tobago.escapeClientId(node.attr("id") + Tobago.SUB_COMPONENT_SEP + "content"));
   var expanded = node.find(".tobago-treeMenuNode-expanded, .tobago-treeNode-expanded");
   var toggle = node.find(".tobago-treeMenuNode-toggle, .tobago-treeNode-toggle");
   if (content.css("display") == "none") {