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 2007/11/06 01:46:44 UTC

svn commit: r592210 - in /myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator: GeneratorHelper.java taglib/TrinidadComponentTagGenerator.java

Author: jwaldman
Date: Mon Nov  5 16:46:43 2007
New Revision: 592210

URL: http://svn.apache.org/viewvc?rev=592210&view=rev
Log:
TRINIDAD-774 support for static colors in a tag
Changed to call TagUtils.getColor(s) if the attribute is a Color.
This allows colors like "#ee0077" to be used in color attributes.


Modified:
    myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
    myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java

Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java?rev=592210&r1=592209&r2=592210&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java Mon Nov  5 16:46:43 2007
@@ -72,6 +72,12 @@
         "java.awt.Color".equals(propClassParams[0]));
   }
 
+  public static boolean isColor(
+      String propClass)
+  {
+    return ("java.awt.Color".equals(propClass));
+  }  
+
   public static boolean isAction(PropertyBean property)
   {
     return (property.getClass().equals("javax.el.MethodExpression")

Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java?rev=592210&r1=592209&r2=592210&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java Mon Nov  5 16:46:43 2007
@@ -105,7 +105,8 @@
           imports.add("javax.faces.el.ValueBinding");
         imports.add("org.apache.myfaces.trinidadinternal.taglib.util.VirtualAttributeUtils");
       }
-      else if (GeneratorHelper.isColorList(propertyClass, propertyClassParams))
+      else if (GeneratorHelper.isColorList(propertyClass, propertyClassParams) ||
+               GeneratorHelper.isColor(propertyClass))
       {
         if (_is12)
           imports.add("javax.el.ValueExpression");
@@ -261,7 +262,11 @@
     }
     else if (GeneratorHelper.isColorList(propClass, property.getPropertyClassParameters()))
     {
-      _writeSetColorList(out, componentClass, propName);
+      _writeSetColor(out, componentClass, propName, true);
+    }
+    else if (GeneratorHelper.isColor(propClass))
+    {
+      _writeSetColor(out, componentClass, propName, false);
     }
     else if (GeneratorHelper.isConverter(propClass))
     {
@@ -703,10 +708,11 @@
   }
 
 
-  private void _writeSetColorList(
+  private void _writeSetColor(
       PrettyWriter out,
-      String componentClass,
-      String propName) throws IOException
+      String  componentClass,
+      String  propName,
+      boolean isList) throws IOException
   {
     String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
     String propVar = "_" + propName;
@@ -733,7 +739,12 @@
       out.println("{");
       out.indent();
       out.println("bean.setProperty(" + componentClass + "." + propKey + ",");
-      out.println("                 TagUtils.getColorList(s));");
+      if (isList)
+        out.println("                 TagUtils.getColorList(s));");
+      else
+      {
+        out.println("                 TagUtils.getColor(s));");
+      }
       out.unindent();
       out.println("}");
       out.println("catch (ParseException pe)");
@@ -764,7 +775,10 @@
       out.println("{");
       out.indent();
       out.println("bean.setProperty(" + componentClass + "." + propKey + ",");
-      out.println("                 TagUtils.getColorList(" + propVar + "));");
+      if (isList)
+	    out.println("                 TagUtils.getColorList(" + propVar + "));");
+	  else
+        out.println("                 TagUtils.getColor(" + propVar + "));");
       out.unindent();
       out.println("}");
       out.println("catch (ParseException pe)");