myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r918593 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/taglib/component/ example/demo/src/main/webapp/ example/demo/src/main/webapp/overview/ example/demo/src...
Date Wed, 03 Mar 2010 17:25:35 GMT
Author: lofwyr
Date: Wed Mar  3 17:25:34 2010
New Revision: 918593

URL: http://svn.apache.org/viewvc?rev=918593&view=rev
Log:
TOBAGO-857: New tag <tc:treeMenu> instead of <tc:tree mode="menu">

Added:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeMenuTagDeclaration.java
      - copied, changed from r918393, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java
      - copied, changed from r917992, myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java
    myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp
    myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.xhtml
    myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.xhtml
    myfaces/tobago/trunk/example/demo/src/main/webapp/reference/tree/tree-menu.jsp
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java
Wed Mar  3 17:25:34 2010
@@ -43,7 +43,7 @@
   private MixedTreeModel model;
 
   public UIComponent getRoot() {
-    // find the UITreeNode in the childen.
+    // find the UITreeNode in the children.
     for (UIComponent child : (List<UIComponent>) getChildren()) {
       if (child instanceof AbstractUITreeNode) {
         return child;
@@ -55,6 +55,7 @@
     return null;
   }
 
+  @Override
   public void encodeEnd(FacesContext facesContext) throws IOException {
     model = new MixedTreeModel();
     for (Object child : getChildren()) {
@@ -75,6 +76,7 @@
     return model;
   }
 
+  @Override
   public boolean getRendersChildren() {
     return true;
   }
@@ -88,6 +90,7 @@
         || selectable.equals("sibling") || selectable.equals("siblingLeafOnly"));
   }
 
+  @Override
   public void processDecodes(FacesContext facesContext) {
 
     if (!isRendered()) {
@@ -108,6 +111,7 @@
     }
   }
 
+  @Override
   public void validate(FacesContext context) {
 
 // todo: validate must be written new, without TreeState
@@ -153,10 +157,15 @@
     }
   }
 
+  @Override
   public void updateModel(FacesContext facesContext) {
     // nothing to update for tree's
     // TODO: updating the model here and *NOT* in the decode phase
   }
 
   public abstract Object getState();
+
+  public boolean isShowRoot() {
+    return false;
+  }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
Wed Mar  3 17:25:34 2010
@@ -73,6 +73,7 @@
   public static final String TREE = "Tree";
   public static final String TREE_DATA = "TreeData";
   public static final String TREE_LISTBOX = "TreeListbox";
+  public static final String TREE_MENU = "TreeMenu";
   public static final String TREE_NODE = "TreeNode";
   public static final String SHEET = "Sheet";
   public static final String VERBATIM = "Verbatim";

Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeMenuTagDeclaration.java
(from r918393, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeMenuTagDeclaration.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeMenuTagDeclaration.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java&r1=918393&r2=918593&rev=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeMenuTagDeclaration.java
Wed Mar  3 17:25:34 2010
@@ -31,63 +31,27 @@
 import org.apache.myfaces.tobago.taglib.decl.IsRequired;
 
 /**
- * A tree which has to variants: as menu or normal tree.
+ * A tree which will be displayed like a flat menu.
+ * This menu is often used for navigation on the left side of an application.
  */
-@Tag(name = "tree")
+@Tag(name = "treeMenu")
 @BodyContentDescription(anyTagOf = "<tc:treeNode>|<tc:treeData>")
 @UIComponentTag(
-    uiComponent = "org.apache.myfaces.tobago.component.UITree",
+    uiComponent = "org.apache.myfaces.tobago.component.UITreeMenu",
     uiComponentBaseClass = "org.apache.myfaces.tobago.component.AbstractUITree",
-    rendererType = RendererTypes.TREE,
+    rendererType = RendererTypes.TREE_MENU,
     allowedChildComponenents = {
         "org.apache.myfaces.tobago.TreeNode",
         "org.apache.myfaces.tobago.TreeData"
         })
-public interface TreeTagDeclaration
+public interface TreeMenuTagDeclaration
     extends HasIdBindingAndRendered, HasTreeNodeValue, IsRequired, IsGridLayoutComponent,
HasMarkup {
 
-  /**
-   * Flag indicating whether or not this component should be render selectable items.
-   * Possible values are:
-   * <ul>
-   * <li><strong>multi</strong> : a multi section tree is rendered</li>
-   * <li><strong>single</strong> : a single section tree is rendered</li>
-   * <li><strong>multiLeafOnly</strong> : a multi section tree is rendered,
-   * only Leaf's are selectable</li>
-   * <li><strong>singleLeafOnly</strong> : a single section tree is rendered,
-   * only Leaf's are selectable</li>
-   * </ul>
-   * For any other value or if this attribute is omitted the items are not selectable.
-   */
-  @TagAttribute
-  @UIComponentTagAttribute(defaultValue = "off",
-      allowedValues = {"multi", "single", "multiLeafOnly", "singleLeafOnly", "off"})
-  void setSelectable(String selectable);
-
-  @TagAttribute
-  @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
-  void setShowRootJunction(String showRootJunction);
-
-  @TagAttribute
-  @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
-  void setShowIcons(String showIcons);
-
-  @TagAttribute
-  @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
-  void setShowJunctions(String showJunctions);
-
   @TagAttribute
   @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
   void setShowRoot(String showRoot);
   
   /**
-   * Display option: Normal tree or menu.
-   */
-  @TagAttribute
-  @UIComponentTagAttribute(defaultValue = "tree", allowedValues = {"tree", "menu"})
-  void setMode(String mode);
-
-  /**
    *
    * <strong>ValueBindingExpression</strong> pointing to a object to save the
    * component's state.

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java
Wed Mar  3 17:25:34 2010
@@ -37,7 +37,7 @@
 
 /**
  * Creates a tree node. This component represents a single node inside a tree structure.
- * For interating over tree node use tc:treeData
+ * For interating over tree node use tc:treeData.
  */
 @SuppressWarnings("ALL")
 @Tag(name = "treeNode")

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeTagDeclaration.java
Wed Mar  3 17:25:34 2010
@@ -31,7 +31,8 @@
 import org.apache.myfaces.tobago.taglib.decl.IsRequired;
 
 /**
- * A tree which has to variants: as menu or normal tree.
+ * A tree with classical look. 
+ * Usually used with icons and junction lines to open folder, etc.
  */
 @Tag(name = "tree")
 @BodyContentDescription(anyTagOf = "<tc:treeNode>|<tc:treeData>")
@@ -81,13 +82,6 @@
   void setShowRoot(String showRoot);
   
   /**
-   * Display option: Normal tree or menu.
-   */
-  @TagAttribute
-  @UIComponentTagAttribute(defaultValue = "tree", allowedValues = {"tree", "menu"})
-  void setMode(String mode);
-
-  /**
    *
    * <strong>ValueBindingExpression</strong> pointing to a object to save the
    * component's state.

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp Wed Mar  3 17:25:34 2010
@@ -23,7 +23,7 @@
       <tc:gridLayout rows="*"/>
     </f:facet>
 
-    <tc:tree id="nav" mode="menu" showRoot="true" state="#{navigation.state}">
+    <tc:treeMenu id="nav" state="#{navigation.state}">
       <tc:treeData value="#{navigation.tree}" var="node" id="data">
         <tc:treeNode label="#{node.userObject.title}"
                      action="#{node.userObject.action}"
@@ -31,7 +31,7 @@
                      value="#{node}"
                      expanded="true"/>
       </tc:treeData>
-    </tc:tree>
+    </tc:treeMenu>
 
   </tc:panel>
 </f:subview>

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.xhtml?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.xhtml (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.xhtml Wed Mar  3 17:25:34
2010
@@ -28,7 +28,7 @@
       <tc:gridLayout rows="*"/>
     </f:facet>
 
-    <tc:tree id="nav" mode="menu" showRoot="true" state="#{navigation.state}">
+    <tc:treeMenu id="nav" state="#{navigation.state}">
       <tc:treeData value="#{navigation.tree}" var="node" id="data">
         <tc:treeNode label="#{node.userObject.title}"
                      action="#{node.userObject.action}"
@@ -36,7 +36,7 @@
                      value="#{node}"
                      expanded="true"/>
       </tc:treeData>
-    </tc:tree>
+    </tc:treeMenu>
 
   </tc:panel>
 </f:subview>

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.xhtml?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.xhtml (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.xhtml Wed Mar  3 17:25:34
2010
@@ -93,6 +93,33 @@
           </tc:panel>
 
         </tc:tab>
+        <tc:tab label="#{overviewBundle.treeLabel} as Menu"><!-- todo i18n -->
+          <f:facet name="layout">
+            <tc:gridLayout columns="2*;1*"/>
+          </f:facet>
+
+          <tc:treeMenu id="treeMenu" showRoot="#{demo.showRoot}">
+            <tc:treeData value="#{demo.tree}" var="node" id="data">
+              <tc:treeNode label="#{node.userObject.name}"
+                           id="template"
+                           expanded="true"
+                           value="#{node}"
+                           image="image/feather.png"/>
+            </tc:treeData>
+          </tc:treeMenu>
+
+          <tc:panel>
+            <f:facet name="layout">
+              <tc:gridLayout rows="fixed;*;fixed"/>
+            </f:facet>
+
+            <tc:selectBooleanCheckbox label="#{overviewBundle.treeShowRoot}"
+                                      value="#{demo.showRoot}"/>
+            <tc:cell/>
+            <tc:button action="redisplay" label="#{overviewBundle.submit}"/>
+          </tc:panel>
+
+        </tc:tab>
         <tc:tab label="#{overviewBundle.treeListboxLabel} (todo)">
 
           <tc:treeListbox id="tree">

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/reference/tree/tree-menu.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/reference/tree/tree-menu.jsp?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/reference/tree/tree-menu.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/reference/tree/tree-menu.jsp Wed Mar
 3 17:25:34 2010
@@ -21,28 +21,22 @@
 <f:view>
   <tc:loadBundle basename="demo" var="bundle"/>
 
-  <tc:page label="Sandbox - Tree" id="page"
-           width="500px" height="1000px">
+  <tc:page label="Sandbox - Tree" id="page" width="500px" height="1000px">
     <f:facet name="layout">
       <tc:gridLayout margin="10px" rows="*;*;*"/>
     </f:facet>
 
-    <tc:tree id="menu"
-              showIcons="false"
-              showJunctions="false"
-              showRootJunction="false"
-              showRoot="true"
-              mode="menu">
+    <tc:treeMenu id="menu" showRoot="true">
       <tc:treeNode label="Root" id="root" expanded="true">
         <tc:treeData value="#{treeController.tree}" var="node" id="data">
           <tc:treeNode label="#{node.userObject.name}"
-                        id="template"
-                        expanded="#{node.userObject.expanded}"
-                        markup="#{node.userObject.markup}"
-                        tip="#{node.userObject.tip}"
-                        action="#{node.userObject.action}"
-                        disabled="#{node.userObject.disabled}"
-                        value="#{node}"/>
+                       id="template"
+                       expanded="#{node.userObject.expanded}"
+                       markup="#{node.userObject.markup}"
+                       tip="#{node.userObject.tip}"
+                       action="#{node.userObject.action}"
+                       disabled="#{node.userObject.disabled}"
+                       value="#{node}"/>
         </tc:treeData>
         <tc:treeNode label="2 Action 1" action="#{treeController.action1}" id="action1"/>
         <tc:treeNode label="3 Action 2" action="#{treeController.action2}" id="action2"/>
@@ -55,37 +49,37 @@
         <tc:treeNode label="5 Link" link="http://myfaces.apache.org/tobago/" id="link"
tip="Subnode Link"/>
         <tc:treeNode label="6 Target" action="#{treeController.action2}" target="Target
Window"/>
       </tc:treeNode>
-    </tc:tree>
+    </tc:treeMenu>
 
-    <tc:tree mode="menu">
+    <tc:treeMenu>
       <tc:treeData value="#{treeController.tree}" var="node" id="data">
         <tc:treeNode label="#{node.userObject.name}"
-                      id="template"
-                      expanded="#{node.userObject.expanded}"
-                      markup="#{node.userObject.markup}"
-                      tip="#{node.userObject.tip}"
-                      action="#{node.userObject.action}"
-                      disabled="#{node.userObject.disabled}"
-                      value="#{node}"/>
+                     id="template"
+                     expanded="#{node.userObject.expanded}"
+                     markup="#{node.userObject.markup}"
+                     tip="#{node.userObject.tip}"
+                     action="#{node.userObject.action}"
+                     disabled="#{node.userObject.disabled}"
+                     value="#{node}"/>
       </tc:treeData>
-    </tc:tree>
+    </tc:treeMenu>
 
-    <tc:tree mode="menu">
+    <tc:treeMenu>
       <tc:treeNode label="Root" expanded="true">
-        <tc:treeNode label="2 Action 1" />
-        <tc:treeNode label="3 Action 2" />
-        <tc:treeNode label="4 Action 3" >
-          <tc:treeNode label="4.1 On Click 1" onclick="alert('On Click 1');" />
-          <tc:treeNode label="4.2 On Click 2" onclick="alert('On Click 2');" >
-            <tc:treeNode label="4.2.1 On Click 3" onclick="alert('On Click 3');" />
+        <tc:treeNode label="2 Action 1"/>
+        <tc:treeNode label="3 Action 2"/>
+        <tc:treeNode label="4 Action 3">
+          <tc:treeNode label="4.1 On Click 1" onclick="alert('On Click 1');"/>
+          <tc:treeNode label="4.2 On Click 2" onclick="alert('On Click 2');">
+            <tc:treeNode label="4.2.1 On Click 3" onclick="alert('On Click 3');"/>
           </tc:treeNode>
         </tc:treeNode>
         <tc:treeNode label="5 Link" link="http://myfaces.apache.org/tobago/" tip="Subnode
Link"/>
         <tc:treeNode label="6 Target" target="Target Window"/>
       </tc:treeNode>
-    </tc:tree>
+    </tc:treeMenu>
 
-    <tc:cell />
+    <tc:cell/>
 
   </tc:page>
 </f:view>

Copied: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java
(from r917992, myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java?p2=myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java&p1=myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java&r1=917992&r2=918593&rev=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
(original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java
Wed Mar  3 17:25:34 2010
@@ -17,113 +17,6 @@
  * limitations under the License.
  */
 
-import org.apache.myfaces.tobago.component.AbstractUITree;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
-import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
-import org.apache.myfaces.tobago.renderkit.css.Style;
-import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
-import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
-import org.apache.myfaces.tobago.util.ComponentUtils;
-import org.apache.myfaces.tobago.util.FastStringWriter;
-import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+public class TreeMenuRenderer extends TreeRenderer {
 
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-
-public class TreeRenderer extends LayoutComponentRendererBase {
-
-  private static final String SCRIPT = "script/tobago-tree.js";
-
-  public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException
{
-    super.prepareRender(facesContext, component);
-    if (facesContext instanceof TobagoFacesContext) {
-      // todo: this may be removed, it is twice on the page 1. in the header 2. in the ScriptLoader
-      ((TobagoFacesContext) facesContext).getScriptFiles().add(SCRIPT);
-    }
-  }
-
-  @Override
-  public void decode(FacesContext facesContext, UIComponent component) {
-    if (ComponentUtils.isOutputOnly(component)) {
-      return;
-    }
-
-    AbstractUITree tree = (AbstractUITree) component;
-    tree.setValid(true);
-  }
-
-  public static boolean isSelectable(AbstractUITree tree) {
-    return tree.isSelectableTree();
-  }
-
-  @Override
-  public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
-    // will be rendered in encodeEnd()
-  }
-
-  @Override
-  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
{
-
-    AbstractUITree tree = (AbstractUITree) component;
-
-    String clientId = tree.getClientId(facesContext);
-    UIComponent root = tree.getRoot();
-
-    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-
-    writer.startElement(HtmlConstants.DIV, tree);
-    writer.writeClassAttribute();
-    Style style = new Style(facesContext, tree);
-    writer.writeStyleAttribute(style);
-
-    writer.startElement(HtmlConstants.INPUT, tree);
-    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
-    writer.writeNameAttribute(clientId);
-    writer.writeIdAttribute(clientId);
-    writer.writeAttribute(HtmlAttributes.VALUE, ";", false);
-    writer.endElement(HtmlConstants.INPUT);
-
-    writer.startElement(HtmlConstants.INPUT, tree);
-    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
-    writer.writeNameAttribute(clientId + AbstractUITree.MARKER);
-    writer.writeIdAttribute(clientId + AbstractUITree.MARKER);
-    writer.writeAttribute(HtmlAttributes.VALUE, "", false);
-    writer.endElement(HtmlConstants.INPUT);
-
-    if (isSelectable(tree)) {
-      writer.startElement(HtmlConstants.INPUT, tree);
-      writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
-      writer.writeNameAttribute(clientId + AbstractUITree.SELECT_STATE);
-      writer.writeIdAttribute(clientId + AbstractUITree.SELECT_STATE);
-      writer.writeAttribute(HtmlAttributes.VALUE, ";", false);
-      writer.endElement(HtmlConstants.INPUT);
-    }
-
-    HtmlRendererUtils.writeScriptLoader(facesContext, SCRIPT);
-
-    RenderUtil.encode(facesContext, root);
-
-    writer.endElement(HtmlConstants.DIV);
-  }
-
-  // XXX can be removed?
-  protected String getNodesAsJavascript(FacesContext facesContext, UIComponent root) throws
IOException {
-    ResponseWriter writer = facesContext.getResponseWriter();
-    FastStringWriter stringWriter = new FastStringWriter();
-    facesContext.setResponseWriter(writer.cloneWithWriter(stringWriter));
-    RenderUtil.encode(facesContext, root);
-    facesContext.setResponseWriter(writer);
-    return stringWriter.toString();
-  }
-
-  // XXX can be removed?
-  protected String nodeStateId(FacesContext facesContext, UIComponent node) {
-    String clientId = node.getClientId(facesContext);
-    int last = clientId.lastIndexOf(':') + 1;
-    return clientId.substring(last);
-  }
 }

Modified: myfaces/tobago/trunk/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/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?rev=918593&r1=918592&r2=918593&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
(original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
Wed Mar  3 17:25:34 2010
@@ -26,6 +26,7 @@
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.UITree;
 import org.apache.myfaces.tobago.component.UITreeListbox;
+import org.apache.myfaces.tobago.component.UITreeMenu;
 import org.apache.myfaces.tobago.component.UITreeNode;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.context.ResourceUtils;
@@ -110,8 +111,8 @@
   public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
{
     UITreeNode node = (UITreeNode) component;
     AbstractUITree tree = node.findTree();
-    if (tree instanceof UITree) {
-      encodeBeginMenuAndNormal(facesContext, node, (UITree)tree);
+    if (tree instanceof UITree || tree instanceof UITreeMenu) {
+      encodeBeginMenuAndNormal(facesContext, node, tree, tree instanceof UITreeMenu);
     } else { // if (tree instanceof UITreeListbox)
       encodeBeginListbox(facesContext, node, (UITreeListbox)tree);
     }
@@ -183,7 +184,8 @@
     }
   }
 
-  public void encodeBeginMenuAndNormal(FacesContext facesContext, UITreeNode node, UITree
tree) throws IOException {
+  public void encodeBeginMenuAndNormal(FacesContext facesContext, UITreeNode node, AbstractUITree
tree, boolean isMenu) 
+      throws IOException {
 
     String treeId = tree.getClientId(facesContext);
     boolean folder = node.isFolder();
@@ -194,10 +196,14 @@
     List<Boolean> junctions = node.getJunctions();
 
     boolean expanded = isExpanded(tree, node);
-    boolean menuMode = tree.getMode().equals("menu");
-    boolean showIcons = tree.isShowIcons();
-    boolean showJunctions = tree.isShowJunctions();
-    boolean showRootJunction = tree.isShowRootJunction();
+    boolean showIcons = false;
+    boolean showJunctions = false;
+    boolean showRootJunction = false;
+    if (tree instanceof UITree) {
+      showIcons = ((UITree)tree).isShowIcons();
+      showJunctions = ((UITree)tree).isShowJunctions();
+      showRootJunction = ((UITree)tree).isShowRootJunction();
+    }
     boolean showRoot = tree.isShowRoot();
 
     if (!showRoot && junctions.size() > 0) {
@@ -249,7 +255,7 @@
       // div class (css)
       StyleClasses styleClasses = StyleClasses.ensureStyleClasses(node);
       styleClasses.updateClassAttributeAndMarkup(node, "treeNode");
-      if ("menu".equals(tree.getMode())) {
+      if (isMenu) {
         styleClasses.addClass("treeNode", "menu");
         if (marked) {
           styleClasses.addClass("treeNode", "marker");
@@ -272,11 +278,11 @@
         encodeExpandedHidden(writer, node, id, expanded);
       }
 
-      if (folder && menuMode) {
+      if (folder && isMenu) {
         encodeMenuIcon(facesContext, writer, treeId, id, expanded, node);
       }
 
-      encodeIndent(facesContext, writer, menuMode, junctions);
+      encodeIndent(facesContext, writer, isMenu, junctions);
 
       encodeTreeJunction(facesContext, writer, id, treeId, showJunctions, showRootJunction,
showRoot, expanded,
           folder, depth, hasNextSibling, openSource, closedSource);
@@ -474,7 +480,7 @@
   public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
{
     UITreeNode node = (UITreeNode) component;
     AbstractUITree tree = node.findTree();
-    if (tree instanceof UITree) {
+    if (tree instanceof UITree || tree instanceof UITreeMenu) {
       encodeEndMenuAndNormal(facesContext, node);
     } else { // if (tree instanceof UITreeListbox)
       encodeEndListbox(facesContext, node);



Mime
View raw message