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 2014/08/28 11:23:52 UTC

svn commit: r1621101 [2/2] - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/context/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/tagli...

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java?rev=1621101&r1=1621100&r2=1621101&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ToolBarRendererBase.java Thu Aug 28 09:23:50 2014
@@ -33,7 +33,6 @@ import org.apache.myfaces.tobago.context
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.apache.myfaces.tobago.internal.component.AbstractUIMenu;
-import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
 import org.apache.myfaces.tobago.internal.util.ObjectUtils;
 import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.layout.Measure;
@@ -156,7 +155,7 @@ public abstract class ToolBarRendererBas
           image = ((org.apache.myfaces.tobago.model.SelectItem) item).getImage();
         }
         if (image == null) {
-          image = "image/1x1.gif";
+          image = "image/1x1";
         }
         command.getAttributes().put(Attributes.IMAGE, image);
 
@@ -407,8 +406,15 @@ public abstract class ToolBarRendererBas
     if (showIcon && iconName != null) {
       writer.startElement(HtmlElements.IMG, command);
       writer.writeAttribute(HtmlAttributes.SRC, image, false);
-      final String imageHover
-          = ResourceManagerUtils.getImageWithPath(facesContext, HtmlRendererUtils.createSrc(iconName, "Hover"), true);
+      // todo in Tobago 3.0: remove "Hover" and replace with CSS filter
+      final int dot = ResourceManagerUtils.indexOfExtension(iconName);
+      final String imageHover;
+      if (dot != -1) {
+        imageHover = ResourceManagerUtils.getImageOrDisabledImageWithPath(
+            facesContext, iconName.substring(0, dot) + "Hover" + iconName.substring(dot), disabled, true);
+      } else {
+        imageHover = ResourceManagerUtils.getImageOrDisabledImage(facesContext, iconName + "Hover", disabled, true);
+      }
       if (imageHover != null) {
         writer.writeAttribute(DataAttributes.SRC_DEFAULT, image, false);
         writer.writeAttribute(DataAttributes.SRC_HOVER, imageHover, false);
@@ -443,8 +449,8 @@ public abstract class ToolBarRendererBas
       writer.startElement(HtmlElements.IMG, command);
       final boolean dropDownDisabled
           = ComponentUtils.getBooleanAttribute(dropDownMenu, Attributes.DISABLED) || disabled;
-      final String menuImage = ResourceManagerUtils
-          .getImageOrDisabledImageWithPath(facesContext, "image/toolbarButtonMenu.gif", dropDownDisabled);
+      final String menuImage
+          = ResourceManagerUtils.getImageOrDisabledImage(facesContext, "image/toolbarButtonMenu", dropDownDisabled);
       writer.writeAttribute(HtmlAttributes.SRC, menuImage, false);
       writer.writeStyleAttribute(openerStyle);
       writer.endElement(HtmlElements.IMG);
@@ -537,10 +543,8 @@ public abstract class ToolBarRendererBas
   private String getImage(
       final FacesContext facesContext, final String name, final String iconSize, final boolean disabled,
       final boolean selected) {
-    int pos = name.lastIndexOf('.');
-    if (pos == -1) {
-      pos = name.length(); // avoid exception if no '.' in name
-    }
+    final int dot = ResourceManagerUtils.indexOfExtension(name);
+    final int pos = dot == -1 ? name.length() : dot; // avoid exception if no '.' in name
     final String key = name.substring(0, pos);
     final String ext = name.substring(pos);
 
@@ -551,29 +555,61 @@ public abstract class ToolBarRendererBas
       size = "32";
     }
     String image = null;
-    final ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
+
     if (disabled && selected) {
-      image = resourceManager.getImage(facesContext, key + "SelectedDisabled" + size + ext, true);
+      if (dot != -1) {
+        image = ResourceManagerUtils.getImageWithPath(facesContext, key + "SelectedDisabled" + size + ext, true);
+      } else {
+        image = ResourceManagerUtils.getImage(facesContext, key + "SelectedDisabled" + size, true);
+      }
       if (image == null) {
-        image = resourceManager.getImage(facesContext, key + "SelectedDisabled" + ext, true);
+        if (dot != -1) {
+          image = ResourceManagerUtils.getImageWithPath(facesContext, key + "SelectedDisabled" + ext, true);
+        } else {
+          image = ResourceManagerUtils.getImage(facesContext, key + "SelectedDisabled", true);
+        }
       }
     }
     if (image == null && disabled) {
-      image = resourceManager.getImage(facesContext, key + "Disabled" + size + ext, true);
+      if (dot != -1) {
+        image = ResourceManagerUtils.getImageWithPath(facesContext, key + "Disabled" + size + ext, true);
+      } else {
+        image = ResourceManagerUtils.getImage(facesContext, key + "Disabled" + size, true);
+      }
       if (image == null) {
-        image = resourceManager.getImage(facesContext, key + "Disabled" + ext, true);
+        if (dot != -1) {
+          image = ResourceManagerUtils.getImageWithPath(facesContext, key + "Disabled" + ext, true);
+        } else {
+          image = ResourceManagerUtils.getImage(facesContext, key + "Disabled", true);
+        }
       }
     }
     if (image == null && selected) {
-      image = resourceManager.getImage(facesContext, key + "Selected" + size + ext, true);
+      if (dot != -1) {
+        image = ResourceManagerUtils.getImageWithPath(facesContext, key + "Selected" + size + ext, true);
+      } else {
+        image = ResourceManagerUtils.getImage(facesContext, key + "Selected" + size, true);
+      }
       if (image == null) {
-        image = resourceManager.getImage(facesContext, key + "Selected" + ext, true);
+        if (dot != -1) {
+          image = ResourceManagerUtils.getImageWithPath(facesContext, key + "Selected" + ext, true);
+        } else {
+          image = ResourceManagerUtils.getImage(facesContext, key + "Selected", true);
+        }
       }
     }
     if (image == null) {
-      image = resourceManager.getImage(facesContext, key + size + ext, true);
+      if (dot != -1) {
+        image = ResourceManagerUtils.getImageWithPath(facesContext, key + size + ext, true);
+      } else {
+        image = ResourceManagerUtils.getImage(facesContext, key + size, true);
+      }
       if (image == null) {
-        image = resourceManager.getImage(facesContext, key + ext, true);
+        if (dot != -1) {
+          image = ResourceManagerUtils.getImageWithPath(facesContext, key + ext, true);
+        } else {
+          image = ResourceManagerUtils.getImage(facesContext, key, true);
+        }
       }
     }
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeIconRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeIconRenderer.java?rev=1621101&r1=1621100&r2=1621101&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeIconRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeIconRenderer.java Thu Aug 28 09:23:50 2014
@@ -23,7 +23,6 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UITreeNode;
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
-import org.apache.myfaces.tobago.context.ResourceUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUIData;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -40,12 +39,9 @@ import java.io.IOException;
 
 public class TreeIconRenderer extends LayoutComponentRendererBase {
 
-  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);
+  protected static final String OPEN_FOLDER = "image/treeNode-icon-open";
+  protected static final String CLOSED_FOLDER = "image/treeNode-icon";
+  protected static final String LEAF = "image/treeNode-icon-leaf";
 
   @Override
   public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
@@ -60,27 +56,45 @@ public class TreeIconRenderer extends La
     final String openSource;
     final String closedSource;
 
-    final String imageUrl = (String) image.getValue();
+    String imageUrl = (String) image.getValue();
+    String imageExtension = null;
+    if (imageUrl != null) {
+      final int dot = imageUrl.lastIndexOf('.');
+      if (dot > -1) {
+        imageExtension = imageUrl.substring(dot);
+        imageUrl = imageUrl.substring(0, dot);
+      }
+    }
     if (imageUrl != null) { // application image
-      closedSource = ResourceManagerUtils.getImageWithPath(facesContext, imageUrl);
+      if (imageExtension != null) {
+        closedSource = ResourceManagerUtils.getImageWithPath(facesContext, imageUrl + imageExtension);
+      } else {
+        closedSource = ResourceManagerUtils.getImage(facesContext, imageUrl);
+      }
     } else { // theme image
-      closedSource = ResourceManagerUtils.getImageWithPath(facesContext, CLOSED_FOLDER);
+      closedSource = ResourceManagerUtils.getImage(facesContext, CLOSED_FOLDER);
     }
     if (folder) {
       if (imageUrl != null) { // application image
-        openSource = ResourceManagerUtils.getImageWithPath(facesContext,
-            ResourceUtils.addPostfixToFilename(imageUrl, "-open"), true);
+        if (imageExtension != null) {
+          openSource = ResourceManagerUtils.getImageWithPath(facesContext, imageUrl + "-open" + imageExtension, true);
+        } else {
+          openSource = ResourceManagerUtils.getImage(facesContext, imageUrl + "-open", true);
+        }
       } else { // theme image
-        openSource = ResourceManagerUtils.getImageWithPath(facesContext, OPEN_FOLDER);
+        openSource = ResourceManagerUtils.getImage(facesContext, OPEN_FOLDER);
       }
       source = expanded ? openSource : closedSource;
     } else {
       openSource = null;
       if (imageUrl != null) { // application image
-        source = ResourceManagerUtils.getImageWithPath(facesContext,
-            ResourceUtils.addPostfixToFilename(imageUrl, "-leaf"), true);
+        if (imageExtension != null) {
+          source = ResourceManagerUtils.getImageWithPath(facesContext, imageUrl + "-leaf" + imageExtension, true);
+        } else {
+          source = ResourceManagerUtils.getImage(facesContext, imageUrl + "-leaf", true);
+        }
       } else { // theme image
-        source = ResourceManagerUtils.getImageWithPath(facesContext, LEAF);
+        source = ResourceManagerUtils.getImage(facesContext, LEAF);
       }
     }
     if (source == null) {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeIndentRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeIndentRenderer.java?rev=1621101&r1=1621100&r2=1621101&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeIndentRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeIndentRenderer.java Thu Aug 28 09:23:50 2014
@@ -85,8 +85,8 @@ public class TreeIndentRenderer extends 
       throws IOException {
 
     final boolean dropFirst = !showRoot || !showRootJunction && (showLines || showIcons);
-    final String blank = ResourceManagerUtils.getImageWithPath(facesContext, "image/blank.gif");
-    final String perpendicular = ResourceManagerUtils.getImageWithPath(facesContext, "image/I.gif");
+    final String blank = ResourceManagerUtils.getImage(facesContext, "image/blank");
+    final String perpendicular = ResourceManagerUtils.getImage(facesContext, "image/I");
 
     for (int i = dropFirst ? 1 : 0; i < junctions.size() - 1; i++) {
       final Boolean junction = junctions.get(i);
@@ -118,39 +118,39 @@ public class TreeIndentRenderer extends 
     final String close;
     if (showLines) {
       if (root) {
-        open = "Rminus.gif";
-        close = "Rplus.gif";
+        open = "Rminus";
+        close = "Rplus";
       } else {
         if (hasNextSibling) {
           if (folder) {
-            open = "Tminus.gif";
-            close = "Tplus.gif";
+            open = "Tminus";
+            close = "Tplus";
           } else {
-            open = "T.gif";
-            close = "T.gif";
+            open = "T";
+            close = "T";
           }
         } else {
           if (folder) {
-            open = "Lminus.gif";
-            close = "Lplus.gif";
+            open = "Lminus";
+            close = "Lplus";
           } else {
-            open = "L.gif";
-            close = "L.gif";
+            open = "L";
+            close = "L";
           }
         }
       }
     } else {
       if (folder) {
-        open = "minus.gif";
-        close = "plus.gif";
+        open = "minus";
+        close = "plus";
       } else {
-        open = "blank.gif";
-        close = "blank.gif";
+        open = "blank";
+        close = "blank";
       }
     }
 
-    final String srcOpen = ResourceManagerUtils.getImageWithPath(facesContext, "image/" + open);
-    final String srcClose = ResourceManagerUtils.getImageWithPath(facesContext, "image/" + close);
+    final String srcOpen = ResourceManagerUtils.getImage(facesContext, "image/" + open);
+    final String srcClose = ResourceManagerUtils.getImage(facesContext, "image/" + close);
     final String src = expanded ? srcOpen : srcClose;
     writer.writeAttribute(HtmlAttributes.SRC, src, true);
     if (folder) {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeMenuNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeMenuNodeRenderer.java?rev=1621101&r1=1621100&r2=1621101&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeMenuNodeRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeMenuNodeRenderer.java Thu Aug 28 09:23:50 2014
@@ -73,7 +73,7 @@ public class TreeMenuNodeRenderer extend
 
 
     if (!folder && ie6) { // XXX IE6: without this hack, we can't click beside the label text. Why?
-      final String src = ResourceManagerUtils.getImageWithPath(facesContext, "image/1x1.gif");
+      final String src = ResourceManagerUtils.getImage(facesContext, "image/1x1");
       writer.startElement(HtmlElements.IMG, null);
       writer.writeClassAttribute(Classes.create(node, "icon"));
       writer.writeAttribute(HtmlAttributes.SRC, src, false);
@@ -104,8 +104,8 @@ public class TreeMenuNodeRenderer extend
   private void encodeIcon(
       final FacesContext facesContext, final TobagoResponseWriter writer, final boolean expanded, final UITreeNode node)
       throws IOException {
-    final String srcOpen = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuOpen.gif");
-    final String srcClose = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuClose.gif");
+    final String srcOpen = ResourceManagerUtils.getImage(facesContext, "image/treeMenuOpen");
+    final String srcClose = ResourceManagerUtils.getImage(facesContext, "image/treeMenuClose");
     final String src = expanded ? srcOpen : srcClose;
     writer.startElement(HtmlElements.IMG, null);
     writer.writeClassAttribute(Classes.create(node, "toggle"));

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeNodeRenderer.java?rev=1621101&r1=1621100&r2=1621101&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeNodeRenderer.java Thu Aug 28 09:23:50 2014
@@ -19,7 +19,6 @@
 
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
-import org.apache.myfaces.tobago.context.ResourceUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUIData;
 import org.apache.myfaces.tobago.internal.component.AbstractUITreeNode;
 import org.apache.myfaces.tobago.layout.Display;
@@ -31,8 +30,6 @@ import org.apache.myfaces.tobago.renderk
 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;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -40,15 +37,6 @@ import java.io.IOException;
 
 public class TreeNodeRenderer extends TreeNodeRendererBase {
 
-  private static final Logger LOG = LoggerFactory.getLogger(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 encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
 
@@ -56,7 +44,6 @@ public class TreeNodeRenderer extends Tr
     final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
 
     final boolean dataRendersRowContainer = data.isRendersRowContainer();
-    final boolean folder = node.isFolder();
     final String clientId = node.getClientId(facesContext);
     final String parentId = data.getRowParentClientId();
     final boolean visible = data.isRowVisible();

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java?rev=1621101&r1=1621100&r2=1621101&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java Thu Aug 28 09:23:50 2014
@@ -76,6 +76,7 @@ public final class HtmlRendererUtils {
     // to prevent instantiation
   }
 
+  /** @deprecated since 2.0.0, because of CSP */
   private static boolean renderErrorFocusId(final FacesContext facesContext, final UIInput input) throws IOException {
     if (ComponentUtils.isError(input)) {
       if (!FacesContext.getCurrentInstance().getExternalContext().getRequestMap().containsKey(ERROR_FOCUS_KEY)) {
@@ -249,6 +250,8 @@ public final class HtmlRendererUtils {
     Deprecation.LOG.error("HtmlRendererUtils.createHeaderAndBodyStyles() no longer supported");
   }
 
+  /** @deprecated since 2.0.3 */
+  @Deprecated
   public static String createSrc(final String src, final String ext) {
     final int dot = src.lastIndexOf('.');
     if (dot == -1) {