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 2008/10/30 09:54:43 UTC

svn commit: r709123 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/context/ core/src/test/java/org/apache/myfaces/tobago/context/ example/demo/src/main/webapp/image/ example/demo/src/main/webapp/overview/ theme/richmond/src/ma...

Author: lofwyr
Date: Thu Oct 30 01:54:42 2008
New Revision: 709123

URL: http://svn.apache.org/viewvc?rev=709123&view=rev
Log:
TOBAGO-377: Tree
TOBAGO-718: Application Icons with naming fallback schema

Added:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java   (contents, props changed)
      - copied, changed from r708103, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java
    myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/context/
    myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/context/ResourceUtilsUnitTest.java
    myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-leaf.png   (contents, props changed)
      - copied, changed from r708103, myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather.png
    myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-open.png   (with props)
    myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-leaf.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/new.gif
    myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-open.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/openfoldericon.gif
    myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/foldericon.gif
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-leaf.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/new.gif
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-open.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/openfoldericon.gif
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/foldericon.gif
    myfaces/tobago/trunk/theme/scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/
    myfaces/tobago/trunk/theme/scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-leaf.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/new.gif
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-open.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/openfoldericon.gif
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon.gif   (props changed)
      - copied unchanged from r708103, myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/foldericon.gif
Removed:
    myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather.png
    myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/foldericon.gif
    myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/new.gif
    myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/openfoldericon.gif
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/foldericon.gif
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/new.gif
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/openfoldericon.gif
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/foldericon.gif
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/new.gif
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/openfoldericon.gif
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java
    myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.jsp
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
    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/context/ResourceManagerUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java?rev=709123&r1=709122&r2=709123&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java Thu Oct 30 01:54:42 2008
@@ -131,9 +131,7 @@
   }
 
   public static String getDisabledImageWithPath(FacesContext facesContext, String image) {
-    int dotIndex = image.lastIndexOf('.');
-    String name = image.substring(0, dotIndex);
-    String postfix = image.substring(dotIndex);
-    return getImageWithPath(facesContext, name + "Disabled" + postfix, true);
+    String filename = ResourceUtils.addPostfixToFilename(image, "Disabled");
+    return getImageWithPath(facesContext, filename, true);
   }
 }

Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java (from r708103, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java&r1=708103&r2=709123&rev=709123&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java Thu Oct 30 01:54:42 2008
@@ -17,123 +17,53 @@
  * limitations under the License.
  */
 
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import java.util.ArrayList;
-import java.util.List;
+public class ResourceUtils {
 
-public class ResourceManagerUtil {
-
-  private ResourceManagerUtil() {
-  }
-
-  public static String getProperty(
-      FacesContext facesContext, String bundle, String key) {
-    return ResourceManagerFactory.getResourceManager(facesContext)
-        .getProperty(facesContext.getViewRoot(), bundle, key);
-  }
-
-  public static String getPropertyNotNull(
-      FacesContext facesContext, String bundle, String key) {
-    UIViewRoot viewRoot = facesContext.getViewRoot();
-    String result = ResourceManagerFactory.getResourceManager(facesContext)
-        .getProperty(viewRoot, bundle, key);
-    if (result == null) {
-      return "???" + key + "???";
-    } else {
-      return result;
-    }
-  }
-
-  /**
-   * Searchs for an image and return it with the context path
-   */
-  public static String getImageWithPath(
-      FacesContext facesContext, String name) {
-    return facesContext.getExternalContext().getRequestContextPath()
-        + ResourceManagerFactory.getResourceManager(facesContext)
-        .getImage(facesContext.getViewRoot(), name);
-  }
-
-  public static String getBlankPage(FacesContext context) {
-    return context.getExternalContext().getRequestContextPath()
-        + "/org/apache/myfaces/tobago/renderkit/html/standard/blank.html";
-  }
-
-  /**
-   * Searchs for an image and return it with the context path
-   */
-  public static String getImageWithPath(
-      FacesContext facesContext, String name, boolean ignoreMissing) {
-    String image = ResourceManagerFactory.getResourceManager(facesContext)
-        .getImage(facesContext.getViewRoot(), name, ignoreMissing);
-    if (image == null) {
-      return null;
-    } else {
-      return facesContext.getExternalContext().getRequestContextPath() + image;
-    }
+  public static final char FOLDER_SEPARATOR = '/';
+  public static final char SEPARATOR = '-';
+  public static final char DOT = '.';
+
+  public static final String GIF = "gif";
+
+  public static String createString(String folder, String component, String name, String postfix, String extension) {
+    return new StringBuilder()
+        .append(folder)
+        .append(FOLDER_SEPARATOR)
+        .append(component)
+        .append(SEPARATOR)
+        .append(name)
+        .append(SEPARATOR)
+        .append(postfix)
+        .append(DOT)
+        .append(extension)
+        .toString();
+  }
+
+  public static String createString(String folder, String component, String name, String extension) {
+    return new StringBuilder()
+        .append(folder)
+        .append(FOLDER_SEPARATOR)
+        .append(component)
+        .append(SEPARATOR)
+        .append(name)
+        .append(DOT)
+        .append(extension)
+        .toString();
+  }
+
+  public static String addPostfixToFilename(String filename, String postfix) {
+    int dotIndex = filename.lastIndexOf('.');
+    String name = filename.substring(0, dotIndex);
+    String extension = filename.substring(dotIndex);
+    return new StringBuilder()
+        .append(name)
+        .append(SEPARATOR)
+        .append(postfix)
+        .append(extension)
+        .toString();
   }
 
-  public static List<String> getStyles(FacesContext facesContext, String name) {
-    UIViewRoot viewRoot = facesContext.getViewRoot();
-    String contextPath = facesContext.getExternalContext().getRequestContextPath();
-    String[] styles = ResourceManagerFactory.getResourceManager(facesContext).getStyles(viewRoot, name);
-    return addContextPath(styles, contextPath);
+  private ResourceUtils() {
   }
 
-  private static List<String> addContextPath(String[] strings, String contextPath) {
-    List<String> withContext = new ArrayList<String>(strings.length);
-    for (String string : strings) {
-      withContext.add(contextPath + string);
-    }
-    return withContext;
-  }
-
-  public static List<String> getScripts(FacesContext facesContext, String name) {
-    UIViewRoot viewRoot = facesContext.getViewRoot();
-    String contextPath = facesContext.getExternalContext().getRequestContextPath();
-    //if (name.startsWith("script/dojo/")) {
-    //  scripts = new String[] {"/" + ResourceServlet.DOJO_RESOURCE_PREFIX + name.substring("script/dojo/".length())};
-    //} else {
-    String[] scripts = ResourceManagerFactory.getResourceManager(facesContext)
-        .getScripts(viewRoot, name);
-    //}
-    return addContextPath(scripts, contextPath);
-  }
-
-  public static String getScriptsAsJSArray(FacesContext facesContext, String[] names) {
-    List<String> fileNames = new ArrayList<String>();
-    for (String name : names) {
-      fileNames.addAll(getScripts(facesContext, name));
-    }
-    return toJSArray(fileNames);
-  }
-
-  public static String getStylesAsJSArray(FacesContext facesContext, String[] names) {
-    List<String> fileNames = new ArrayList<String>();
-    for (String name : names) {
-      fileNames.addAll(getStyles(facesContext, name));
-    }
-    return toJSArray(fileNames);
-  }
-
-  public static String toJSArray(List<String> list) {
-    StringBuilder sb = new StringBuilder();
-    for (String name : list) {
-      if (sb.length() > 0) {
-        sb.append(", ");
-      }
-      sb.append('\'');
-      sb.append(name);
-      sb.append('\'');
-    }
-    return "[" + sb.toString() + "]";
-  }
-
-  public static String getDisabledImageWithPath(FacesContext facesContext, String image) {
-    int dotIndex = image.lastIndexOf('.');
-    String name = image.substring(0, dotIndex);
-    String postfix = image.substring(dotIndex);
-    return getImageWithPath(facesContext, name + "Disabled" + postfix, true);
-  }
 }

Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/context/ResourceUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/context/ResourceUtilsUnitTest.java?rev=709123&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/context/ResourceUtilsUnitTest.java (added)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/context/ResourceUtilsUnitTest.java Thu Oct 30 01:54:42 2008
@@ -0,0 +1,33 @@
+package org.apache.myfaces.tobago.context;
+
+import junit.framework.TestCase;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class ResourceUtilsUnitTest extends TestCase {
+
+  public void testCreateString() {
+    assertEquals("folder/treeNode-icon-open.gif",
+        ResourceUtils.createString("folder", "treeNode", "icon", "open", "gif"));
+  }
+
+  public void testCreateString2() {
+        assertEquals("folder/treeNode-icon.gif",
+        ResourceUtils.createString("folder", "treeNode", "icon", "gif"));
+  }
+}

Copied: myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-leaf.png (from r708103, myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather.png)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-leaf.png?p2=myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-leaf.png&p1=myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather.png&r1=708103&r2=709123&rev=709123&view=diff
==============================================================================
Binary files - no diff available.

Propchange: myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-leaf.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-open.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-open.png?rev=709123&view=auto
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/trunk/example/demo/src/main/webapp/image/feather-open.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.jsp?rev=709123&r1=709122&r2=709123&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/overview/tree.jsp Thu Oct 30 01:54:42 2008
@@ -26,7 +26,7 @@
   <tc:gridLayout rows="9*;16*"/>
 </f:facet>
 
-<tc:out escape="false" value="#{overviewBundle.tree_text}"/>
+<tc:out escape="false" value="(UNDER CONSTRUCTION) #{overviewBundle.tree_text}"/>
 
 <%-- column --%>
 

Propchange: myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-leaf.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-open.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

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=709123&r1=709122&r2=709123&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 Thu Oct 30 01:54:42 2008
@@ -32,6 +32,7 @@
 import org.apache.myfaces.tobago.component.UITree;
 import org.apache.myfaces.tobago.component.UITreeNode;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
+import org.apache.myfaces.tobago.context.ResourceUtils;
 import org.apache.myfaces.tobago.model.MixedTreeModel;
 import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
@@ -60,6 +61,13 @@
 
   private static final Log LOG = LogFactory.getLog(TreeNodeRenderer.class);
 
+  protected static final String OPEN_FOLDER
+      = ResourceUtils.createString("image", "treeNode", "icon", "open", ResourceUtils.GIF);
+  protected static final String CLOSED_FOLDER
+      = ResourceUtils.createString("image", "treeNode", "icon", ResourceUtils.GIF);
+  protected static final String LEAF
+      = ResourceUtils.createString("image", "treeNode", "icon", "leaf", ResourceUtils.GIF);
+
   @Override
   public void decode(FacesContext facesContext, UIComponent component) {
 
@@ -131,12 +139,39 @@
     boolean isRoot = mixedModel.isRoot();
     boolean hasNextSibling = mixedModel.hasCurrentNodeNextSibling();
     List<Boolean> junctions = mixedModel.getJunctions();
-    String image = ComponentUtil.getStringAttribute(node, "image");
 
     if (!showRoot && junctions.size() > 0) {
       junctions.remove(0);
     }
 
+    String source;
+    String openSource = null;
+    String closedSource;
+
+    String image = ComponentUtil.getStringAttribute(node, "image");
+    if (image != null) { // application image
+      closedSource = ResourceManagerUtil.getImageWithPath(facesContext, image);
+    } else { // theme image
+      closedSource = ResourceManagerUtil.getImageWithPath(facesContext, CLOSED_FOLDER);
+    }
+    if (folder) {
+      if (image != null) { // application image
+        openSource = ResourceManagerUtil.getImageWithPath(facesContext, ResourceUtils.addPostfixToFilename(image, "open"), true);
+      } else { // theme image
+        openSource = ResourceManagerUtil.getImageWithPath(facesContext, OPEN_FOLDER);
+      }
+      source = expanded ? openSource : closedSource;
+    } else {
+      if (image != null) { // application image
+        source = ResourceManagerUtil.getImageWithPath(facesContext, ResourceUtils.addPostfixToFilename(image, "leaf"), true);
+      } else { // theme image
+        source = ResourceManagerUtil.getImageWithPath(facesContext, LEAF);
+      }
+      if (source == null) {
+        source = closedSource;
+      }
+    }
+
     CommandRendererHelper helper = new CommandRendererHelper(facesContext, node);
 
     if (showRoot || !isRoot) {
@@ -185,9 +220,9 @@
       encodeIndent(facesContext, writer, menuMode, junctions);
 
       encodeTreeJunction(facesContext, writer, id, treeId, showJunctions, showRootJunction, showRoot, expanded,
-          folder, depth, hasNextSibling, image);
+          folder, depth, hasNextSibling, openSource, closedSource);
 
-      encodeTreeIcons(facesContext, writer, id, treeId, showIcons, expanded, folder, image);
+      encodeTreeIcons(writer, id, treeId, showIcons, folder, source, openSource, closedSource);
 
       encodeLabel(writer, helper, node, marked, treeId);
 
@@ -205,7 +240,7 @@
       writer.writeIdAttribute(id + "-cont");
       writer.writeStyleAttribute(contentStyle);
     }
-    if (LOG.isDebugEnabled())  {
+    if (LOG.isDebugEnabled()) {
       String label = node.getLabel();
       int level = modelNode.getLevel();
       StringBuilder builder = new StringBuilder();
@@ -217,7 +252,7 @@
   }
 
   private void encodeExpandedHidden(TobagoResponseWriter writer, AbstractUITreeNode node, String clientId,
-      boolean expanded) throws IOException {
+                                    boolean expanded) throws IOException {
     writer.startElement(HtmlConstants.INPUT, node);
     writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
     writer.writeNameAttribute(clientId + "-expanded");
@@ -242,8 +277,8 @@
     writer.startElement(IMG, null);
     writer.writeClassAttribute("tobago-tree-menu-icon");
     writer.writeIdAttribute(id + "-menuIcon");
-    writer.writeAttribute("src", src, true); // xxx is escaping required?
-    writer.writeAttribute("onclick", onclick, true); // xxx is escaping required?
+    writer.writeAttribute("src", src, true);
+    writer.writeAttribute("onclick", onclick, true);
     writer.writeAttribute("alt", "", false);
     writer.endElement(IMG);
   }
@@ -259,9 +294,9 @@
       writer.startElement(IMG, null);
       writer.writeClassAttribute("tree-junction");
       if (junction && !menuMode) {
-        writer.writeAttribute("src", perpendicular, true); // xxx is escaping required?
+        writer.writeAttribute("src", perpendicular, true);
       } else {
-        writer.writeAttribute("src", blank, true); // xxx is escaping required?
+        writer.writeAttribute("src", blank, true);
       }
       writer.endElement(IMG);
     }
@@ -269,8 +304,9 @@
 
   private void encodeTreeJunction(
       FacesContext facesContext, TobagoResponseWriter writer, String id, String treeId,
-      boolean showJunctions, boolean showRootJunction, boolean showRoot,
-      boolean expanded, boolean folder, int depth, boolean hasNextSibling, String image) throws IOException {
+      boolean showJunctions, boolean showRootJunction, boolean showRoot, boolean expanded, boolean folder,
+      int depth, boolean hasNextSibling, String openSource, String closedSource)
+      throws IOException {
     if (!(!showJunctions
         || !showRootJunction && depth == 0
         || !showRootJunction && !showRoot && depth == 1)) {
@@ -290,10 +326,9 @@
       );
 
       String src = ResourceManagerUtil.getImageWithPath(facesContext, "image/" + gif);
-      writer.writeAttribute("src", src, true); // xxx is escaping required
+      writer.writeAttribute("src", src, true);
       if (folder) {
-        // xxx is escaping required
-        writer.writeAttribute("onclick", createOnclickForToggle(facesContext, treeId, image), true);
+        writer.writeAttribute("onclick", createOnclickForToggle(treeId, openSource, closedSource), true);
       }
       writer.writeAttribute("alt", "", false);
 //    } else if (( !this.hideRoot && depth >0 ) || (this.hideRoot && depth > 1)) {
@@ -305,8 +340,8 @@
   }
 
   private void encodeTreeIcons(
-      FacesContext facesContext, TobagoResponseWriter writer, String id, String treeId,
-      boolean showIcons, boolean expanded, boolean isFolder, String image)
+      TobagoResponseWriter writer, String id, String treeId,
+      boolean showIcons, boolean folder, String source, String openSource, String closedSource)
       throws IOException {
 
     if (showIcons) {
@@ -314,29 +349,21 @@
       writer.writeClassAttribute("tree-icon");
       writer.writeIdAttribute(id + "-icon");
 
-      if (image == null) {
-        image = "image/" + (isFolder ? (expanded ? "openfoldericon.gif" : "foldericon.gif") : "new.gif");
-      }
-      String src = ResourceManagerUtil.getImageWithPath(facesContext, image);
-      writer.writeAttribute("src", src, true); // xxx is escaping required
-      if (isFolder) {
-        writer.writeAttribute("onclick",
-            createOnclickForToggle(facesContext, treeId, image), true); // xxx is escaping required
+      writer.writeAttribute("src", source, true);
+      if (folder) {
+        writer.writeAttribute("onclick", createOnclickForToggle(treeId, openSource, closedSource), true);
       }
       writer.writeAttribute("alt", "", false);
       writer.endElement(IMG);
     }
   }
 
-  private String createOnclickForToggle(FacesContext facesContext, String treeId, String image) {
-    String openImage = image;
-    if (image == null) {
-      openImage = "image/openfoldericon.gif";
-      image = "image/foldericon.gif";
+  private String createOnclickForToggle(String treeId, String openSouce, String closedSource) {
+    if (openSouce == null) { // default
+      openSouce = closedSource;
     }
     return "tobagoTreeNodeToggle(this.parentNode, '" + treeId + "', '"
-        + ResourceManagerUtil.getImageWithPath(facesContext, openImage) + "', '"
-        + ResourceManagerUtil.getImageWithPath(facesContext, image) + "', null, null)";
+        + openSouce + "', '" + closedSource + "', null, null)";
   }
 
 /*
@@ -344,13 +371,13 @@
     str += '<img class="tree-icon" id="' + this.id + '-icon" '
         + 'src="' + (this.expanded ? this.openIcon : this.icon) + ' " '
         + 'onclick="toggle(this.parentNode, \'' + this.treeHiddenId
-        + '\', \'' + this.treeResources.getImage("openfoldericon.gif")
-        + '\', \'' + this.treeResources.getImage("foldericon.gif")
+        + '\', \'' + this.treeResources.getImage("image/treeNode-icon-open.gif")
+        + '\', \'' + this.treeResources.getImage("image/treeNode-icon.gif")
         + '\')"'
         + ' alt="">';
   } else {
     str += '<img class="tree-icon" id="' + this.id
-        + '-icon" src="' + this.treeResources.getImage("new.gif") + '" alt="">';
+        + '-icon" src="' + this.treeResources.getImage("image/treeNode-icon-leaf.gif") + '" alt="">';
   }
 */
 

Modified: 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/TreeRenderer.java?rev=709123&r1=709122&r2=709123&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/TreeRenderer.java Thu Oct 30 01:54:42 2008
@@ -23,7 +23,6 @@
  */
 
 import org.apache.myfaces.tobago.component.AbstractUITree;
-import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
@@ -42,30 +41,6 @@
 
 public class TreeRenderer extends LayoutableRendererBase {
 
-  /**
-   * Resources to display the tree.
-   */
-  private static final String[] TREE_IMAGES = {
-      "openfoldericon.gif",
-      "foldericon.gif",
-      "unchecked.gif",
-      "uncheckedDisabled.gif",
-      "checked.gif",
-      "checkedDisabled.gif",
-      "new.gif",
-      "T.gif",
-      "L.gif",
-      "I.gif",
-      "Lminus.gif",
-      "Tminus.gif",
-      "Rminus.gif",
-      "Lplus.gif",
-      "Tplus.gif",
-      "Rplus.gif",
-      "treeMenuOpen.gif",
-      "treeMenuClose.gif",
-  };
-
   private static final String SCRIPT = "script/tobago-tree.js";
 
   public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
@@ -139,42 +114,13 @@
       writer.endElement(HtmlConstants.INPUT);
     }
 
-    String scriptTexts = createJavascript(facesContext);
-
-    HtmlRendererUtil.writeScriptLoader(facesContext, new String[]{SCRIPT}, new String[]{scriptTexts});
+    HtmlRendererUtil.writeScriptLoader(facesContext, SCRIPT);
 
     RenderUtil.encode(facesContext, root);
 
     writer.endElement(HtmlConstants.DIV);
   }
 
-  private String createJavascript(FacesContext facesContext) throws IOException {
-    StringBuilder sb = new StringBuilder(128);
-
-    sb.append("{\n");
-
-    sb.append("  var treeResourcesHelp = new Object();\n");
-    for (String images : TREE_IMAGES) {
-      sb.append("  treeResourcesHelp[\"");
-      sb.append(images);
-      sb.append("\"] = \"");
-      sb.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/" + images));
-      sb.append("\";\n");
-    }
-    sb.append(" \n  treeResourcesHelp.getImage = function (name) {\n");
-    sb.append("    var result = this[name];\n");
-    sb.append("    if (result) {\n");
-    sb.append("      return result;\n");
-    sb.append("    } else {\n");
-    sb.append("      return \"");
-    sb.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/blank.gif"));
-    sb.append("\";\n");
-    sb.append("    }\n");
-    sb.append("  };\n \n");
-    sb.append("}");
-    return sb.toString();
-  }
-
   protected String getNodesAsJavascript(FacesContext facesContext, UIComponent root) throws IOException {
     ResponseWriter writer = facesContext.getResponseWriter();
     FastStringWriter stringWriter = new FastStringWriter();

Propchange: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-leaf.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-open.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: myfaces/tobago/trunk/theme/scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java?rev=709123&view=auto
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java (added)
+++ myfaces/tobago/trunk/theme/scarborough/src/test/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRendererUnitTest.java Thu Oct 30 01:54:42 2008
@@ -0,0 +1,29 @@
+package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.TestCase;
+
+public class TreeNodeRendererUnitTest extends TestCase {
+
+  public void testConstants() {
+     assertEquals("image/treeNode-icon-open.gif", TreeNodeRenderer.OPEN_FOLDER);
+     assertEquals("image/treeNode-icon.gif", TreeNodeRenderer.CLOSED_FOLDER);
+     assertEquals("image/treeNode-icon-leaf.gif", TreeNodeRenderer.LEAF);
+  }
+}

Propchange: myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-leaf.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-open.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream