You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by aw...@apache.org on 2007/04/16 20:42:26 UTC

svn commit: r529393 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal: share/config/ style/ style/cache/ style/util/ style/xml/parse/ ui/laf/base/xhtml/

Author: awiner
Date: Mon Apr 16 13:42:25 2007
New Revision: 529393

URL: http://svn.apache.org/viewvc?view=rev&rev=529393
Log:
Remove long-obsoleted and unused UserStyleSheet class

Removed:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/UserStyleSheet.java
Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/config/Configuration.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/config/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/config/Configuration.java?view=diff&rev=529393&r1=529392&r2=529393
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/config/Configuration.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/config/Configuration.java Mon Apr 16 13:42:25 2007
@@ -152,25 +152,6 @@
   static public final Object IMAGE_SERVLET_URL = "imageServletURL";
 
 
-  /**
-   * Key used to specify the URL location of the ImageServlet to use
-   * for image generation.
-   *
-   * @deprecated Use IMAGE_SERVLET_URL
-   */
-  @Deprecated
-  static public final Object TECATE_SERVLET_URL = IMAGE_SERVLET_URL;
-
-  /**
-   * Key for the UserStyleSheetProperty.  The styles defined by the
-   * UserStyleSheet instance stored are merged with styles defined
-   * by the UIX Styles StyleProvider when generating a new style sheet.
-   *
-   * @see org.apache.myfaces.trinidadinternal.style.UserStyleSheet
-   * @see org.apache.myfaces.trinidadinternal.style.StyleProvider
-   */
-  static public final Object USER_STYLE_SHEET = "userStyleSheet";
-
   public static final Object DISABLE_STANDARDS_MODE =
     "disableStandardsMode";
 

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?view=diff&rev=529393&r1=529392&r2=529393
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java Mon Apr 16 13:42:25 2007
@@ -60,7 +60,6 @@
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
 import org.apache.myfaces.trinidadinternal.style.StyleMap;
 import org.apache.myfaces.trinidadinternal.style.StyleProvider;
-import org.apache.myfaces.trinidadinternal.style.UserStyleSheet;
 import org.apache.myfaces.trinidadinternal.style.util.CSSGenerationUtils;
 import org.apache.myfaces.trinidadinternal.style.util.NameUtils;
 import org.apache.myfaces.trinidadinternal.style.xml.StyleSheetDocumentUtils;
@@ -993,31 +992,18 @@
 
       LocaleContext localeContext = context.getLocaleContext();
 
-      UserStyleSheet styleSheet = UserStyleSheet.getUserStyleSheet(context);
-
       _init(
        localeContext.getTranslationLocale(),
        LocaleUtils.getReadingDirection(localeContext),
        agent.getAgentApplication(),
        agent.getAgentMajorVersion(),
        agent.getAgentOS(),
-       styleSheet,
        true);
     }
 
     @Override
     public int hashCode()
     {
-      // We treat the UserStyleSheet specially.  We want to have one and
-      // only one entry for a particular user style sheet ID.  So, we avoid
-      // hashing directly on the UserStyleSheet object.  That way, if the
-      // styles for a particular UserStyleSheet ID changes, we can still find
-      // the same old entry in the FileSystemStyleCache, and re-generate the
-      // CSS/StyleMap as necessary.
-      int userStyleSheetHashCode = 0;
-      if (_userStyleSheet != null)
-        userStyleSheetHashCode = _userStyleSheet.getID().hashCode();
-
       int shortHash = (_short ? 1 : 0);
 
       return (_locale.hashCode()           ^
@@ -1025,18 +1011,12 @@
                (_browser  << 2)            ^
                (_version  << 4)            ^
                (_platform << 8)            ^
-               shortHash                   ^
-               userStyleSheetHashCode);
+               shortHash);
     }
 
     @Override
     public boolean equals(Object o)
     {
-      // As documented in our hashCode() implementation, we treat
-      // UserStyleSheets specially.  Two keys are equals if they have the
-      // UserStyleSheet ID.  Later on we can actually check to see if the
-      // styles have changed, but we still want to use the same Key even if
-      // that is the case.
       if (this == o)
         return true;
 
@@ -1054,18 +1034,6 @@
         {
           return false;
         }
-
-        // Check for matching UserStyleSheets IDs
-        if (_userStyleSheet == null)
-        {
-          if (key._userStyleSheet != null)
-            return false;
-        }
-        else if ((key._userStyleSheet == null) ||
-                 !_userStyleSheet.getID().equals(key._userStyleSheet.getID()))
-        {
-          return false;
-        }
       }
 
       return true;
@@ -1077,7 +1045,6 @@
       int browser,
       int version,
       int platform,
-      UserStyleSheet userStyleSheet,
       boolean useShort
       )
     {
@@ -1093,7 +1060,6 @@
       _browser = browser;
       _version = version;
       _platform = platform;
-      _userStyleSheet = userStyleSheet;
       _short = useShort;
     }
 
@@ -1102,7 +1068,6 @@
     private int            _browser;
     private int            _version;
     private int            _platform;
-    private UserStyleSheet _userStyleSheet;
     private boolean        _short;  // Do we use short style classes?
   }
 
@@ -1127,7 +1092,6 @@
   {
     public DerivationKey(StyleContext context, StyleSheetNode[] styleSheets)
     {
-      _userStyleSheet = UserStyleSheet.getUserStyleSheet(context);
       _styleSheets = new StyleSheetNode[styleSheets.length];
       System.arraycopy(styleSheets, 0, _styleSheets, 0, styleSheets.length);
       _short = true;
@@ -1148,18 +1112,6 @@
           (_styleSheets.length != key._styleSheets.length))
         return false;
 
-      // Check for matching UserStyleSheets IDs
-      if (_userStyleSheet == null)
-      {
-        if (key._userStyleSheet != null)
-          return false;
-      }
-      else if ((key._userStyleSheet == null) ||
-               !_userStyleSheet.getID().equals(key._userStyleSheet.getID()))
-      {
-        return false;
-      }
-
       // Test each StyleSheetNode for equality.  We start
       // at the end of the list, as the last style sheet
       // is more likely to be different.  (The first entry
@@ -1178,11 +1130,6 @@
     {
       int hashCode = 0;
 
-      // Only hash on the UserStyleSheet ID.  We don't hash on the styles as
-      // any two UserStyleSheets with the same ID should use the same key.
-      if (_userStyleSheet != null)
-        hashCode ^= _userStyleSheet.getID().hashCode();
-
       for (int i = 0; i < _styleSheets.length; i++)
         hashCode ^= _styleSheets[i].hashCode();
 
@@ -1192,7 +1139,6 @@
     }
 
     private StyleSheetNode[] _styleSheets;
-    private UserStyleSheet   _userStyleSheet;
     private boolean          _short;   // Do we use short style classes?
   }
 

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java?view=diff&rev=529393&r1=529392&r2=529393
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java Mon Apr 16 13:42:25 2007
@@ -28,7 +28,6 @@
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
 
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
-import org.apache.myfaces.trinidadinternal.style.UserStyleSheet;
 
 import org.apache.myfaces.trinidadinternal.style.xml.parse.StyleSheetDocument;
 import org.apache.myfaces.trinidadinternal.style.xml.parse.StyleSheetNode;
@@ -261,12 +260,6 @@
     buffer.append(_getPlatformString(context));
     buffer.append(_getModeString(context));
     buffer.append(_VARIANT_SEPARATOR);   
-    String userStyleSheetString = _getUserStyleSheetString(context);
-    if (userStyleSheetString != null)
-    {
-      buffer.append(_VARIANT_SEPARATOR);
-      buffer.append(userStyleSheetString);
-    }
 
     return buffer.toString();
   }
@@ -382,14 +375,6 @@
       needSeparator = true;
     }
 
-    String userStyleSheetString = _getUserStyleSheetString(context);
-    if (userStyleSheetString != null)
-    {
-      if (needSeparator)
-        buffer.append(_VARIANT_SEPARATOR);
-      buffer.append(userStyleSheetString);
-    }
-
     return buffer.toString();
   }
 
@@ -477,16 +462,6 @@
       return _UNKNOWN_NAME;
 
     return name;
-  }
-
-  // Get the name of the UserStyleSheet for this context
-  private static String _getUserStyleSheetString(StyleContext context)
-  {
-    UserStyleSheet userStyleSheet = UserStyleSheet.getUserStyleSheet(context);
-    if (userStyleSheet == null)
-      return null;
-
-    return userStyleSheet.getID();
   }
 
   // Tests whether the locale specified in the context match the

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java?view=diff&rev=529393&r1=529392&r2=529393
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java Mon Apr 16 13:42:25 2007
@@ -26,7 +26,6 @@
 import java.util.Locale;
 import java.util.NoSuchElementException;
 import java.util.Stack;
-import java.util.Vector;
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.List;
@@ -44,7 +43,6 @@
 import org.apache.myfaces.trinidadinternal.style.PropertyParseException;
 import org.apache.myfaces.trinidadinternal.style.Style;
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
-import org.apache.myfaces.trinidadinternal.style.UserStyleSheet;
 import org.apache.myfaces.trinidadinternal.style.util.CSSUtils;
 import org.apache.myfaces.trinidadinternal.style.util.ModeUtils;
 import org.apache.myfaces.trinidadinternal.style.util.NameUtils;
@@ -177,8 +175,7 @@
    */
   public Iterator<StyleSheetNode> getStyleSheets(StyleContext context)
   {
-    // =-=ags Should this include the UserStyleSheet?
-     StyleSheetNode[] styleSheets = _getStyleSheets(context,false);
+     StyleSheetNode[] styleSheets = _getStyleSheets(context);
     if(styleSheets == null)
       return (Arrays.asList(new StyleSheetNode[0])).iterator();
     else
@@ -192,13 +189,13 @@
   public Iterator<StyleNode> getStyles(StyleContext context)
   {
     // Get the matching style sheets, including the UserStyleSheet
-    StyleSheetNode[] styleSheets = _getStyleSheets(context, true);
+    StyleSheetNode[] styleSheets = _getStyleSheets(context);
     if (styleSheets == null)
       return EmptyIterator.getInstance();
 
     // We are going to loop through every StyleNode in every StyleSheetNode,
     // resolving each one along the way.  We store resolved StyleNodes in
-    // a Vector, so that the generated CSS somewhat matches the order that
+    // a List, so that the generated CSS somewhat matches the order that
     // the style elements appear in the XSS document.
     ArrayList<StyleNode> styles = new ArrayList<StyleNode>();
 
@@ -307,8 +304,7 @@
 
   // Returns array of matching style sheets sorted by specificity
   private StyleSheetNode[] _getStyleSheets(
-    StyleContext context,
-    boolean      includeUserStyleSheet
+    StyleContext context
     )
   {
     LocaleContext localeContext = context.getLocaleContext();
@@ -317,18 +313,16 @@
     int mode = NameUtils.getMode(ModeUtils.getCurrentMode(context));
     TrinidadAgent agent = context.getAgent();
 
-    // -= Simon Lessard =- 
-    // TODO: Check if synchronization is truly required    
-    Vector<StyleSheetNode> v = new Vector<StyleSheetNode>(); // Vector of matching style sheets
-    Iterator<StyleSheetNode> e = getStyleSheets();  // Enum of all style sheets
+    List<StyleSheetNode> v = new ArrayList<StyleSheetNode>(); // List of matching style sheets
+    Iterator<StyleSheetNode> e = getStyleSheets();  // Iterator of all style sheets
 
-    // Loop through the style sheets, storing matches in the Vector
+    // Loop through the style sheets, storing matches in the List
     while (e.hasNext())
     {
       StyleSheetNode styleSheet = e.next();
 
       if (styleSheet.compareVariants(locale, direction, agent, mode) > 0)
-        v.addElement(styleSheet);
+        v.add(styleSheet);
     }
 
     int count = v.size();
@@ -336,8 +330,7 @@
       return null;
 
     // Sort the matching style sheets by specificity
-    StyleSheetNode[] styleSheets = new StyleSheetNode[count];
-    v.copyInto(styleSheets);
+    StyleSheetNode[] styleSheets = v.toArray(new StyleSheetNode[count]);
     Comparator<StyleSheetNode> comparator = 
       new StyleSheetComparator(locale,
                                direction,
@@ -347,25 +340,6 @@
 
     Arrays.sort(styleSheets, comparator);
 
-
-    // If we've got a UserStyleSheet, convert it to a StyleSheetNode and
-    // add it to the end of the list (highest precedence)
-    if (includeUserStyleSheet)
-    {
-      UserStyleSheet userStyleSheet =
-        UserStyleSheet.getUserStyleSheet(context);
-      if (userStyleSheet != null)
-      {
-        StyleSheetNode[] tmpSheets =
-          new StyleSheetNode[styleSheets.length + 1];
-        System.arraycopy(styleSheets, 0, tmpSheets, 0, styleSheets.length);
-        tmpSheets[tmpSheets.length - 1] =
-          _createStyleSheetNode(userStyleSheet);
-
-        styleSheets = tmpSheets;
-      }
-    }
-
     return styleSheets;
   }
 
@@ -376,7 +350,7 @@
     boolean      isNamed
     )
   {
-    StyleSheetNode[] styleSheets = _getStyleSheets(context, true);
+    StyleSheetNode[] styleSheets = _getStyleSheets(context);
     if (styleSheets == null)
       return null;
 
@@ -666,8 +640,8 @@
 
   }
 
-  // Returns a count of the non-null items in the Vector
-  private static int _getNonNullCount(ArrayList<?> list)
+  // Returns a count of the non-null items in the List
+  private static int _getNonNullCount(List<?> list)
   {
     if (list == null)
       return 0;
@@ -740,54 +714,13 @@
     return null;
   }
 
-  // Coverts a UserStyleSheet into a StyleSheetNode
-  private StyleSheetNode _createStyleSheetNode(UserStyleSheet userStyleSheet)
-  {
-    // Convert each Style in the userStyleSheet to a StyleNode
-    // -= Simon Lessard =- 
-    // TODO: Check if synchronization is truly required
-    Vector<StyleNode> v = new Vector<StyleNode>();
-
-    // First, add the selector-based styles
-    Iterator<Object> selectors = userStyleSheet.getSelectors();
-    while (selectors.hasNext())
-    {
-      String selector = (String)selectors.next();
-      Style style = userStyleSheet.getStyle(selector);
-
-      v.addElement(_createStyleNode(selector, style, false));
-    }
-
-    // Now, add in the named styles
-    Iterator<Object> names = userStyleSheet.getNames();
-    while (names.hasNext())
-    {
-      String name = (String)names.next();
-      Style style = userStyleSheet.getNamedStyle(name);
-
-      v.addElement(_createStyleNode(name, style, true));
-    }
-
-    StyleNode[] nodes = new StyleNode[v.size()];
-    v.copyInto(nodes);
-
-    return new StyleSheetNode(nodes, // The StyleNodes
-                              null,  // locales - we don't care
-                              LocaleUtils.DIRECTION_DEFAULT,  // direction
-                              null,  // browsers - we don't care
-                              null,  // versions - we don't care
-                              null,   // platforms - we don't care
-                              ModeUtils.MODE_DEFAULT);
-  }
 
   // Creates a StyleNode for the specified Style.  The key is either a
   // selector or a name, depending on the value of the isNamed parameter.
   private StyleNode _createStyleNode(String key, Style style, boolean isNamed)
   {
     // Covert the properties into PropertyNodes
-    // -= Simon Lessard =- 
-    // TODO: Check if synchronization is truly required
-    Vector<PropertyNode> v = new Vector<PropertyNode>();
+    List<PropertyNode> v = new ArrayList<PropertyNode>();
     Iterator<Object> names = style.getPropertyNames();
 
     while (names.hasNext())
@@ -795,11 +728,10 @@
       String name = (String)names.next();
       String value = style.getProperty(name);
 
-      v.addElement(new PropertyNode(name, value));
+      v.add(new PropertyNode(name, value));
     }
 
-    PropertyNode[] nodes = new PropertyNode[v.size()];
-    v.copyInto(nodes);
+    PropertyNode[] nodes = v.toArray(new PropertyNode[v.size()]);
 
     if (isNamed)
     {
@@ -1064,7 +996,7 @@
     }
 
     // Tests whether a property with the specified name is
-    // contained within the Vector of PropertyNodes
+    // contained within the List of PropertyNodes
     // -= Simon Lessard =-
     // FIXME: Never used locally as of 2006-08-04
     @SuppressWarnings("unused")
@@ -1085,8 +1017,8 @@
     }
 
     // Removes the PropertyNode with the specified name from the
-    // Vector of properties.  Note - we assume that the properties
-    // Vector will contain at most one property with the specified
+    // List of properties.  Note - we assume that the properties
+    // List will contain at most one property with the specified
     // name.  Returns a boolean indicating whether the specified
     // property was found (and thus removed).
     private boolean _removeProperty(

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java?view=diff&rev=529393&r1=529392&r2=529393
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java Mon Apr 16 13:42:25 2007
@@ -249,47 +249,6 @@
   }
 
   /**
-   * Resolves the class name to the appropriate Style object
-   */
-  public static Style getStyleSelector(
-    UIXRenderingContext context,
-    Object           styleSelector
-    )
-  {
-    if (styleSelector != null)
-    {
-      StyleMap map = context.getStyleContext().getStyleMap();
-      if (map != null)
-      {
-        return map.getStyleBySelector(context.getStyleContext(),
-                                      styleSelector.toString());
-      }
-    }
-
-    return null;
-  }
-
-  /**
-   * Resolves the class name to the appropriate Style object,
-   * then get a property from the Style
-   */
-  public static String getStyleSelectorProperty(
-    UIXRenderingContext context,
-    Object           selectorName,
-    String           propertyName
-    )
-  {
-      Style styleSelector = getStyleSelector(context,
-                                             selectorName);
-      if (styleSelector != null)
-      {
-        return styleSelector.getProperty(propertyName);
-      }
-
-      return null;
-  }
-
-  /**
    * Returns the short version of the specified style class.
    */
   public static Object getShortStyleClass(