Revision: 9701
Author: fre...@google.com
Date: Tue Feb 8 16:15:58 2011
Log: Provide mechanism to suppress warning dialog when runtime and compile
time user.agent propert values disagree, i.e. via
<set-property name="user.agent.runtimeWarning" value="false"/>
Fixes issues: 5861
Review at http://gwt-code-reviews.appspot.com/1344802
Review by: j...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=9701
Modified:
/trunk/user/src/com/google/gwt/user/UserAgent.gwt.xml
/trunk/user/src/com/google/gwt/user/client/UserAgentAsserter.java
/trunk/user/src/com/google/gwt/user/rebind/UserAgentGenerator.java
/trunk/user/src/com/google/gwt/user/rebind/UserAgentPropertyGenerator.java
=======================================
--- /trunk/user/src/com/google/gwt/user/UserAgent.gwt.xml Thu Jan 27
13:56:33 2011
+++ /trunk/user/src/com/google/gwt/user/UserAgent.gwt.xml Tue Feb 8
16:15:58 2011
@@ -23,7 +23,14 @@
<property-provider name="user.agent"
generator="com.google.gwt.user.rebind.UserAgentPropertyGenerator"/>
- <!-- Asserts the the compile time value matches the runtime user.agent
value -->
+ <!-- Set to false to avoid runtime warnings for mismatched runtime and
-->
+ <!-- compile time user.agent values -->
+ <define-configuration-property name="user.agent.runtimeWarning"
+ is-multi-valued="false" />
+ <set-configuration-property name="user.agent.runtimeWarning"
value="true"/>
+
+ <!-- Asserts that the compile time user.agent value matches the runtime
-->
+ <!-- user.agent value -->
<entry-point class="com.google.gwt.user.client.UserAgentAsserter" />
<generate-with class="com.google.gwt.user.rebind.UserAgentGenerator">
=======================================
--- /trunk/user/src/com/google/gwt/user/client/UserAgentAsserter.java Thu
Jan 27 16:01:17 2011
+++ /trunk/user/src/com/google/gwt/user/client/UserAgentAsserter.java Tue
Feb 8 16:15:58 2011
@@ -33,6 +33,8 @@
* <code>user.agent</code> selection property value.
*/
interface UserAgentProperty {
+ boolean getUserAgentRuntimeWarning();
+
String getCompileTimeValue();
String getRuntimeValue();
@@ -40,6 +42,10 @@
public void onModuleLoad() {
UserAgentProperty impl = GWT.create(UserAgentProperty.class);
+ if (!impl.getUserAgentRuntimeWarning()) {
+ return;
+ }
+
String compileTimeValue = impl.getCompileTimeValue();
String runtimeValue = impl.getRuntimeValue();
=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/UserAgentGenerator.java Thu
Jan 27 13:56:33 2011
+++ /trunk/user/src/com/google/gwt/user/rebind/UserAgentGenerator.java Tue
Feb 8 16:15:58 2011
@@ -17,6 +17,7 @@
package com.google.gwt.user.rebind;
import com.google.gwt.core.ext.BadPropertyValueException;
+import com.google.gwt.core.ext.ConfigurationProperty;
import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.PropertyOracle;
@@ -33,7 +34,9 @@
* Generator for {@link com.google.gwt.user.client.UserAgentAsserter}.
*/
public class UserAgentGenerator extends Generator {
- private static final String PROPERTY_USER_AGENT = "user.agent";
+ static final String PROPERTY_USER_AGENT = "user.agent";
+
+ static final String PROPERTY_USER_AGENT_RUNTIME_WARNING
= "user.agent.runtimeWarning";
@Override
public String generate(TreeLogger logger, GeneratorContext context,
@@ -65,11 +68,22 @@
}
PropertyOracle propertyOracle = context.getPropertyOracle();
+
+ boolean userAgentRuntimeWarning = true;
+ try {
+ ConfigurationProperty property =
+
propertyOracle.getConfigurationProperty(PROPERTY_USER_AGENT_RUNTIME_WARNING);
+ userAgentRuntimeWarning =
Boolean.valueOf(property.getValues().get(0));
+ } catch (BadPropertyValueException e) {
+ logger.log(TreeLogger.WARN, "Unable to find value for '"
+ + PROPERTY_USER_AGENT_RUNTIME_WARNING + "'", e);
+ }
+
String userAgentValue;
try {
- SelectionProperty userAgentProperty =
propertyOracle.getSelectionProperty(
- logger, PROPERTY_USER_AGENT);
- userAgentValue = userAgentProperty.getCurrentValue();
+ SelectionProperty property =
propertyOracle.getSelectionProperty(logger,
+ PROPERTY_USER_AGENT);
+ userAgentValue = property.getCurrentValue();
} catch (BadPropertyValueException e) {
logger.log(TreeLogger.ERROR, "Unable to find value for '"
+ PROPERTY_USER_AGENT + "'", e);
@@ -88,6 +102,14 @@
if (pw != null) {
SourceWriter sw = composerFactory.createSourceWriter(context, pw);
+ sw.println();
+ sw.println("public boolean getUserAgentRuntimeWarning() {");
+ sw.indent();
+ sw.println("return " + userAgentRuntimeWarning + ";");
+ sw.outdent();
+ sw.println("}");
+ sw.println();
+
sw.println();
sw.println("public native String getRuntimeValue() /*-{");
sw.indent();
=======================================
---
/trunk/user/src/com/google/gwt/user/rebind/UserAgentPropertyGenerator.java
Thu Jan 27 16:01:17 2011
+++
/trunk/user/src/com/google/gwt/user/rebind/UserAgentPropertyGenerator.java
Tue Feb 8 16:15:58 2011
@@ -96,9 +96,13 @@
String fallback, SortedSet<ConfigurationProperty> configProperties) {
for (String value : possibleValues) {
if (!VALID_VALUES.contains(value)) {
- logger.log(TreeLogger.ERROR, "Unrecognized user.agent property
value '"
+ logger.log(TreeLogger.ERROR, "Unrecognized "
+ + UserAgentGenerator.PROPERTY_USER_AGENT + " property value '"
+ value + "', possibly due to UserAgent.gwt.xml and "
- + UserAgentPropertyGenerator.class.getName() + " being out of
sync");
+ + UserAgentPropertyGenerator.class.getName()
+ + " being out of sync." + " Use <set-configuration-property
name=\""
+ + UserAgentGenerator.PROPERTY_USER_AGENT_RUNTIME_WARNING
+ + "\" value=\"false\"/> to suppress this warning message.");
}
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors