Author: awiner
Date: Wed Aug 16 08:55:50 2006
New Revision: 431929
URL: http://svn.apache.org/viewvc?rev=431929&view=rev
Log:
Patch from Simon Lessard for ADFFACES-55: Add support for ora-inhibit to
inhibit inherited properties
Modified:
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/style/xml/parse/StyleNode.java
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNodeParser.java
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java
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?rev=431929&r1=431928&r2=431929&view=diff
==============================================================================
---
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 Aug 16 08:55:50 2006
@@ -25,6 +25,8 @@
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
@@ -260,6 +262,7 @@
_addStyleNode(selectorName,
noOraPropertyList,
resolvedProperties.getOraRuleRefList(),
+ resolvedProperties.getInhibitedProperties(),
resolvedProperties.isOraTextAntialias(),
styleNodeList);
@@ -317,6 +320,7 @@
List<PropertyNode> noOraPropertyList = new ArrayList<PropertyNode>();
List<String> oraRuleRefList = new ArrayList<String>();
+ Set<String> inhibitedPropertySet = new TreeSet<String>();
List<SkinPropertyNode> skinPropertyNodeList =
new ArrayList<SkinPropertyNode>();
@@ -335,7 +339,7 @@
String propertyName = propertyNode.getName();
String propertyValue = propertyNode.getValue();
- if(propertyName != null)
+ if(propertyName != null && propertyValue != null)
{
if(propertyName.startsWith(_ORA_PROPERTY_PREFIX))
{
@@ -350,19 +354,26 @@
oraTextAntialias = true;
}
+ else if (propertyName.equals(_ORA_INHIBIT))
+ {
+ for (String value : propertyValue.split("\\s"))
+ {
+ inhibitedPropertySet.add(value);
+ }
+ }
else
{
SkinPropertyNode node =
new SkinPropertyNode(selectorName,
propertyName,
propertyValue);
-
+
skinPropertyNodeList.add(node);
}
}
- else if(propertyValue != null)
+ else
{
- if(_containsURL(propertyValue))
+ if (_containsURL(propertyValue))
{
String resolvedUrl = _resolveURL(baseURI,
propertyValue,
@@ -393,6 +404,7 @@
return new ResolvedSkinProperties(
noOraPropertyList,
oraRuleRefList,
+ inhibitedPropertySet,
skinPropertyNodeList,
oraTextAntialias);
}
@@ -653,6 +665,7 @@
String selectorName,
List<PropertyNode> propertyNodeList,
List<String> oraRuleRefList,
+ Set<String> inhibitedProperties,
boolean oraTextAntialias,
List<StyleNode> styleNodeList)
{
@@ -710,7 +723,8 @@
propertyArray,
null,
includeStyleNodes.toArray(new IncludeStyleNode[0]),
- null);
+ null,
+ inhibitedProperties);
styleNodeList.add(styleNode);
@@ -1016,11 +1030,13 @@
ResolvedSkinProperties(
List<PropertyNode> noOraPropertyList,
List<String> oraRuleRefList,
+ Set<String> inhibitedPropertySet,
List<SkinPropertyNode> skinPropertyNodeList,
boolean oraTextAntialias)
{
_noOraPropertyList = noOraPropertyList;
_oraRuleRefList = oraRuleRefList;
+ _inhibitedPropertySet = inhibitedPropertySet;
_skinPropertyNodeList = skinPropertyNodeList;
_oraTextAntialias = oraTextAntialias;
}
@@ -1039,12 +1055,18 @@
{
return _skinPropertyNodeList;
}
+
+ public Set<String> getInhibitedProperties()
+ {
+ return _inhibitedPropertySet;
+ }
public boolean isOraTextAntialias()
{
return _oraTextAntialias;
}
-
+
+ private Set<String> _inhibitedPropertySet;
private List<PropertyNode> _noOraPropertyList;
private List<String> _oraRuleRefList;
private List<SkinPropertyNode> _skinPropertyNodeList;
@@ -1054,6 +1076,7 @@
private static final String _ORA_PROPERTY_PREFIX = "-ora-";
private static final String _ORA_RULE_REF = "-ora-rule-ref";
+ private static final String _ORA_INHIBIT = "-ora-inhibit";
private static final String _ORA_TEXT_ANTIALIAS = "-ora-text-antialias";
static private final TrinidadLogger _LOG =
TrinidadLogger.createTrinidadLogger(
Modified:
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNode.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNode.java?rev=431929&r1=431928&r2=431929&view=diff
==============================================================================
---
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNode.java
(original)
+++
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNode.java
Wed Aug 16 08:55:50 2006
@@ -16,12 +16,12 @@
package org.apache.myfaces.trinidadinternal.style.xml.parse;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-
-
+import java.util.Set;
/**
@@ -44,7 +44,8 @@
properties,
style._compoundProperties,
style._includedStyles,
- style._includedProperties);
+ style._includedProperties,
+ null);
}
/**
@@ -56,7 +57,8 @@
PropertyNode[] properties,
CompoundPropertyNode[] compoundProperties,
IncludeStyleNode[] includedStyles,
- IncludePropertyNode[] includedProperties
+ IncludePropertyNode[] includedProperties,
+ Set<String> inhibitedProperties
)
{
this(name,
@@ -65,6 +67,7 @@
compoundProperties,
includedStyles,
includedProperties,
+ inhibitedProperties,
false);
}
@@ -78,6 +81,7 @@
CompoundPropertyNode[] compoundProperties,
IncludeStyleNode[] includedStyles,
IncludePropertyNode[] includedProperties,
+ Set<String> inhibitedProperties,
boolean resetProperties
)
{
@@ -116,6 +120,30 @@
_includedProperties, 0,
_includedProperties.length);
}
+
+ _inhibitAll = false;
+ if(inhibitedProperties != null)
+ {
+ _inhibitedProperties = new ArrayList<String>(inhibitedProperties.size());
+ for(String property : inhibitedProperties)
+ {
+ if(_INHIBIT_ALL_VALUE.equalsIgnoreCase(property))
+ { // Case insensitivity for "all" value
+ _inhibitAll = true;
+ _inhibitedProperties = null;
+ break;
+ }
+ else
+ {
+ _inhibitedProperties.add(property);
+ }
+ }
+
+ if(_inhibitedProperties != null)
+ {
+ _inhibitedProperties =
Collections.unmodifiableList(_inhibitedProperties);
+ }
+ }
}
/**
@@ -191,6 +219,39 @@
else
return (Arrays.asList(_includedProperties)).iterator();
}
+
+ /**
+ * Gets the properties specified by this node's parent that should be
+ * ignored. This method will return an empty iterator if
+ * [EMAIL PROTECTED] #isInhibitingAll()} returns <code>true</code>
+ *
+ * @return an iterator over the properties that should be ignored, an
+ * empty iterator if all properties should be.
+ */
+ public Iterator<String> getInhibitedProperties()
+ {
+ if(_inhibitedProperties == null)
+ {
+ List<String> list = Collections.emptyList();
+ return list.iterator();
+ }
+ else
+ {
+ return _inhibitedProperties.iterator();
+ }
+ }
+
+ /**
+ * Determines if this node inhibits all of its inherited properties.
+ *
+ * @return <code>true</code> if this node ignores all properties defined
+ * by its parent, <code>false</code> otherwise.
+ */
+ public boolean isInhibitingAll()
+ {
+ return _inhibitAll;
+ }
+
// Just leaving this package-private, since only
// StyleSheetDocument really needs to know about this.
@@ -201,15 +262,18 @@
return _resetProperties;
}
+ private boolean _inhibitAll;
private String _name;
private String _selector;
private PropertyNode[] _properties; // The property nodes
private CompoundPropertyNode[] _compoundProperties; // Compound properties
private IncludeStyleNode[] _includedStyles; // Included styles
private IncludePropertyNode[] _includedProperties; // Included properties
-
+ private List<String> _inhibitedProperties; // Inhibited properties
+
// This flag checks whether the style should inherit properties
// from equivalent styles defined in earlier style sheets.
private boolean _resetProperties;
+ private static final String _INHIBIT_ALL_VALUE = "all";
}
Modified:
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNodeParser.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNodeParser.java?rev=431929&r1=431928&r2=431929&view=diff
==============================================================================
---
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNodeParser.java
(original)
+++
incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleNodeParser.java
Wed Aug 16 08:55:50 2006
@@ -109,6 +109,7 @@
compoundProperties,
includedStyles,
includedProperties,
+ null,
_resetProperties);
}
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?rev=431929&r1=431928&r2=431929&view=diff
==============================================================================
---
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
Wed Aug 16 08:55:50 2006
@@ -507,9 +507,19 @@
// into our StyleEntry.
// 3. Resolve all compound properites, and shove those properties
// into the StyleEntry
- // 4. Shove all properties from the matching StyleNode into our
+ // 4. Remove all properties that were inhibited.
+ // 5. Shove all properties from the matching StyleNode into our
// StyleEntry, overwriting included values
-
+ // -= Simon Lessard =-
+ // FIXME: That sequence looks buggy. If more than 1 matching node
+ // is found, then the included properties of the second will
+ // have priority over the properties found at step 5 on the
+ // first node, which is most likely incorrect.
+ //
+ // A possible fix would be to put entries from the 5 steps
+ // into 5 different lists then resolve all priorities at
the
+ // end.
+
// 0. Reset properties?
if (node.__getResetProperties())
entry.resetProperties();
@@ -661,7 +671,21 @@
}
}
- // 4. Add non-included properties
+ // 4. Check inhibited properties
+ if(node.isInhibitingAll())
+ {
+ entry.resetProperties();
+ }
+ else
+ {
+ Iterator<String> properties = node.getInhibitedProperties();
+ while (properties.hasNext())
+ {
+ entry.removeProperty(properties.next());
+ }
+ }
+
+ // 5. Add non-included properties
Iterator<PropertyNode> properties = node.getProperties();
if (properties != null)
{
@@ -876,9 +900,11 @@
v.copyInto(nodes);
if (isNamed)
- return new StyleNode(key, null, nodes, null, null, null);
-
- return new StyleNode(null, key, nodes, null, null, null);
+ {
+ return new StyleNode(key, null, nodes, null, null, null, null);
+ }
+
+ return new StyleNode(null, key, nodes, null, null, null, null);
}
// Tests whether the value is present in the (possibly null) stack.
@@ -1132,7 +1158,7 @@
// Create and return our StyleNode. We don't need to specify
// a name or included styles, as they have already been resolved.
- return new StyleNode(name, selector, properties, null, null, null);
+ return new StyleNode(name, selector, properties, null, null, null, null);
}
// Tests whether a property with the specified name is
@@ -1517,6 +1543,7 @@
// A StyleNode used as a placeholder for a style which couldn't be resolved
private static final StyleNode _ERROR_STYLE_NODE = new StyleNode("error",
"error",
+ null,
null,
null,
null,