incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r462863 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin: SkinImpl.java SkinStyleSheetParserUtils.java StyleSheetEntry.java
Date Wed, 11 Oct 2006 17:15:59 GMT
Author: jwaldman
Date: Wed Oct 11 10:15:58 2006
New Revision: 462863

URL: http://svn.apache.org/viewvc?view=rev&rev=462863
Log:
fix todo for registering icons and properties from an extension style sheet in SkinImpl.java,
so now you can registerStyleSheet on a particular skin instance and that stylesheet's css
definitions, icons and properties will be included into the skin. The other two files are
comment changes only.

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java?view=diff&rev=462863&r1=462862&r2=462863
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
Wed Oct 11 10:15:58 2006
@@ -405,6 +405,60 @@
 
     return modified;
   }
+  
+  private void _registerIconsAndPropertiesFromStyleSheetEntry(
+    StyleSheetEntry entry)
+  {
+    // register the icons and properties if there are any.
+    // get a List of IconNodes, and register them.
+    if (entry != null)
+    {
+      // register icons
+      List<IconNode> icons = entry.getIcons();
+      if (icons != null)
+      {
+        for(IconNode iconNode : icons)
+        {
+          registerIcon(iconNode.getIconName(), iconNode.getIcon());
+        }
+      }
+      
+      // register properties
+      List<SkinPropertyNode> skinProperties = entry.getSkinProperties();
+      
+      if (skinProperties != null)
+      {
+        for(SkinPropertyNode property : skinProperties)
+        {
+          Object propValueObj = property.getPropertyValue();
+          // Store the property selector + property Name as the Skin Property Key.
+          // e.g., use af|breadCrumbs-tr-show-last-item
+
+          String key = property.getPropertySelector() +
+                       property.getPropertyName();
+          // look up in map to get conversion
+          Class<?> type = _PROPERTY_CLASS_TYPE_MAP.get(key);
+          if (type != null)
+          {
+            try
+            {
+              // coerce the value to the type
+              propValueObj = Coercions.coerce(null, (String)propValueObj,
+                            type);
+            }
+            catch (IllegalArgumentException ex)
+            {
+              if (_LOG.isWarning())
+                _LOG.warning(ex);
+            }
+          }
+
+
+          setProperty(key, propValueObj);
+        }
+      }
+    }    
+  }
 
   // Creates the StyleSheetDocument for this Skin
   // (as a side effect, this also registers icons and skin properties
@@ -421,68 +475,12 @@
     {
       String styleSheetName = getStyleSheetName();
 
-      // =-=jmw I'm not sure where a good place is to parse the css file and
-      // register the icons and properties. For now, I suppose I can do it here.
-
       if (styleSheetName != null)
       {
         _skinStyleSheet = StyleSheetEntry.createEntry(context, styleSheetName);
-
-
-        // register the icons and properties if there are any.
-        // this is a strange place for this. Where is a better spot???
-        // get a List of IconNodes, and register them.
-        if (_skinStyleSheet != null)
-        {
-          // register icons
-          List<IconNode> icons = _skinStyleSheet.getIcons();
-          if (icons != null)
-          {
-            for(IconNode iconNode : icons)
-            {
-              registerIcon(iconNode.getIconName(), iconNode.getIcon());
-            }
-          }
-          
-          // register properties
-          List<SkinPropertyNode> skinProperties = 
-            _skinStyleSheet.getSkinProperties();
-          
-          if (skinProperties != null)
-          {
-            for(SkinPropertyNode property : skinProperties)
-            {
-              Object propValueObj = property.getPropertyValue();
-              // Store the property selector + property Name as the Skin Property Key.
-              // e.g., use af|breadCrumbs-tr-show-last-item
-
-              String key = property.getPropertySelector() +
-                           property.getPropertyName();
-              // look up in map to get conversion
-              Class<?> type = _PROPERTY_CLASS_TYPE_MAP.get(key);
-              if (type != null)
-              {
-                try
-                {
-                  // coerce the value to the type
-                  propValueObj = Coercions.coerce(null, (String)propValueObj,
-                                type);
-                }
-                catch (IllegalArgumentException ex)
-                {
-                  if (_LOG.isWarning())
-                    _LOG.warning(ex);
-                }
-              }
-
-
-              setProperty(key, propValueObj);
-            }
-          }
-        }
+        _registerIconsAndPropertiesFromStyleSheetEntry(_skinStyleSheet);
       }
 
-
       // Now create entries for UIExtension-specific style sheets.
       _extensionStyleSheets = _getExtensionStyleSheets(context);
     }
@@ -501,21 +499,28 @@
       for (int i = 0; i < _extensionStyleSheets.length; i++)
       {
         StyleSheetEntry entry = _extensionStyleSheets[i];
-        StyleSheetDocument extensionDocument = entry.getDocument();
-
-        if (extensionDocument != null)
+        if (entry != null)
         {
-          // Merge the UIExtension's StyleSheetDocument on top of
-          // the current StyleSheetDocument.  Note: This is not
-          // exactly efficient - we would be better off creating
-          // an array of StyleSheetDocuments and merging them all
-          // in one pass.  But since this code should rarely be
-          // executed, this shouldn't be a bottleneck...
-          document = StyleSheetDocumentUtils.mergeStyleSheetDocuments(
-                                               document,
-                                               extensionDocument);
-          // =-=jmw @todo when we have extension documents, we'll need
-          // to register icons and skin properties from those on the skin?
+          // add the icons and properties that are in the 
+          // extensionDocument's StyleSheetEntry
+           _registerIconsAndPropertiesFromStyleSheetEntry(entry);
+           
+          // now merge the css properties
+          StyleSheetDocument extensionDocument = entry.getDocument();
+  
+          if (extensionDocument != null)
+          {
+            // Merge the UIExtension's StyleSheetDocument on top of
+            // the current StyleSheetDocument.  Note: This is not
+            // exactly efficient - we would be better off creating
+            // an array of StyleSheetDocuments and merging them all
+            // in one pass.  But since this code should rarely be
+            // executed, this shouldn't be a bottleneck...
+            document = StyleSheetDocumentUtils.mergeStyleSheetDocuments(
+                                                 document,
+                                                 extensionDocument);
+  
+          }
         }
       }
     }

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java?view=diff&rev=462863&r1=462862&r2=462863
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
Wed Oct 11 10:15:58 2006
@@ -99,6 +99,7 @@
     {
 
       // Store a resolver relative to the file we're about to parse
+      // =-=jmw TODO are these two lines needed?
       XMLUtils.setResolver(context, resolver.getResolver(sourceName));
       XMLUtils.setInputStreamProvider(context, provider);
 

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java?view=diff&rev=462863&r1=462862&r2=462863
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java
Wed Oct 11 10:15:58 2006
@@ -403,7 +403,6 @@
   private List <IconNode> _icons;
   // List of -tr- properties that the skin can be set on the skin.
   // This is a List of SkinPropertyNodes
-  // jmw it will be key, name, value. or name/value???
   private List <SkinPropertyNode> _skinProperties;
 
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(StyleSheetEntry.class);



Mime
View raw message