You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2009/12/31 18:39:17 UTC
svn commit: r894905 [2/2] - in /myfaces/trinidad/branches/1.2.12.2-branch:
src/site/xdoc/devguide/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/
trinidad-examples/trinidad-d...
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java Thu Dec 31 17:39:14 2009
@@ -23,8 +23,8 @@
import java.util.Set;
import java.util.Vector;
-import org.apache.myfaces.trinidad.context.Version;
import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
+import org.apache.myfaces.trinidadinternal.skin.AgentAtRuleMatcher;
import org.apache.myfaces.trinidadinternal.style.StyleContext;
import org.apache.myfaces.trinidadinternal.style.xml.XMLConstants;
import org.apache.myfaces.trinidadinternal.style.xml.parse.StyleSheetDocument;
@@ -43,91 +43,22 @@
/**
* Returns the id of the browser with the specified name
*/
- public static int getBrowser(String browserName)
+ public static TrinidadAgent.Application getAgentApplication(String agentName)
{
- if (browserName == null)
- return TrinidadAgent.APPLICATION_UNKNOWN;
-
- int browser = TrinidadAgent.APPLICATION_UNKNOWN;
-
- if (_BROWSER_NETSCAPE.equals(browserName))
- browser = TrinidadAgent.APPLICATION_NETSCAPE;
- else if (_BROWSER_IE.equals(browserName))
- browser = TrinidadAgent.APPLICATION_IEXPLORER;
- else if (_BROWSER_GECKO.equals(browserName) ||
- _BROWSER_MOZILLA.equals(browserName))
- browser = TrinidadAgent.APPLICATION_GECKO;
- else if (_BROWSER_ICE.equals(browserName))
- browser = TrinidadAgent.APPLICATION_ICE;
- else if (_BROWSER_WEBKIT.equals(browserName))
- browser = TrinidadAgent.APPLICATION_SAFARI;
- else if (_BROWSER_OPERA.equals(browserName))
- browser = TrinidadAgent.APPLICATION_OPERA;
- else if (_BROWSER_BLACKBERRY.equals(browserName))
- browser = TrinidadAgent.APPLICATION_BLACKBERRY;
- else if (_BROWSER_NOKIA_S60.equals(browserName))
- browser = TrinidadAgent.APPLICATION_NOKIA_S60;
- else if (_BROWSER_GENERICPDA.equals(browserName))
- browser = TrinidadAgent.APPLICATION_GENERICPDA;
- else if (_BROWSER_EMAIL.equals(browserName))
- browser = TrinidadAgent.APPLICATION_EMAIL;
- else
+ if (agentName == null)
+ return TrinidadAgent.Application.UNKNOWN;
+
+ TrinidadAgent.Application application = TrinidadAgent.Application.fromAgentName(agentName);
+
+ if (application == null)
{
// Either a new or an invalid browser
- assert false:"Invalid browser name: " + browserName;
- }
-
- return browser;
- }
-
- /**
- * Returns the name of the specified browser id
- */
- public static String getBrowserName(int browser)
- {
- String name = null;
-
- switch (browser)
- {
- case TrinidadAgent.APPLICATION_NETSCAPE:
- name = _BROWSER_NETSCAPE;
- break;
- case TrinidadAgent.APPLICATION_IEXPLORER:
- name = _BROWSER_IE;
- break;
- case TrinidadAgent.APPLICATION_GECKO:
- name = _BROWSER_GECKO;
- break;
- case TrinidadAgent.APPLICATION_ICE:
- name = _BROWSER_ICE;
- break;
- case TrinidadAgent.APPLICATION_SAFARI:
- name = _BROWSER_WEBKIT;
- break;
- case TrinidadAgent.APPLICATION_OPERA:
- name = _BROWSER_OPERA;
- break;
- case TrinidadAgent.APPLICATION_BLACKBERRY:
- name = _BROWSER_BLACKBERRY;
- break;
- case TrinidadAgent.APPLICATION_NOKIA_S60:
- name = _BROWSER_NOKIA_S60;
- break;
- case TrinidadAgent.APPLICATION_GENERICPDA:
- name = _BROWSER_GENERICPDA;
- break;
- case TrinidadAgent.APPLICATION_EMAIL:
- name = _BROWSER_EMAIL;
- break;
- case TrinidadAgent.APPLICATION_UNKNOWN:
- // This case is only here to avoid the default assertion
- break;
- default:
- // New or invalid browser id
- assert false:"Invalid browser id: " +browser;
+ assert false:"Invalid browser name: " + agentName;
+
+ application = TrinidadAgent.Application.UNKNOWN;
}
-
- return name;
+
+ return application;
}
/**
@@ -500,13 +431,9 @@
// Get the browser as a String
private static String _getBrowserString(StyleContext context)
{
- int browser = context.getAgent().getAgentApplication();
- String name = getBrowserName(browser);
-
- if (name == null)
- return _UNKNOWN_NAME;
-
- return name;
+ TrinidadAgent.Application application = context.getAgent().getAgentApplication();
+
+ return application.getApplicationName();
}
// get the StyleSheetDocument's id.
@@ -644,34 +571,33 @@
private static boolean[] _isBrowserAndVersionMatch(StyleContext context,
StyleSheetNode[] styleSheets)
{
- int browser = context.getAgent().getAgentApplication();
- Version version = new Version(context.getAgent().getAgentVersion());
- if (browser == TrinidadAgent.APPLICATION_UNKNOWN)
+ TrinidadAgent agent = context.getAgent();
+ TrinidadAgent.Application browser = agent.getAgentApplication();
+ if (browser == TrinidadAgent.Application.UNKNOWN)
{
return new boolean[] { false, false };
}
boolean browserMatched = false;
- Integer browserNum = Integer.valueOf(browser);
// If any style sheet has a non-null browser variant, we must
// have a browser match.
for (int i = 0; i < styleSheets.length; i++)
{
- if (!styleSheets[i].getAgentVersions().isEmpty())
+ AgentAtRuleMatcher agentMatcher = styleSheets[i].getAgentMatcher();
+
+ if (agentMatcher != null)
{
- Set<Version> versions = styleSheets[i].getAgentVersions().get(browserNum);
+ Set<AgentAtRuleMatcher.Match> matches = agentMatcher.match(agent);
- if (versions != null)
+ if (matches.contains(AgentAtRuleMatcher.Match.APPLICATION))
{
+ // latch the browser matched
browserMatched = true;
- for (Version av : versions)
- {
- if (av.compareTo(version) == 0)
- {
- return new boolean[] { true, true };
- }
- }
+
+ // we can't match better than application and version, so return immediately
+ if (matches.contains(AgentAtRuleMatcher.Match.VERSION))
+ return new boolean[] { true, true };
}
}
}
@@ -745,29 +671,6 @@
private static final String _DIRECTION_RTL = "rtl";
private static final String _DIRECTION_LTR = "ltr";
-
- // Browser constants
- private static final String _BROWSER_NETSCAPE = "netscape";
-
- private static final String _BROWSER_IE = "ie";
-
- private static final String _BROWSER_MOZILLA = "mozilla";
-
- private static final String _BROWSER_GECKO = "gecko";
-
- private static final String _BROWSER_WEBKIT = "webkit";
-
- private static final String _BROWSER_ICE = "ice";
-
- private static final String _BROWSER_BLACKBERRY = "blackberry";
-
- private static final String _BROWSER_NOKIA_S60 = "nokia_s60";
-
- private static final String _BROWSER_GENERICPDA = "genericpda";
-
- private static final String _BROWSER_EMAIL = "email";
-
- private static final String _BROWSER_OPERA = "opera";
// Platform constants
private static final String _PLATFORM_WINDOWS = "windows";
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java Thu Dec 31 17:39:14 2009
@@ -32,6 +32,7 @@
import org.apache.myfaces.trinidad.context.AccessibilityProfile;
import org.apache.myfaces.trinidad.context.Version;
import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
+import org.apache.myfaces.trinidadinternal.skin.AgentAtRuleMatcher;
import org.apache.myfaces.trinidadinternal.style.util.ModeUtils;
import org.apache.myfaces.trinidadinternal.style.util.NameUtils;
import org.apache.myfaces.trinidadinternal.style.xml.XMLConstants;
@@ -58,7 +59,7 @@
Collection<SkinPropertyNode> skinProperties,
Locale[] locales,
int direction,
- Map<Integer, Set<Version>> agentVersions,
+ AgentAtRuleMatcher agentMatcher,
int[] platforms,
int mode,
Set<String> accessibilityProperties
@@ -91,12 +92,7 @@
else
_locales = Collections.emptySet();
- if (agentVersions != null)
- {
- _agentVersions = Collections.unmodifiableMap(agentVersions);
- }
- else
- _agentVersions = Collections.emptyMap();
+ _agentMatcher = agentMatcher;
if (platforms != null)
{
@@ -169,12 +165,11 @@
}
/**
- * Implementation of StyleSheetNode.getAgentVersions().
- * @return a map containing each browser type mapped to its versions set
+ * @return AgentAtRuleMatcher for matching @agent selectors
*/
- public Map<Integer, Set<Version>> getAgentVersions()
+ public AgentAtRuleMatcher getAgentMatcher()
{
- return _agentVersions;
+ return _agentMatcher;
}
/**
@@ -216,10 +211,8 @@
int directionMatch = _compareDirection(direction);
if (directionMatch == 0)
return 0;
-
- int browser = agent.getAgentApplication();
- int browserAndVersionMatch = _compareBrowserAndVersion(browser, agent);
+ int browserAndVersionMatch = _compareBrowserAndVersion(agent);
if (browserAndVersionMatch == 0)
return 0;
int modeMatch = _compareMode(mode);
@@ -278,8 +271,7 @@
return getClass().getName() + "[" +
"locales=" + (_locales != null ? _locales.toString() : "") + ", " +
"direction=" + _getDirectionString() + ", " +
- "agentVersions=" + (_agentVersions != null ? _agentVersions.toString() : "") + ", " +
-// "versions=" + _versions.toString() + ", " +
+ "agentVersions=" + (_agentMatcher != null ? _agentMatcher.toString() : "") + ", " +
"platforms=" + (_platforms != null ? _platforms.toString() : "") + ", " +
"styles=" + (_styles != null ? _styles.toString() : "") + ", " +
"icons=" + (_icons != null ? _icons.toString() :"") + ", " +
@@ -317,7 +309,7 @@
hash = 37*hash + _mode;
hash = 37*hash + _direction;
hash = 37*hash + _locales.hashCode();
- hash = 37*hash + _agentVersions.hashCode();
+ hash = 37*hash + ((_agentMatcher != null) ? _agentMatcher.hashCode() : 0);
hash = 37*hash + _platforms.hashCode();
hash = 37*hash + _styles.hashCode();
hash = 37*hash + _accProps.hashCode();
@@ -384,40 +376,39 @@
return 0;
}
- //Compares the browser and its version against the supported variants
- private int _compareBrowserAndVersion(int browser, TrinidadAgent agent)
+ // Compares the browser and its version against the supported variants
+ // This uses the AgentAtRuleMatcher object _agentMatcher, which stores the agent
+ // information for the StyleSheetNode and has a built-in matcher.
+ private int _compareBrowserAndVersion(TrinidadAgent agent)
{
// If we don't have a browser specified, we match anything
- if (_agentVersions.isEmpty())
+ if (_agentMatcher == null)
return _BROWSER_UNKNOWN_MATCH;
+ TrinidadAgent.Application application = agent.getAgentApplication();
+
// On the other hand, if we do have a browser specified, but
// the client browser is not known, we don't have a match
- if (browser == TrinidadAgent.APPLICATION_UNKNOWN)
+ if (application == TrinidadAgent.Application.UNKNOWN)
return 0;
- //If we have browser exact match, compare versions
- Integer browserNum = Integer.valueOf(browser);
- if (_agentVersions.containsKey(browserNum))
+ Set<AgentAtRuleMatcher.Match> matches = _agentMatcher.match(agent);
+
+ int matchResult = _NO_MATCH;
+
+ // first check that we have a match against the browser
+ if (matches.contains(AgentAtRuleMatcher.Match.APPLICATION))
{
- Set<Version> versions = _agentVersions.get(browserNum);
- if (versions.isEmpty())
- return _BROWSER_EXACT_MATCH | _VERSION_UNKNOWN_MATCH;
-
- Version version = new Version(agent.getAgentVersion());
-
- for (Version av : versions)
- {
- if (av.compareTo(version) == 0)
- {
- return _BROWSER_EXACT_MATCH | _VERSION_EXACT_MATCH;
- }
- }
+ matchResult |= _BROWSER_EXACT_MATCH;
- return 0;
+ // check if the browser also specified a version match that we matched
+ int versionMatch = (matches.contains(AgentAtRuleMatcher.Match.VERSION))
+ ? _VERSION_EXACT_MATCH
+ : _VERSION_UNKNOWN_MATCH;
+ matchResult |= versionMatch;
}
- return 0;
+ return matchResult;
}
@@ -582,18 +573,17 @@
// Order does not matter for locales, browsers, versions, platforms
private final Set<Locale> _locales; // The locale variants
private final int _direction; // The reading direction
- // The browsers mapped to their versions (multiple versions for browser supported)
- // The Integer value is the APPLICATION value in TrinidadAgent, like if
- // Integer is 3, it is APPLICATION_GECKO.
- // TODO It would be clearer to make the Integer an Enum, and to make the
- // Application constants an enum.
- private final Map<Integer, Set<Version>> _agentVersions;
+
+ // matches Agent at-rules
+ private final AgentAtRuleMatcher _agentMatcher;
private final Set<Integer> _platforms; // The platform variants
private final int _mode; // The mode
private final Set<String> _accProps; // Accessibility profile properties
private final int _id; // The cached style sheet id
// Constants for accessibility matches - 0x0f000000 bits
+ private static final int _NO_MATCH = 0;
+
private static final int _ACC_EXACT_MATCH = 0x02000000;
private static final int _ACC_UNKNOWN_MATCH = 0x01000000;
@@ -616,7 +606,7 @@
// Constants for version matches - 0x000000f0 bits
private static final int _VERSION_EXACT_MATCH = 0x00000020;
- private static final int _VERSION_UNKNOWN_MATCH = 0x00000020;
+ private static final int _VERSION_UNKNOWN_MATCH = 0x00000010;
// Constants for os matches - 0x0000000f bits
private static final int _OS_EXACT_MATCH = 0x00000004;
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java Thu Dec 31 17:39:14 2009
@@ -18,10 +18,13 @@
*/
package org.apache.myfaces.trinidadinternal.style.xml.parse;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -34,6 +37,7 @@
import org.apache.myfaces.trinidadinternal.share.xml.NodeParser;
import org.apache.myfaces.trinidadinternal.share.xml.ParseContext;
import org.apache.myfaces.trinidadinternal.share.xml.XMLUtils;
+import org.apache.myfaces.trinidadinternal.skin.AgentAtRuleMatcher;
import org.apache.myfaces.trinidadinternal.style.StyleConstants;
import org.apache.myfaces.trinidadinternal.style.util.NameUtils;
import org.apache.myfaces.trinidadinternal.style.xml.XMLConstants;
@@ -61,7 +65,7 @@
_initLocales(attrs.getValue(LOCALES_ATTR));
_direction = NameUtils.getDirection(attrs.getValue(DIRECTION_ATTR));
_mode = NameUtils.getMode(attrs.getValue(MODE_ATTR));
- _initBrowsers(attrs.getValue(BROWSERS_ATTR));
+ _browsers = _initBrowsers(attrs.getValue(BROWSERS_ATTR));
_initVersions(attrs.getValue(VERSIONS_ATTR));
_initPlatforms(attrs.getValue(PLATFORMS_ATTR));
_initAccessibilityProperties(attrs.getValue(ACC_PROFILE_ATTR));
@@ -83,33 +87,16 @@
styles = new StyleNode[_styles.size()];
_styles.copyInto(styles);
}
-
- int versionCount = (_versions != null) ? _versions.length : 0;
-
- Set<Version> versions = new HashSet<Version>(versionCount);
- for (int i = 0; i < versionCount ; i++)
- {
- versions.add(_versions[i]);
- }
- int browserCount = (_browsers != null) ? _browsers.length : 0;
- Map<Integer, Set<Version>> browsers
- = new HashMap<Integer, Set<Version>>(browserCount);
-
- //in XSS there's now way of having multiple browsers and multiple versions
- //if encountered, we map all versions to each browser (it works for 1 browser)
- for (int i=0; i < browserCount ; i++)
- {
- browsers.put(_browsers[i], new HashSet<Version>(versions));
- }
-
+ AgentAtRuleMatcher agentMatcher = new AgentAtRuleMatcher(_browsers, _versions);
+
return new StyleSheetNode(
styles,
null, // icons only supported in skin CSS - not XSS
null, // properties only supported in skin CSS - not XSS
_locales,
_direction,
- browsers,
+ agentMatcher,
_platforms,
_mode,
_accProperties
@@ -196,24 +183,23 @@
}
// Initialize browsers
- private void _initBrowsers(String browserAttr)
+ private List<TrinidadAgent.Application> _initBrowsers(String browserAttr)
{
Iterator<String> browsers = _getTokens(browserAttr);
if (browsers == null)
- return;
+ return Collections.emptyList();
- // -= Simon Lessard =-
- // TODO: Check if synchronization is really needed.
- Vector<Integer> v = new Vector<Integer>();
+ List<TrinidadAgent.Application> applications = new ArrayList<TrinidadAgent.Application>();
+
while (browsers.hasNext())
{
- int browser = NameUtils.getBrowser(browsers.next());
+ TrinidadAgent.Application browser = NameUtils.getAgentApplication(browsers.next());
- if (browser != TrinidadAgent.APPLICATION_UNKNOWN)
- v.addElement(browser);
+ if (browser != TrinidadAgent.Application.UNKNOWN)
+ applications.add(browser);
}
-
- _browsers = _getIntegers(v);
+
+ return applications;
}
// Initialize version
@@ -324,7 +310,7 @@
private Locale[] _locales;
private int _direction;
private int _mode;
- private int[] _browsers;
+ private List<TrinidadAgent.Application> _browsers;
private Version[] _versions;
private int[] _platforms;
private Set<String> _accProperties;
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/data/bind/IsAgentApplicationBoundValue.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/data/bind/IsAgentApplicationBoundValue.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/data/bind/IsAgentApplicationBoundValue.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/data/bind/IsAgentApplicationBoundValue.java Thu Dec 31 17:39:14 2009
@@ -50,7 +50,7 @@
UIXRenderingContext context
)
{
- return Boolean.valueOf(_app == context.getAgent().getAgentApplication());
+ return Boolean.valueOf(_app == context.getAgent().getAgentApplication().ordinal());
}
private int _app;
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/expl/UIFunctions.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/expl/UIFunctions.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/expl/UIFunctions.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/expl/UIFunctions.java Thu Dec 31 17:39:14 2009
@@ -96,7 +96,7 @@
String text, String breakChars)
{
UIXRenderingContext rc = uix.getRenderingContext();
- int agentApp = rc.getAgent().getAgentApplication();
+ TrinidadAgent.Application agentApp = rc.getAgent().getAgentApplication();
// bug 3364275
@@ -114,9 +114,9 @@
final char breakHint;
- if ((agentApp == TrinidadAgent.APPLICATION_IEXPLORER) ||
- (agentApp == TrinidadAgent.APPLICATION_GECKO) ||
- (agentApp == TrinidadAgent.APPLICATION_NETSCAPE))
+ if ((agentApp == TrinidadAgent.Application.IEXPLORER) ||
+ (agentApp == TrinidadAgent.Application.GECKO) ||
+ (agentApp == TrinidadAgent.Application.NETSCAPE))
{
// insert the special unicode character that tells the output method to
// use the <wbr> tag. This character is recognized by HTMLEscapes:
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/NameAndAgentScorer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/NameAndAgentScorer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/NameAndAgentScorer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/NameAndAgentScorer.java Thu Dec 31 17:39:14 2009
@@ -77,7 +77,7 @@
TrinidadAgent agent = context. getAgent();
int typeScore = _score(_agentType, agent.getAgentType());
- int appScore = _score(_agentApplication, agent.getAgentApplication());
+ int appScore = _score(_agentApplication, agent.getAgentApplication().ordinal());
int versScore = _score(_agentMajorVersion, agent.getAgentMajorVersion());
int osScore = _score(_agentOS, agent.getAgentOS());
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ApplicationSwitcherRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ApplicationSwitcherRenderer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ApplicationSwitcherRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ApplicationSwitcherRenderer.java Thu Dec 31 17:39:14 2009
@@ -226,7 +226,7 @@
writer.startElement(TABLE_DATA_ELEMENT, null);
if ( context.getAgent().getAgentApplication()
- != TrinidadAgent.APPLICATION_NETSCAPE)
+ != TrinidadAgent.Application.NETSCAPE)
writer.writeAttribute("valign", "bottom", null);
}
@@ -284,7 +284,7 @@
writer.startElement(TABLE_DATA_ELEMENT, null);
if ( context.getAgent().getAgentApplication()
- != TrinidadAgent.APPLICATION_NETSCAPE)
+ != TrinidadAgent.Application.NETSCAPE)
writer.writeAttribute("valign", "bottom", null);
// render goto button
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/BaseDesktopUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/BaseDesktopUtils.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/BaseDesktopUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/BaseDesktopUtils.java Thu Dec 31 17:39:14 2009
@@ -96,7 +96,7 @@
Score score = super.scoreLookAndFeel(context, lafName);
// We don't support Netscape 4.x
- if (TrinidadAgent.APPLICATION_NETSCAPE ==
+ if (TrinidadAgent.Application.NETSCAPE ==
context.getAgent().getAgentApplication())
{
score = new ScoreProxy(score)
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ButtonRenderer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ButtonRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ButtonRenderer.java Thu Dec 31 17:39:14 2009
@@ -334,11 +334,11 @@
// In screen reader mode, "middle" instead of "absmiddle" for vAlign to
// comply with 4.01 HTML Spec.
- int application = context.getAgent().getAgentApplication();
+ TrinidadAgent.Application application = context.getAgent().getAgentApplication();
Object align;
- if ((application == TrinidadAgent.APPLICATION_NETSCAPE)
- || (application == TrinidadAgent.APPLICATION_GECKO)
+ if ((application == TrinidadAgent.Application.NETSCAPE)
+ || (application == TrinidadAgent.Application.GECKO)
|| (isScreenReaderMode(context)))
{
align = UIConstants.V_ALIGN_MIDDLE;
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/HeaderRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/HeaderRenderer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/HeaderRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/HeaderRenderer.java Thu Dec 31 17:39:14 2009
@@ -154,7 +154,7 @@
// of the changes, I'll only tweak it here.
if ((context.getAgent().getAgentOS() == TrinidadAgent.OS_MACOS) &&
(context.getAgent().getAgentApplication() ==
- TrinidadAgent.APPLICATION_IEXPLORER))
+ TrinidadAgent.Application.IEXPLORER))
renderAttribute(context, NAME_ATTRIBUTE, label);
else
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/HtmlLafRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/HtmlLafRenderer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/HtmlLafRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/HtmlLafRenderer.java Thu Dec 31 17:39:14 2009
@@ -53,7 +53,7 @@
)
{
return (context.getAgent().getAgentApplication() ==
- TrinidadAgent.APPLICATION_NETSCAPE);
+ TrinidadAgent.Application.NETSCAPE);
}
/**
@@ -64,7 +64,7 @@
)
{
return (context.getAgent().getAgentApplication() ==
- TrinidadAgent.APPLICATION_SAFARI);
+ TrinidadAgent.Application.SAFARI);
}
@@ -76,7 +76,7 @@
)
{
return (context.getAgent().getAgentApplication() ==
- TrinidadAgent.APPLICATION_GECKO);
+ TrinidadAgent.Application.GECKO);
}
/**
@@ -87,7 +87,7 @@
)
{
return (context.getAgent().getAgentApplication() ==
- TrinidadAgent.APPLICATION_IEXPLORER);
+ TrinidadAgent.Application.IEXPLORER);
}
/**
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/PageLayoutRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/PageLayoutRenderer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/PageLayoutRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/PageLayoutRenderer.java Thu Dec 31 17:39:14 2009
@@ -615,7 +615,7 @@
public Object getValue(UIXRenderingContext context)
{
if (context.getAgent().getAgentApplication() ==
- TrinidadAgent.APPLICATION_NETSCAPE)
+ TrinidadAgent.Application.NETSCAPE)
return _netscapeObj;
else return _elseObj;
}
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/FormElementRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/FormElementRenderer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/FormElementRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/FormElementRenderer.java Thu Dec 31 17:39:14 2009
@@ -53,7 +53,7 @@
// hopefully we can remove it eventually
if ( context.getAgent().getAgentType() == TrinidadAgent.TYPE_PDA &&
context.getAgent().getAgentApplication() ==
- TrinidadAgent.APPLICATION_IEXPLORER )
+ TrinidadAgent.Application.IEXPLORER )
setRenderingProperty(context,
VISIBLE_FORM_ELEMENT_RENDERED,
Boolean.TRUE);
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/GlobalButtonBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/GlobalButtonBarRenderer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/GlobalButtonBarRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/GlobalButtonBarRenderer.java Thu Dec 31 17:39:14 2009
@@ -199,7 +199,7 @@
// See bug 2866954
if ( context.getAgent().getAgentOS() == TrinidadAgent.OS_MACOS &&
context.getAgent().getAgentApplication() ==
- TrinidadAgent.APPLICATION_IEXPLORER)
+ TrinidadAgent.Application.IEXPLORER)
valign = "top";
else
valign = "bottom";
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/HiddenLabelUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/HiddenLabelUtils.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/HiddenLabelUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/HiddenLabelUtils.java Thu Dec 31 17:39:14 2009
@@ -52,7 +52,7 @@
TrinidadAgent agent = context.getAgent();
switch (agent.getAgentApplication())
{
- case TrinidadAgent.APPLICATION_IEXPLORER:
+ case IEXPLORER:
if (agent.getAgentOS() == TrinidadAgent.OS_WINDOWS)
{
// IE 4 doesn't support the label hack.
@@ -71,13 +71,13 @@
return false;
// Mozilla does support the label hack
- case TrinidadAgent.APPLICATION_GECKO:
+ case GECKO:
// Make sure we don't change the VE to Gecko
assert(agent.getCapability(TrinidadAgent.CAP_IS_JDEV_VE) == null);
return true;
// Assume everyone else doesn't.
- case TrinidadAgent.APPLICATION_NETSCAPE:
+ case NETSCAPE:
default:
return false;
}
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/NavigationBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/NavigationBarRenderer.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/NavigationBarRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/NavigationBarRenderer.java Thu Dec 31 17:39:14 2009
@@ -1042,7 +1042,7 @@
if ((id != null) &&
(partialTargets != null) &&
- (agent.getAgentApplication() == TrinidadAgent.APPLICATION_IEXPLORER))
+ (agent.getAgentApplication() == TrinidadAgent.Application.IEXPLORER))
{
iconID = id.toString() + "-i";
}
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java Thu Dec 31 17:39:14 2009
@@ -880,7 +880,7 @@
// on ICE due to problems with tiling transparent images that
// are affecting UIXVE. This code should be removed once the
// underlying ICE bug is fixed (supposedly ICE 5.4.1)
- if (TrinidadAgent.APPLICATION_ICE == agent.getAgentApplication())
+ if (TrinidadAgent.Application.ICE == agent.getAgentApplication())
return false;
//int encodings = ((Integer)agent.getCapability(
@@ -946,9 +946,9 @@
// For now, "top" in Netscape, "absmiddle" everywhere else
String align = null;
- int agentApplication = context.getAgent().getAgentApplication();
+ TrinidadAgent.Application agentApplication = context.getAgent().getAgentApplication();
- if (agentApplication == TrinidadAgent.APPLICATION_NETSCAPE)
+ if (agentApplication == TrinidadAgent.Application.NETSCAPE)
{
align = UIConstants.V_ALIGN_TOP;
}
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/partial/PartialPageRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/partial/PartialPageRendererUtils.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/partial/PartialPageRendererUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/partial/PartialPageRendererUtils.java Thu Dec 31 17:39:14 2009
@@ -118,10 +118,10 @@
// At the moment we have blocking solved on IE and Mozilla
if (supportsPartialRendering(context))
{
- int application = context.getAgent().getAgentApplication();
+ TrinidadAgent.Application application = context.getAgent().getAgentApplication();
- return ((application == TrinidadAgent.APPLICATION_IEXPLORER)
- || (application == TrinidadAgent.APPLICATION_GECKO));
+ return ((application == TrinidadAgent.Application.IEXPLORER)
+ || (application == TrinidadAgent.Application.GECKO));
}
return false;
}
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java?rev=894905&r1=894904&r2=894905&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java Thu Dec 31 17:39:14 2009
@@ -33,6 +33,7 @@
import org.apache.myfaces.trinidad.skin.Icon;
import org.apache.myfaces.trinidadinternal.skin.icon.ContextImageIcon;
import org.apache.myfaces.trinidadinternal.skin.icon.TextIcon;
+import org.apache.myfaces.trinidadinternal.skin.AgentAtRuleMatcher;
/**
* Test the getStyleSheetId() method on the StyleSheetNode object.
@@ -133,17 +134,9 @@
Locale[] diffOrderLocalesArray = getDiffOrderLocalesArray();
// create a browsers map
- Map<Integer, Set<Version>> browsers = new HashMap<Integer, Set<Version>>();
- browsers.put(1, new HashSet<Version>(Arrays.asList(new Version("5"), new Version("6"))));
- browsers.put(2, new HashSet<Version>(Arrays.asList(new Version("7"), new Version("8"))));
- Map<Integer, Set<Version>> anotherBrowsers = new HashMap<Integer, Set<Version>>();
- anotherBrowsers.put(1, new HashSet<Version>(Arrays.asList(new Version("5"), new Version("6"))));
- anotherBrowsers.put(2, new HashSet<Version>(Arrays.asList(new Version("7"), new Version("8"))));
- Map<Integer, Set<Version>> anotherBrowsersDiffOrder
- = new HashMap<Integer, Set<Version>>();
- anotherBrowsersDiffOrder.put(2, new HashSet<Version>(Arrays.asList(new Version("8"), new Version("7"))));
- anotherBrowsersDiffOrder.put(1, new HashSet<Version>(Arrays.asList(new Version("6"), new Version("5"))));
-
+ String browserSelector = "netscape and (version:5), netscape and (version:6), ie and (version:7), ie and (version:8)";
+ String anotherBrowserSelector = browserSelector;
+ String anotherBrowserDiffOrder = "ie and (version:8), ie and (version:7), netscape and (version:6), netscape and (version:5)";
int[] platforms = {2, 3, 4};
int[] anotherPlatforms = {2, 3, 4};
@@ -168,7 +161,7 @@
null,
localesArray,
0,
- browsers,
+ new AgentAtRuleMatcher(browserSelector),
platforms,
0,
accProps);
@@ -178,7 +171,7 @@
null,
anotherLocalesArray,
0,
- anotherBrowsersDiffOrder,
+ new AgentAtRuleMatcher(anotherBrowserSelector),
anotherPlatforms,
0,
anotherAccProps);
@@ -188,7 +181,7 @@
null,
diffOrderLocalesArray,
0,
- anotherBrowsersDiffOrder,
+ new AgentAtRuleMatcher(anotherBrowserDiffOrder),
differentOrderPlatforms,
0,
differentOrderAccProps);