You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2010/08/06 05:33:11 UTC

svn commit: r982859 - in /myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal: skin/SkinStyleSheetParserUtils.java style/util/StyleUtils.java style/xml/parse/StyleSheetDocument.java

Author: jwaldman
Date: Fri Aug  6 03:33:10 2010
New Revision: 982859

URL: http://svn.apache.org/viewvc?rev=982859&view=rev
Log:
TRINIDAD-17 Need to support mapping icons via -tr-rule-ref like we do with styles.
Re-check in. It definitely does not break the ADF Faces build.

Modified:
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/StyleUtils.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java?rev=982859&r1=982858&r2=982859&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java Fri Aug  6 03:33:10 2010
@@ -153,6 +153,7 @@ class SkinStyleSheetParserUtils
     return in.substring(firstCharIndex, length);
   }
 
+
   /**
    * Given a List of SkinStyleSheetNode, create StyleSheetEntry.
    * A StyleSheetEntry is an object that contains:
@@ -212,7 +213,7 @@ class SkinStyleSheetParserUtils
         List<PropertyNode> noTrPropertyList =
           resolvedProperties.getNoTrPropertyList();
 
-        if (_isIcon(selectorName))
+        if (StyleUtils.isIcon(selectorName))
         {
           // knock off the '.' if it is the first character.
           if (selectorName.charAt(0) == '.')
@@ -529,6 +530,22 @@ class SkinStyleSheetParserUtils
     // really an icon. But we don't want to hurt the person that didn't abide by the -icon rule
     // because this wasn't an enforced rule.
     //
+    // if the trRuleRefList is not empty, create IncludeStyleNodes.
+    List<IncludeStyleNode> includeStyleNodes = new ArrayList<IncludeStyleNode>();
+
+    for(String value : trRuleRefList)
+    {
+      // parse the value, which will be of this form:
+      // -tr-rule-ref: selector(".AFBaseFont:alias") selector(".Foo")
+      // where you have more than one selector in an -tr-rule-ref definition
+      // or -tr-rule-ref: selector(".AFBaseFont:alias")
+      // where you have only one selector in an -tr-rule-ref definition.
+      // I want each selector value to be an IncludeStyleNode.
+
+      _addIncludeStyleNodes(value, includeStyleNodes);
+
+    }
+
     if (selectorName != null)
     {
       // Create a styleNode that we will add to the IconNode.
@@ -536,7 +553,7 @@ class SkinStyleSheetParserUtils
         new StyleNode(null,
                       selectorName,
                       propertyNodeArray,
-                      null, // TODO includeStyleNodes.toArray(new IncludeStyleNode[0]), TRINIDAD-17
+                      includeStyleNodes.toArray(new IncludeStyleNode[0]),
                       null, //TODO jmw includePropertyNodes
                       inhibitedProperties
                       );
@@ -911,25 +928,6 @@ class SkinStyleSheetParserUtils
     return builder.toString();
     
   }
-
-  // returns true if the selectorName indicates that it is an icon.
-  private static boolean _isIcon(String selectorName)
-  {
-    if (selectorName == null)
-      return false;
-    // =-=jmw There is no good way to tell if this is an icon.
-    // for now, I look at the selector name.
-    // we do have some styles that have -icon- in the name, but it's
-    // not at the end which is how icons are determined.
-    // our icon names look like .AFWarningIcon:alias
-    // AFErrorIconStyle is a style.
-    // This supports pseudo-classes on icon definitions (e.g.,
-    // foo-icon:hover- or FooIcon:alias:hover)
-    // -icon: is a condition because it could be -icon:hover.
-    return  (selectorName.endsWith("-icon")  ||
-            (selectorName.indexOf("-icon:") > -1) ||
-            selectorName.indexOf("Icon:alias") > -1);
-  }
   
   private static class ResolvedSkinProperties
   {

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/StyleUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/StyleUtils.java?rev=982859&r1=982858&r2=982859&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/StyleUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/StyleUtils.java Fri Aug  6 03:33:10 2010
@@ -50,6 +50,26 @@ public class StyleUtils
 
     return selector;
   }
+  
+  
+  // returns true if the selectorName indicates that it is an icon.
+  public static boolean isIcon(String selectorName)
+  {
+    if (selectorName == null)
+      return false;
+    // =-=jmw There is no good way to tell if this is an icon.
+    // for now, I look at the selector name.
+    // we do have some styles that have -icon- in the name, but it's
+    // not at the end which is how icons are determined.
+    // our icon names look like .AFWarningIcon:alias
+    // AFErrorIconStyle is a style.
+    // This supports pseudo-classes on icon definitions (e.g.,
+    // foo-icon:hover- or FooIcon:alias:hover)
+    // -icon: is a condition because it could be -icon:hover.
+    return  (selectorName.endsWith("-icon")  ||
+            (selectorName.indexOf("-icon:") > -1) ||
+            selectorName.indexOf("Icon:alias") > -1);
+  }
 
   static private final String _DOUBLE_COLON = "::";
 }

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java?rev=982859&r1=982858&r2=982859&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java Fri Aug  6 03:33:10 2010
@@ -53,6 +53,7 @@ import org.apache.myfaces.trinidadintern
 import org.apache.myfaces.trinidadinternal.style.util.CSSUtils;
 import org.apache.myfaces.trinidadinternal.style.util.ModeUtils;
 import org.apache.myfaces.trinidadinternal.style.util.NameUtils;
+import org.apache.myfaces.trinidadinternal.style.util.StyleUtils;
 import org.apache.myfaces.trinidadinternal.util.nls.LocaleUtils;
 
 
@@ -740,7 +741,7 @@ public class StyleSheetDocument
         }
       }        
     }
-    _resolveStyleWork(context, forIconNode, styleSheets, resolvedStyles, resolvedNamedStyles,  
+    _resolveStyleWork(context, id, forIconNode, styleSheets, resolvedStyles, resolvedNamedStyles,  
                       includesStack, namedIncludesStack, entry, nodeList);
     
     // Pop the include stack
@@ -786,6 +787,7 @@ public class StyleSheetDocument
 
   private void _resolveStyleWork(
     StyleContext context,
+    String       id,
     boolean      forIconNode,
     StyleSheetList styleSheets,
     Map<String, StyleNode> resolvedStyles,
@@ -850,6 +852,22 @@ public class StyleSheetDocument
 
           if (resolvedNode != null)
             _addIncludedProperties(entry, resolvedNode);
+          else 
+          {
+            // Fortunately this is an uncommon usecase
+            // af|foo::some-icon {content: url(); width:16px; height:16px} 
+            // // In SkinStyleSheetParserUtils, we are not sure if this is an icon or style 
+            // // since there is no explicit 'content' attr. So we create both an Icon and a Style.
+            // af|bar::some-icon {-tr-rule-ref: selector("af|foo");} 
+            if (_LOG.isFinest() && !forIconNode && StyleUtils.isIcon(includeID) && 
+                StyleUtils.isIcon(id))
+            {
+                _LOG.finest(id + " is being written to the CSS file " +
+                  "even though it is likely a Skin Icon Object, not a style.");
+  
+
+            }
+          }
         }