myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r1069914 - in /myfaces/trinidad/branches/1.2.12.5.0-branch: src/site/xdoc/devguide/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/ trinidad-api/src/main/resources...
Date Fri, 11 Feb 2011 18:28:26 GMT
Author: jwaldman
Date: Fri Feb 11 18:28:25 2011
New Revision: 1069914

URL: http://svn.apache.org/viewvc?rev=1069914&view=rev
Log:
TRINIDAD-1951 add skin versioning
backport to 1.2.12.5.0-branch

Added:
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinVersion.java   (with props)
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin-v1.css   (with props)
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNode.java   (with props)
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNodeParser.java   (with props)
Modified:
    myfaces/trinidad/branches/1.2.12.5.0-branch/src/site/xdoc/devguide/skinning.xml
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/Skin.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinFactory.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/resources/trinidad-config.xsd
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/RequestSkinWrapper.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinFactoryImpl.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNode.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNodeParser.java
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/ui/laf/xml/schemas/skin/trinidad-skins.xsd
    myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/src/site/xdoc/devguide/skinning.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/src/site/xdoc/devguide/skinning.xml?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/src/site/xdoc/devguide/skinning.xml (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/src/site/xdoc/devguide/skinning.xml Fri Feb 11 18:28:25 2011
@@ -139,9 +139,13 @@
             <li>Create a *.css stylesheet document that gets linked to your skin definition in
                 trinidad-skins.xml</li>
             <li>Set trinidad-config.xml &lt;skin-family&gt; to be the skin-family of your skin.</li>
+          <li>Optionally, if the skin has a version, set trinidad-config.xml &lt;skin-version&gt; to be the skin-version of your skin,
+            or "default" if you want choose the skin marked to be the default for that skin family.</li>
           </ul>
             <li>Turn off styleclass name compression in web.xml (while creating the skin only then
                 turn it back on for performance sake)</li>
+            <li>Turn on check file modification in web.xml (while creating the skin only then
+                turn it back off for performance sake)</li>
             <li>Install Firebug to help look at the DOM and the styleclasses</li>
             <li>Run a component or application to see the default mode. Your skin will extend the
                 default skin, unless you specify otherwise (because you can extend any skin you
@@ -190,6 +194,14 @@
                     <family>
                         bigfont
                     </family>
+                    <!-- optional. If you want to version your skin, then you set the version.
+                    This is useful if you want to keep the skin-family the same name, but you
+                    have fixed bugs in the skin. The user can use the original version or the 
+                    new version by specifying skin-version in trinidad-config.xml.-->
+                    <version>
+                      <name>v1</name>
+                      <default>true</default>
+                    </version>
                     <!-- if you want this skin to be for a pda, use org.apache.myfaces.trinidad.pda as the render-kit-id -->
                     <render-kit-id>
                         org.apache.myfaces.trinidad.desktop
@@ -221,11 +233,21 @@
         <b>id</b> - Each skin must have an id. This is a unique identifier for a skin. The syntax we use is bigfont.desktop. 
         We put the .desktop in there to specify that this is for the desktop renderkit. You can also create a skin for the pda renderkit if you would like.
         </li>
-        <b>family</b> - Each skin must have a family. A skin belongs to a family and this is what you set in the 
+        <li><b>family</b> - Each skin must have a family. A skin belongs to a family and this is what you set in the 
         trinidad-config.xml file under &lt;skin-family&gt;. Then the specific skin is chosen depending upon 
         the renderkit that is being used on render. You can create a bigfont.pda skin that is also in the bigfont family. 
         Then if a person is running your app with a pda, they would get the bigfont.pda skin. Otherwise, if you 
         didn't have a bigfont.pda skin, they'd get the default skin which is simple.pda.
+        </li>
+        <li><b>version</b> - Version is optional. Setting a version on your skin is useful if you
+        tend to change your css to fix bugs. Instead of creating a new skin and updating the skin-family 
+        so the end user can choose the new skin (e.g., purple-release2), you can instead create a new skin
+        with the same skin-family, and a version like release2.       
+        This way the skin-family in trinidad-config.xml will not have to change. The user can
+        either change the skin-version or they can set it to "default"
+        You can set the <b>name</b> element of the version, and optionally you can set the <b>default</b> element to true/false. 
+        The default skin will get picked if the trinidad-config.xml only specifies the skin-family.
+        </li>
         <li>
         <b>render-kit-id</b> - The renderkit that this skin is designed for. The values can be org.apache.myfaces.trinidad.desktop or org.apache.myfaces.trinidad.pda.
         </li>
@@ -309,10 +331,13 @@ In bigfont.css, to change the font for y
 </source>
 Components that use font and font-family have included these aliases in their skin definitions, so if you change the aliases, everything that includes these aliases will change.
        </subsection>
-       <subsection name="In trinidad-config.xml set the skin-family">
+       <subsection name="In trinidad-config.xml set the skin-family and optionally the skin-version">
 Open the trinidad-config.xml file that is in your WEB-INF directory.
 Set &lt;skin-family&gt;bigfont&lt;/skin-family&gt;
-This will set your skin to bigfont when you run your application. You can EL-bind the skin-family as well to dynamically change the skin at runtime.
+This will set your skin to bigfont when you run your application. 
+You can EL-bind the skin-family as well to dynamically change the skin at runtime.
+If the skin has a particular version you want, you can also set the skin-version element to the name
+of the skin's version.
 <P>
 Remember, your page must have the &lt;tr:document&gt; tag on the page to kick off the skin framework.
 </P>
@@ -678,9 +703,10 @@ so the medium panelBox's body will be pi
         <P>Let's go through an example. Let's say you want to skin the ShowDetail disclosed tip.
         Let's say the 'key' is af_showDetail.DISCLOSED_TIP. You would:
         <ul>
-        <li> Create a ResouceBundle file that sets your new value for this key and any other
-        keys you want to change the value for.</li>
+        <li> Create a ResourceBundle file(s) that sets your new value for this key and any other
+        keys you want to change the value for, one file per language.</li>
         <li> Set bundle-name in the trinidad-skins.xml file for your custom skin.</li>
+        <li> Package your skin and resource bundle classes together in the jar.</li>
         </ul>
         </P>
 
@@ -718,6 +744,12 @@ so the medium panelBox's body will be pi
             org.apache.myfaces.trinidaddemo.resource.SkinBundle
         </bundle-name>
     </skin>]]></source>
+        <source><![CDATA[  
+        The directory structure of your skin jar would look like:
+        META-INF
+        META-INF/trinidad-skins.xml
+        META-INF/org/apache/myfaces/trinidaddemo/resource/SkinBundle.class & SkinBundle_fr.class
+        ]]></source>
         <P>Then when the renderer renders the text, it will look in your resource bundle first for the key's value.   
         It is highly recommended if you do skin text that you provide all the translated bundles
         for the key you are skinning. Therefore you will have many other files, like SkinBundle_fr, etc.,

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java Fri Feb 11 18:28:25 2011
@@ -251,6 +251,14 @@ abstract public class RequestContext
   public abstract String getSkinFamily();
 
   /**
+   * Returns the name of the skin version that goes with the skin-family.
+   */
+  public String getSkinVersion()
+  {
+    return null;
+  }
+
+  /**
    * Determines whether the current View Root is an internal view
    * @param context Faces context
    * @return true if the current View Root is an internal view, false otherwise

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/Skin.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/Skin.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/Skin.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/Skin.java Fri Feb 11 18:28:25 2011
@@ -53,6 +53,19 @@ abstract public class Skin
    * current render-kit-id.
    */
   abstract public String getFamily();
+  
+
+  /**
+   * Returns the (@link SkinVersion} instance of the "version" for this skin.
+   * When a Skin instance is created, a SkinVersion instance can be a part of it.
+   * In trinidad-skins.xml this is the version element. In the trinidad-config.xml, 
+   * the application developer can set the skin-version to a skin version, or to 'default'.
+   * This returns SkinVersion.EMPTY_SKIN_VERSION if no version is set.
+   */
+  public SkinVersion getVersion()
+  {
+    return SkinVersion.EMPTY_SKIN_VERSION;
+  }
 
   /**
    * Returns the renderKitId for the Skin.
@@ -202,5 +215,5 @@ abstract public class Skin
    * The Skinning Framework calls setDirty(false) after the skin has been reprocessed.
    */
   abstract public void setDirty(boolean dirty);
-    
+  
 }

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinFactory.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinFactory.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinFactory.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinFactory.java Fri Feb 11 18:28:25 2011
@@ -106,6 +106,31 @@ abstract public class SkinFactory
     String family, 
     String renderKitId);
   
+
+  /**
+   * <p>Return a {@link Skin} instance for the specified skinFamily and
+   * renderKitId, and skin version. The best matched skin is returned. 
+   * If there is no registered {@link
+   * Skin} for the specified identifier, return
+   * <code>null</code>.  The set of available skin identifiers
+   * is available via the <code>getSkinIds()</code> method.</p>
+   *
+   * @param context FacesContext for the request currently being
+   * processed, or <code>null</code> if none is available.
+   * @param family family of the requested {@link Skin} instance
+   * @param renderKitId RenderKit identifier of the requested
+   *  {@link Skin} instance
+   *  @param version. A string that denotes the skin version name. It can be "default" or 
+   *  the name of the version (see the Skin's SkinVersion#getName) or null which 
+   *  returns the skin with no version set.
+   *  
+   */
+  public abstract Skin getSkin(
+    FacesContext context, 
+    String family,
+    String renderKitId,
+    String version);
+  
   /**
    * <p>Return an <code>Iterator</code> over the set of skin
    * identifiers registered with this factory.

Added: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinVersion.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinVersion.java?rev=1069914&view=auto
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinVersion.java (added)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinVersion.java Fri Feb 11 18:28:25 2011
@@ -0,0 +1,115 @@
+/*
+ *  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.
+ */
+package org.apache.myfaces.trinidad.skin;
+
+ /**
+  * The skin version works tightly with the skin family.
+  * This allows someone to create versions of their skin, like purple (no version), 
+  * purple version v2, purple version v3. 
+  * Then the user can say which skin version they want, like:
+  * <skin-family>purple</skin-family><skin-version>v3</skin-version> when they 
+  * pick a skin in trinidad-config.xml.
+  * When creating a skin, you give it a version if you care about versioning.
+  */
+final public class SkinVersion
+{
+  /**
+   * Constructor that takes a version name.
+   * @param name the name of the version, like "v1". If name is null, it is converted to "".
+   * same skin family
+   */
+  public SkinVersion(String name)
+  {
+    this(name, false);
+  }
+  
+  /**
+   * Constructor that takes a name and a defaultVersion.
+   * @param name the name of the version, like "v1". If name is null, it is converted to "".
+   * @param defaultVersion true if this skin is the default version for all skins with the
+   * same skin family
+   */
+  public SkinVersion(
+    String  name,
+    boolean defaultVersion)
+  {
+    if(name == null) 
+      name = "";
+    
+    _default = defaultVersion;
+    _name = name;
+  }
+  
+  public boolean isDefault()
+  {
+    return _default;
+  }
+  
+  public String getName()
+  {
+    return _name;
+  }
+  
+  @Override
+  final public boolean equals(Object o) 
+  {
+    if (o == this)
+      return true;
+    if (!(o instanceof SkinVersion))
+    {
+      return false;
+    }
+    SkinVersion test = (SkinVersion)o;
+    return (test.isDefault() == this.isDefault()) &&
+      (test.getName().equals(this.getName()));
+  }
+  
+  @Override
+  final public int hashCode()
+  {
+    int hash = 17;
+    hash = 37*hash + this.getName().hashCode();
+    hash = 37*hash + ((this.isDefault()) ? 1231 : 1237 );
+
+    return hash; 
+  } 
+
+  @Override
+  public String toString()
+  {
+    StringBuffer buffer = new StringBuffer("Version[");
+    buffer.append(getName());
+
+    boolean isDefault = isDefault();
+
+    if (isDefault)
+    {
+      buffer.append(',');
+      buffer.append("default");
+    }
+    return buffer.toString();
+  }
+  
+  // If the skin doesn't explicitly have a version, then it will return EMPTY_SKIN_VERSION
+  // when skin.getVersion is callled. This makes our skin picking code cleaner.
+  public final static SkinVersion EMPTY_SKIN_VERSION = new SkinVersion("");
+
+  private final boolean _default;
+  private final String _name;
+}

Propchange: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/skin/SkinVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/resources/trinidad-config.xsd
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/resources/trinidad-config.xsd?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/resources/trinidad-config.xsd (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/resources/trinidad-config.xsd Fri Feb 11 18:28:25 2011
@@ -87,11 +87,28 @@ output mode used by Apache MyFaces Trini
         <element name="skin-family" minOccurs="0" maxOccurs="1"
                  type="config:stringExpressionType">
           <annotation>
-            <documentation>The &lt;skin-family&gt; element controls the skin used for output.
+            <documentation>The &lt;skin-family&gt; element is used to pick a skin during render.
+            The skin picking logic looks at the skin-family and finds a skin that matches that
+            skin-family. This element is required to get a skin that isn't the simple skin.
+            You can optionally add the skin-version to pick a particular version of a skin
+            with the same skin-family.
             </documentation>
           </annotation>
         </element>
 
+        <element name="skin-version" minOccurs="0" maxOccurs="1"
+                 type="config:stringExpressionType">
+          <annotation>
+            <documentation>The &lt;skin-version&gt; element is used to pick a skin during render.
+            A skin is picked by matching the skin-family (required), and if specified here, the
+            skin-version. If you want the skin that is marked default, you set the skin-version to
+            "default". If you want a skin with a specific version, then you set the version here. 
+            If you don't care about the version, or if your skin does not have a version, you leave
+            this blank.
+            </documentation>
+          </annotation>
+        </element>
+        
         <element name="accessibility-mode" minOccurs="0" maxOccurs="1"
                  type="config:accessibilityModeExpressionType">
           <annotation>

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml Fri Feb 11 18:28:25 2011
@@ -36,6 +36,29 @@
             org.apache.myfaces.trinidaddemo.resource.SkinBundle
         </bundle-name>
     </skin>
+    <skin>
+        <id>
+            purple-v1.desktop
+        </id>
+        <family>
+            purple
+        </family>
+        <render-kit-id>
+            org.apache.myfaces.trinidad.desktop
+        </render-kit-id>
+        <style-sheet-name>
+            skins/purple/purpleSkin-v1.css
+        </style-sheet-name>
+        <extends>
+          purple.desktop
+        </extends>
+        <version>
+           <name>v1</name>
+        </version>
+        <bundle-name>
+            org.apache.myfaces.trinidaddemo.resource.SkinBundle
+        </bundle-name>
+    </skin>
     <!-- You can extend any skin you want. Here we want the purple
     skin, but with a bigger font size -->
     <skin>

Added: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin-v1.css
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin-v1.css?rev=1069914&view=auto
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin-v1.css (added)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin-v1.css Fri Feb 11 18:28:25 2011
@@ -0,0 +1,23 @@
+/*
+ *  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.
+ */
+
+@agent email
+{
+  af|selectBooleanCheckbox::label {color: green}
+}
\ No newline at end of file

Propchange: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin-v1.css
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java Fri Feb 11 18:28:25 2011
@@ -68,7 +68,9 @@ public class RequestContextBean extends 
   static public final PropertyKey TWO_DIGIT_YEAR_START =
     TYPE.registerKey("two-digit-year-start", Integer.class);
   static public final PropertyKey SKIN_FAMILY_KEY =
-    TYPE.registerKey("skin-family");    
+    TYPE.registerKey("skin-family");
+  static public final PropertyKey SKIN_VERSION_KEY =
+    TYPE.registerKey("skin-version");   
   static public final PropertyKey UPLOADED_FILE_PROCESSOR_KEY = 
     TYPE.registerKey("uploaded-file-processor",
                      PropertyKey.CAP_NOT_BOUND);

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Fri Feb 11 18:28:25 2011
@@ -257,6 +257,12 @@ public class RequestContextImpl extends 
   }
 
   @Override
+  public String getSkinVersion()
+  {
+    return (String) _bean.getProperty(RequestContextBean.SKIN_VERSION_KEY);
+  } 
+
+  @Override
   public Accessibility getAccessibilityMode()
   {
     String name = (String) _bean.getProperty(

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java Fri Feb 11 18:28:25 2011
@@ -590,11 +590,14 @@ public class CoreRenderingContext extend
     FacesContext   context,
     RequestContext afContext)
   {
-    // get skinFamily
+    // get skin-family
     String skinFamily = afContext.getSkinFamily();
     if (skinFamily == null)
       skinFamily = getDefaultSkinFamily();
 
+    // get skin-version
+    String skinVersionString = afContext.getSkinVersion();
+
     // get renderKitId, default is desktop renderKit
     String renderKitId = XhtmlConstants.APACHE_TRINIDAD_DESKTOP;
     if (CoreRenderKit.OUTPUT_MODE_PORTLET.equals(getOutputMode()))
@@ -616,7 +619,7 @@ public class CoreRenderingContext extend
       return;
     }
 
-    Skin skin = factory.getSkin(null, skinFamily, renderKitId);
+    Skin skin = factory.getSkin(context, skinFamily, renderKitId, skinVersionString);
 
     if (skin == null)
     {

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/RequestSkinWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/RequestSkinWrapper.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/RequestSkinWrapper.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/RequestSkinWrapper.java Fri Feb 11 18:28:25 2011
@@ -30,6 +30,7 @@ import org.apache.myfaces.trinidad.loggi
 import org.apache.myfaces.trinidad.skin.Icon;
 import org.apache.myfaces.trinidad.skin.Skin;
 import org.apache.myfaces.trinidad.skin.SkinAddition;
+import org.apache.myfaces.trinidad.skin.SkinVersion;
 import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderingContext;
 import org.apache.myfaces.trinidadinternal.skin.icon.NullIcon;
 import org.apache.myfaces.trinidadinternal.skin.icon.ReferenceIcon;
@@ -111,6 +112,12 @@ public class RequestSkinWrapper extends 
   }
 
   @Override
+  public SkinVersion getVersion()
+  {
+    return _skin.getVersion();
+  }
+  
+  @Override
   public String getRenderKitId()
   {
     return _skin.getRenderKitId();

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java Fri Feb 11 18:28:25 2011
@@ -30,7 +30,7 @@ import org.apache.myfaces.trinidad.conte
 import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidad.skin.Skin;
 import org.apache.myfaces.trinidad.skin.Icon;
-
+import org.apache.myfaces.trinidad.skin.SkinVersion;
 import org.apache.myfaces.trinidadinternal.skin.icon.ReferenceIcon;
 
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
@@ -83,6 +83,20 @@ public class SkinExtension extends SkinI
     String resourceBundleName
     )
   {
+    this(baseSkin, id, family, renderKitId, styleSheetName, 
+         resourceBundleName, SkinVersion.EMPTY_SKIN_VERSION);
+  }
+  
+  public SkinExtension(
+    Skin baseSkin,
+    String id,
+    String family,
+    String renderKitId,
+    String styleSheetName,
+    String resourceBundleName,
+    SkinVersion version
+    )
+  {
     if (baseSkin == null)
       throw new NullPointerException("Null baseSkin");
     if (id == null)
@@ -92,7 +106,8 @@ public class SkinExtension extends SkinI
       throw new NullPointerException("Null family");
     if (renderKitId == null)
       renderKitId = _DEFAULT_RENDERKIT;
-
+    if (version == null)
+      version = SkinVersion.EMPTY_SKIN_VERSION;
 
     _baseSkin = (SkinImpl)baseSkin;
     _id = id;
@@ -101,6 +116,7 @@ public class SkinExtension extends SkinI
     _styleSheetName = styleSheetName;
     _bundleName = resourceBundleName;
     _translationSourceVE = null;
+    _version = version;    
   }
   
   /**
@@ -144,6 +160,20 @@ public class SkinExtension extends SkinI
     ValueExpression translationSourceValueExpression
     )
   {
+    this(baseSkin, id, family, renderKitId, styleSheetName, 
+         translationSourceValueExpression, SkinVersion.EMPTY_SKIN_VERSION);
+  }
+  
+  public SkinExtension(
+    Skin   baseSkin,
+    String id,
+    String family,
+    String renderKitId,
+    String styleSheetName,
+    ValueExpression translationSourceValueExpression,
+    SkinVersion version
+    )
+  {
     if (baseSkin == null)
       throw new NullPointerException("Null baseSkin");
     if (id == null)
@@ -153,6 +183,8 @@ public class SkinExtension extends SkinI
       throw new NullPointerException("Null family");
     if (renderKitId == null)
       renderKitId = _DEFAULT_RENDERKIT;
+    if (version == null)
+      version = SkinVersion.EMPTY_SKIN_VERSION;
 
     _baseSkin = (SkinImpl)baseSkin;
     _id = id;
@@ -161,7 +193,8 @@ public class SkinExtension extends SkinI
     _styleSheetName = styleSheetName;
     _bundleName = null;
     _translationSourceVE = translationSourceValueExpression;
-  }
+    _version = version;
+  }  
 
   
   /**
@@ -201,6 +234,21 @@ public class SkinExtension extends SkinI
     String styleSheetName
     )
   {
+    this(baseSkin, id, family, renderKitId, styleSheetName, SkinVersion.EMPTY_SKIN_VERSION);
+  }
+  
+  /*
+   * SkinExtension without the resource bundle information, but with the version information.
+   */
+  public SkinExtension(
+    Skin baseSkin,
+    String id,
+    String family,
+    String renderKitId,
+    String styleSheetName,
+    SkinVersion version
+    )
+  {
     if (baseSkin == null)
       throw new NullPointerException("Null baseSkin");
     if (id == null)
@@ -210,6 +258,8 @@ public class SkinExtension extends SkinI
       throw new NullPointerException("Null family");
     if (renderKitId == null)
       renderKitId = _DEFAULT_RENDERKIT;
+    if (version == null)
+      version = SkinVersion.EMPTY_SKIN_VERSION;
 
     _baseSkin = (SkinImpl)baseSkin;
     _id = id;
@@ -218,7 +268,9 @@ public class SkinExtension extends SkinI
     _styleSheetName = styleSheetName;
     _bundleName = null;
     _translationSourceVE = null;
+    _version = version;
   }
+  
   /**
    * Creates a Skin which extends the specified base
    * Skin.
@@ -287,6 +339,17 @@ public class SkinExtension extends SkinI
   }
 
   /**
+   * Returns the SkinVersion object. 
+   * If version was not set when creating the SkinExtension, 
+   * this returns SkinVersion.EMPTY_SKIN_VERSION.
+   */
+  @Override
+  public SkinVersion getVersion()
+  {
+    return _version;
+  }
+  
+  /**
    * Returns the name of the style sheet for this Skin if
    * one has been set
    * @see #setStyleSheetName(String)
@@ -664,10 +727,9 @@ public class SkinExtension extends SkinI
   private String          _renderKitId;
   private SkinImpl        _baseSkin;
   private String          _styleSheetName;
-  private String          _bundleName;
   private ValueExpression _translationSourceVE;
-
-
+  private String          _bundleName;
+  private SkinVersion     _version;
 
   // The StyleSheetDocument for the base LookAndFeel's style sheet
   private StyleSheetDocument _baseStyleSheetDocument;

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinFactoryImpl.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinFactoryImpl.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinFactoryImpl.java Fri Feb 11 18:28:25 2011
@@ -18,8 +18,10 @@
  */
 package org.apache.myfaces.trinidadinternal.skin;
 
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.faces.context.FacesContext;
@@ -27,6 +29,7 @@ import javax.faces.context.FacesContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.skin.Skin;
 import org.apache.myfaces.trinidad.skin.SkinFactory;
+import org.apache.myfaces.trinidad.skin.SkinVersion;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
 
 
@@ -43,7 +46,7 @@ public class SkinFactoryImpl extends Ski
   public SkinFactoryImpl()
   {
     super();
-    _skins = new HashMap<String, Skin>();
+    _skins = new LinkedHashMap<String, Skin>();
 
   }
 
@@ -111,11 +114,43 @@ public class SkinFactoryImpl extends Ski
     String       family,
     String       renderKitId)
   {
+    return getSkin(context, family, renderKitId, null);
+  }
 
+  /**
+   * Given the skin family, renderKitId, and version, return the best matched skin.
+   * The skin picking logic is:
+   * If an exact family, renderKitId, and version (including null or "") is found, return that skin
+   * Else if the user asks for version "default", return the skin with family and renderKitId with version marked
+   * default. If version wasn't default and does not match any version for the skins with family and renderKitId, 
+   * then return the 'default' skin if there is one marked or return the last entry in the list
+   * of matching family/renderKitId skins.
+   * @param context
+   * @param family
+   * @param renderKitId
+   * @param version The version of the skin you want to return. This can be 
+   *                "default", or a version name (e.g., "v1"), or null or "" 
+   *                (if you want the skin that does not have a version set).
+   * @return the best matched Skin given the family, renderKitId, and version.
+   */
+  @Override
+  public Skin getSkin(
+    FacesContext context,
+    String       family,
+    String       renderKitId,
+    String       version)
+  {
+    // By setting the version to the empty string if version is null, we can
+    // get the skin that has a matching family and renderkit and has no skin version.
+    // (A Skin with no version returns SkinVersion.EMPTY_SKIN_VERSION for skin.getVersion(),
+    // and getName will be "")
+    if (version == null)
+        version = "";
+  
     // given a skinFamily and a renderKitId, figure out the skinId.
     // If we don't have an exact match, use the simple skin that matches the
     // renderKitId (simple.desktop or simple.pda)
-   if (family == null)
+    if (family == null)
      throw new NullPointerException("Null skin family");
 
     // default render-kit-id, if needed.
@@ -125,6 +160,7 @@ public class SkinFactoryImpl extends Ski
     // loop through each skin in the SkinFactory
     // and see if the family and the renderKitId match
     Skin matchingSkin = null;
+    List<Skin> matchingSkinList = new ArrayList<Skin>();
 
     for(Skin skin : _skins.values())
     {
@@ -132,12 +168,12 @@ public class SkinFactoryImpl extends Ski
           renderKitId.equalsIgnoreCase(skin.getRenderKitId()))
       {
         // exact family+renderKitId match!
-        matchingSkin = skin;
-        break;
+        matchingSkinList.add(skin);
       }
     }
+    
 
-    if (matchingSkin == null)
+    if (matchingSkinList.isEmpty())
     {
       // if we get here, that means we couldn't find an exact
       // family/renderKitId match, so return the simple skin
@@ -147,10 +183,6 @@ public class SkinFactoryImpl extends Ski
          _LOG.warning("CANNOT_FIND_MATCHING_SKIN", new Object[]{family, renderKitId});
        }
 
-      // if we get here, that means we couldn't find an exact
-      // family/renderKitId match, so return the simple skin
-      // that matches the renderkitid.
-
       if (renderKitId.equals(XhtmlConstants.APACHE_TRINIDAD_PORTLET))
         matchingSkin = getSkin(context, _SIMPLE_PORTLET);
       else if (renderKitId.equals(XhtmlConstants.APACHE_TRINIDAD_PDA))
@@ -158,10 +190,104 @@ public class SkinFactoryImpl extends Ski
       else
         matchingSkin = getSkin(context, _SIMPLE_DESKTOP);
     }
-
-    // If we've got a matching skin, wrap it in a RequestSkinWrapper 
+    else
+    {
+      // at this point we know we have something in the matchingSkinList
+      // which is a list of matching family and renderKitId skins. Now match the version
+      // to find the best matched skin.
+        boolean foundMatchingSkin = false;
+        boolean versionIsDefault = (_DEFAULT.compareToIgnoreCase(version) == 0);
+      // if the user didn't ask for the 'default' version, then look for the exact match
+        if (!versionIsDefault)
+        {
+          for (Skin skin : matchingSkinList)
+          {
+            SkinVersion skinVersion = skin.getVersion();
+            if (skinVersion != null)
+            {
+              String name = skinVersion.getName(); 
+              if (version.equals(name))
+              {
+                matchingSkin = skin;
+                break;
+              }
+            }
+          }          
+        }
+      // matchingSkin will be null if an exact version match (family+renderKitId+exact version) was not found;
+      // we can have an exact version match if the user asks for null version, and we find a skin with no
+      // version set.
+        if (matchingSkin == null || versionIsDefault)
+        {
+          // find skin with version= default
+          matchingSkin = _getDefaultVersionSkin(matchingSkinList);
+
+          if (matchingSkin == null)
+          {
+            // get the last skin in the matchingSkinList if there is no skin marked default.
+            matchingSkin = matchingSkinList.get(matchingSkinList.size() -1);
+          }
+          else if ((matchingSkin != null) && versionIsDefault)
+          {
+            // found the default skin the user wanted
+            foundMatchingSkin = true;
+          }
+        } // end matchingSkin == null || versionIsDefault 
+        else
+        {
+          foundMatchingSkin = true;
+        }
+        // log messages
+        if (foundMatchingSkin)
+        {
+          if (_LOG.isFine())
+            _LOG.fine("GET_SKIN_FOUND_SKIN_VERSION", 
+                      new Object[]{family, version, matchingSkin.getId()}); 
+        }
+        else
+        {
+          if(_LOG.isWarning())
+        {
+          if ("".equals(version))
+          {
+              _LOG.warning("GET_SKIN_CANNOT_FIND_NO_VERSION", 
+                           new Object[]{family, matchingSkin.getId()});  
+          }
+          else
+          { 
+            _LOG.warning("GET_SKIN_CANNOT_FIND_SKIN_VERSION", 
+                         new Object[]{family, version, matchingSkin.getId()}); 
+        }
+        }
+      }
+    }
+    
+    // If we've got a matching skin, wrap it in a RequestSkinWrapper
     // to provide access to request-specific state.
-    return (matchingSkin == null) ? null : new RequestSkinWrapper(matchingSkin);
+    return (matchingSkin == null) ? null : new RequestSkinWrapper(matchingSkin); 
+  }
+
+  /**
+   * Given a list of Skins, find the one that has its SkinVersion set to 'default', if it exists.
+   * @param matchingSkinList A list of Skins that we will look through to find the 'default'.
+   * @return Skin with SkinVersion isDefault true, otherwise, null.
+   */
+  private Skin _getDefaultVersionSkin(List<Skin> matchingSkinList)
+  {
+    Skin matchingSkin = null;
+    for (Skin skin : matchingSkinList)
+    {
+      SkinVersion skinVersion = skin.getVersion();
+      if (skinVersion != null)
+      {
+        if (skinVersion.isDefault())
+        {
+          matchingSkin = skin;
+          break;
+        }
+      }
+    }
+    return matchingSkin;
   }
 
   @Override
@@ -170,13 +296,13 @@ public class SkinFactoryImpl extends Ski
     return (_skins.keySet().iterator());
   }
 
-
   // Stores all the Skins in this SkinFactory
   private Map<String, Skin> _skins = null;
 
   static private final String _SIMPLE_PDA = "simple.pda";
   static private final String _SIMPLE_DESKTOP = "simple.desktop";
   static private final String _SIMPLE_PORTLET = "simple.portlet";
+  static private final String _DEFAULT = "default";
   static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(SkinFactoryImpl.class);
 
 }

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java Fri Feb 11 18:28:25 2011
@@ -48,6 +48,7 @@ import org.apache.myfaces.trinidad.skin.
 import org.apache.myfaces.trinidad.skin.Skin;
 
 import org.apache.myfaces.trinidad.skin.SkinAddition;
+import org.apache.myfaces.trinidad.skin.SkinVersion;
 import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderingContext;
 import org.apache.myfaces.trinidadinternal.share.config.Configuration;
 import org.apache.myfaces.trinidadinternal.skin.icon.ReferenceIcon;
@@ -98,6 +99,12 @@ abstract public class SkinImpl extends S
     return null;
   }
 
+  @Override
+  public SkinVersion getVersion()
+  {
+    return SkinVersion.EMPTY_SKIN_VERSION;
+  }  
+
   /**
    * Returns the renderKitId for the Skin.
    */

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java Fri Feb 11 18:28:25 2011
@@ -47,7 +47,7 @@ import org.apache.myfaces.trinidad.share
 import org.apache.myfaces.trinidad.skin.Icon;
 import org.apache.myfaces.trinidad.skin.Skin;
 import org.apache.myfaces.trinidad.skin.SkinAddition;
-
+import org.apache.myfaces.trinidad.skin.SkinVersion;
 import org.apache.myfaces.trinidadinternal.config.LazyValueExpression;
 import org.apache.myfaces.trinidadinternal.renderkit.core.skin.MinimalDesktopSkinExtension;
 import org.apache.myfaces.trinidadinternal.renderkit.core.skin.MinimalPdaSkinExtension;
@@ -66,11 +66,11 @@ import org.apache.myfaces.trinidadintern
 import org.apache.myfaces.trinidadinternal.share.xml.TreeBuilder;
 import org.apache.myfaces.trinidadinternal.share.xml.XMLProvider;
 import org.apache.myfaces.trinidadinternal.share.xml.XMLUtils;
-
 import org.apache.myfaces.trinidadinternal.skin.icon.ReferenceIcon;
 import org.apache.myfaces.trinidadinternal.skin.parse.XMLConstants;
 import org.apache.myfaces.trinidadinternal.skin.parse.SkinAdditionNode;
 import org.apache.myfaces.trinidadinternal.skin.parse.SkinNode;
+import org.apache.myfaces.trinidadinternal.skin.parse.SkinVersionNode;
 import org.apache.myfaces.trinidadinternal.skin.parse.SkinsNode;
 
 /**
@@ -285,6 +285,7 @@ public class SkinUtils
     // Register skin node factory and skin addition node factory
     _registerFactory(manager, SkinNode.class, "SkinNode");
     _registerFactory(manager, SkinAdditionNode.class, "SkinAdditionNode");
+    _registerFactory(manager, SkinVersionNode.class, "SkinVersionNode");
 
     return manager;
   }
@@ -544,6 +545,9 @@ public class SkinUtils
     String bundleName = skinNode.getBundleName();
     String translationSourceExpression = 
       skinNode.getTranslationSourceExpression();
+    SkinVersionNode skinVersionNode = skinNode.getSkinVersionNode();
+    
+    SkinVersion skinVersion = _createSkinVersion(skinVersionNode);
     
     if (renderKitId == null)
       renderKitId = _RENDER_KIT_ID_DESKTOP;
@@ -591,7 +595,8 @@ public class SkinUtils
                                family,
                                renderKitId,
                                styleSheetName,
-                               bundleName);    
+                               bundleName,
+                               skinVersion);    
     }
     else
     {
@@ -609,7 +614,8 @@ public class SkinUtils
                                  family,
                                  renderKitId,
                                  styleSheetName,
-                                 translationSourceVE);         
+                                 translationSourceVE,
+                                 skinVersion);         
       }
       else
       {
@@ -617,7 +623,8 @@ public class SkinUtils
                                  id,
                                  family,
                                  renderKitId,
-                                 styleSheetName);         
+                                 styleSheetName,
+                                 skinVersion);         
       }
 
     }
@@ -643,6 +650,22 @@ public class SkinUtils
 
   }
   
+  // Create a SkinVersion object from the SkinVersionNode object.
+  private static SkinVersion _createSkinVersion(SkinVersionNode skinVersionNode)
+  {
+    if (skinVersionNode != null)
+    {
+      String name = skinVersionNode.getName();
+      boolean isDefault = skinVersionNode.isDefault();
+      if ("".equals(name) && !isDefault)
+         return SkinVersion.EMPTY_SKIN_VERSION;
+      else
+        return new SkinVersion(name, isDefault);
+    }
+    else
+      return SkinVersion.EMPTY_SKIN_VERSION;
+  }
+  
   /**
    * Get the WEB-INF/trinidad-skins.xml file, parse it, and return a List of SkinsNode objects. 
    * @param context ServletContext used to getResourceAsStream

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNode.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNode.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNode.java Fri Feb 11 18:28:25 2011
@@ -19,6 +19,7 @@
 package org.apache.myfaces.trinidadinternal.skin.parse;
 
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+import org.apache.myfaces.trinidad.skin.SkinVersion;
 
 /**
  * Object which represents a single &lt;skin&gt; element in trinidad-skins.xml.
@@ -37,7 +38,8 @@ public class SkinNode
     String skinExtends,
     String styleSheetName,
     String bundleName,
-    String translationSourceExpression)
+    String translationSourceExpression,
+    SkinVersionNode skinVersionNode)
   {
     
     if (id==null)
@@ -58,6 +60,7 @@ public class SkinNode
     _styleSheetName = styleSheetName;
     _bundleName = bundleName;
     _translationSourceExpression = translationSourceExpression;
+    _skinVersionNode = skinVersionNode;
 
   }
 
@@ -76,6 +79,14 @@ public class SkinNode
   {
     return _family;
   }
+  
+  /**
+   * Returns the skin version for this node
+   */
+  public SkinVersionNode getSkinVersionNode()
+  {
+    return _skinVersionNode;
+  }  
 
   /**
    * Returns the renderKitId for this node.
@@ -119,13 +130,14 @@ public class SkinNode
   }   
 
   
-  private String _id;
-  private String _family;
-  private String _renderKitId;
-  private String _skinExtends;
-  private String _styleSheetName;
-  private String _bundleName;
-  private String _translationSourceExpression;
+  private final String          _id;
+  private final String          _family;
+  private final SkinVersionNode _skinVersionNode;
+  private final String          _renderKitId;
+  private final String          _skinExtends;
+  private final String          _styleSheetName;
+  private final String          _bundleName;
+  private final String          _translationSourceExpression;
 
 
   private static final TrinidadLogger _LOG =

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNodeParser.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNodeParser.java?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNodeParser.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinNodeParser.java Fri Feb 11 18:28:25 2011
@@ -75,8 +75,8 @@ public class SkinNodeParser extends Base
       _translationSourceExpression = null;
     }
 
-    return new SkinNode(_id, _family, _renderKitId, _extends,
-                        _styleSheetName, _bundleName, _translationSourceExpression);
+    return new SkinNode(_id, _family, _renderKitId, _extends, _styleSheetName, 
+                        _bundleName, _translationSourceExpression, _skinVersionNode);
   }
 
   @Override
@@ -101,6 +101,10 @@ public class SkinNodeParser extends Base
     {
       return new StringParser();
     }
+    else if ("version".equals(localName))
+    {
+      return context.getParser(SkinVersionNode.class, namespaceURI, localName);
+    }
 
     return null;
   }
@@ -128,9 +132,10 @@ public class SkinNodeParser extends Base
       _translationSourceExpression = (String) child;
     else if ("extends".equals(localName))
       _extends = (String) child;
+    else if ((child instanceof SkinVersionNode))    
+      _skinVersionNode = ((SkinVersionNode)child);
   }
 
-
   private String      _namespace;
   private String      _id;
   private String      _family;
@@ -139,7 +144,7 @@ public class SkinNodeParser extends Base
   private String      _bundleName;
   private String      _translationSourceExpression;
   private String      _extends;
-
+  private SkinVersionNode _skinVersionNode;
 
   private static final TrinidadLogger _LOG = 
     TrinidadLogger.createTrinidadLogger(SkinNodeParser.class);

Added: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNode.java?rev=1069914&view=auto
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNode.java (added)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNode.java Fri Feb 11 18:28:25 2011
@@ -0,0 +1,58 @@
+/*
+ *  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.
+ */
+package org.apache.myfaces.trinidadinternal.skin.parse;
+
+/**
+ * Object which represents a single &lt;version&gt; element in trinidad-skins.xml.
+ *
+ * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/ui/laf/xml/parse/SkinPropertyNode.java#0 $) $Date: 10-nov-2005.18:50:45 $
+ */
+public class SkinVersionNode
+{
+
+  /**
+   * 
+   */
+  public SkinVersionNode (
+    String name,
+    boolean defaultVersion
+    )
+  {
+    _name = name;
+    _default = defaultVersion;
+  }
+  
+  public String getName()
+  {
+    return _name;
+  }  
+  
+  /**
+   * Returns the resource bundle name. The actual ResourceBundle will
+   * be resolved by the Skin by using the LocaleContext. 
+   */    
+  public boolean isDefault()
+  {
+    return _default;
+  } 
+   
+  private final String  _name;
+  private final boolean _default;
+
+}

Propchange: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNodeParser.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNodeParser.java?rev=1069914&view=auto
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNodeParser.java (added)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNodeParser.java Fri Feb 11 18:28:25 2011
@@ -0,0 +1,110 @@
+/*
+ *  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.
+ */
+package org.apache.myfaces.trinidadinternal.skin.parse;
+
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+import org.apache.myfaces.trinidadinternal.share.xml.StringParser;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXParseException;
+
+import org.apache.myfaces.trinidadinternal.share.xml.BaseNodeParser;
+import org.apache.myfaces.trinidadinternal.share.xml.NodeParser;
+import org.apache.myfaces.trinidadinternal.share.xml.ParseContext;
+
+/**
+ * This class is used when we parse the trinidad-skins.xml file and there is a 'version' element
+ * as a child of the 'skin' element. A 'version' has both a 'name' (required) and 
+ * a 'default' (optional) element. After parsing, a SkinVersion object is created and attached
+ * to the Skin object.
+ * @see SkinVersionNode
+ * @see org.apache.myfaces.trinidadinternal.skin.SkinUtils
+ * @see org.apache.myfaces.trinidad.skin.SkinVersion
+ */
+public class SkinVersionNodeParser  extends BaseNodeParser
+  implements XMLConstants
+{
+  @Override
+  public void startElement(
+    ParseContext context,
+    String       namespaceURI,
+    String       localName,
+    Attributes   attrs
+    ) throws SAXParseException
+  {
+  }
+
+  @Override
+  public Object endElement(
+    ParseContext context,
+    String       namespaceURI,
+    String       localName
+    ) throws SAXParseException
+  {
+    // allow no name in version.
+    if (_name == null)
+      _name = "";
+
+    return new SkinVersionNode(_name, "true".equals(_default));
+  }
+
+  @Override
+  public NodeParser startChildElement(
+    ParseContext context,
+    String       namespaceURI,
+    String       localName,
+    Attributes   attrs
+    ) throws SAXParseException
+  {
+
+    if ("name".equals(localName) ||
+        "default".equals(localName))
+
+    {
+      return new StringParser();
+    }
+
+    return null;
+  }
+
+  @Override
+  public void addCompletedChild(
+    ParseContext context,
+    String       namespaceURI,
+    String       localName,
+    Object       child
+    ) throws SAXParseException
+  {
+
+    if ("name".equals(localName))
+      _name = (String) child;
+    else if ("default".equals(localName))
+    {
+      _default = (String) child;
+      // <default/> means true
+      if (_default == null || "".equals(_default))
+        _default = "true";
+    }
+  }
+
+  private String _name;
+  private String _default;
+
+  private static final TrinidadLogger _LOG = 
+    TrinidadLogger.createTrinidadLogger(SkinVersionNodeParser.class);
+}

Propchange: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/parse/SkinVersionNodeParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/ui/laf/xml/schemas/skin/trinidad-skins.xsd
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/ui/laf/xml/schemas/skin/trinidad-skins.xsd?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/ui/laf/xml/schemas/skin/trinidad-skins.xsd (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/ui/laf/xml/schemas/skin/trinidad-skins.xsd Fri Feb 11 18:28:25 2011
@@ -58,6 +58,11 @@
                              implementation belongs.</xsd:documentation>
         </xsd:annotation>
       </xsd:element>
+      <xsd:element name="version" type="skin:versionType" minOccurs="1" maxOccurs="1">
+        <xsd:annotation>
+          <xsd:documentation>The version of the skin, if any.</xsd:documentation>
+        </xsd:annotation>
+      </xsd:element>      
       <xsd:element name="render-kit-id" type="string" minOccurs="0" maxOccurs="1">
         <xsd:annotation>
           <xsd:documentation>This value determines which render kit to use for the skin. You can
@@ -81,6 +86,22 @@
       <xsd:element ref="skin:bundleSource" minOccurs="0" maxOccurs="1" />
     </xsd:all>
   </xsd:complexType>
+  <xsd:complexType name="versionType">
+    <xsd:all>
+      <xsd:element name="name" maxOccurs="1" minOccurs="1" type="string">
+        <xsd:annotation>
+          <xsd:documentation>Defines a skin version name.</xsd:documentation>
+        </xsd:annotation>
+      </xsd:element>
+      <xsd:element name="default" maxOccurs="1" minOccurs="0" type="boolean">
+        <xsd:annotation>
+          <xsd:documentation>true if this skin is the default skin for the specified skin family. 
+          The default skin will be picked if the trinidad-config's skin-version is not set
+          or it is set to "default".</xsd:documentation>
+        </xsd:annotation>
+      </xsd:element>
+    </xsd:all>
+  </xsd:complexType>
   <xsd:complexType name="skinAdditionType">
     <xsd:sequence>
       <xsd:element name="skin-id" type="string" minOccurs="1" maxOccurs="1">

Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts?rev=1069914&r1=1069913&r2=1069914&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts Fri Feb 11 18:28:25 2011
@@ -455,6 +455,15 @@ The skin {0} specified on the requestMap
 <!-- CANNOT_FIND_MATCHING_SKIN -->
 <resource key="CANNOT_FIND_MATCHING_SKIN">Can''t find a skin that matches family {0} and renderkit {1}, so we will use the simple skin</resource>
 
+<!-- GET_SKIN_FOUND_SKIN_VERSION -->
+<resource key="GET_SKIN_FOUND_SKIN_VERSION">Found a skin that matches family {0} and version {1}. We will use skin {2}.</resource>
+
+<!-- GET_SKIN_CANNOT_FIND_SKIN_VERSION -->
+<resource key="GET_SKIN_CANNOT_FIND_SKIN_VERSION">Cannot find a skin that matches family {0} and version {1}. We will use the skin {2}.</resource>
+
+<!-- GET_SKIN_CANNOT_FIND_NO_VERSION -->
+<resource key="GET_SKIN_CANNOT_FIND_NO_VERSION">Cannot find an unversioned skin for family {0}. We will use the versioned skin {1}.</resource>
+
 <!-- CANNOT_GET_STYLESHEET_DOCUMENT_TIMESTAMP -->
 <resource key="CANNOT_GET_STYLESHEET_DOCUMENT_TIMESTAMP">Could not get the stylesheet document's timestamp because we couldn't open the connection.</resource>
 
@@ -623,6 +632,9 @@ The skin {0} specified on the requestMap
 <!-- REQURIED_ELEMENT_FAMILY_NOT_FOUND -->
 <resource key="REQURIED_ELEMENT_FAMILY_NOT_FOUND">Required element 'family' not found.</resource>
 
+<!-- REQURIED_ELEMENT_SKINVERSION_NOT_FOUND -->
+<resource key="REQURIED_ELEMENT_SKINVERSION_NOT_FOUND">Required child element for 'version', 'name' not found.</resource>
+
 <!-- MALFORMED_PROPERTY_ENTRY -->
 <resource key="MALFORMED_PROPERTY_ENTRY">Malformed property entry: {0}={1}</resource>
 



Mime
View raw message