Revision: 7007 Author: [email protected] Date: Wed Nov 18 14:56:30 2009 Log: Adding Window.Navigator api.
Patch by: kjin Review by: jlabanca http://code.google.com/p/google-web-toolkit/source/detail?r=7007 Modified: /trunk/eclipse/samples/Hello/.classpath /trunk/eclipse/samples/Hello/.project /trunk/eclipse/user/.project /trunk/samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml /trunk/user/src/com/google/gwt/user/client/Window.java /trunk/user/test/com/google/gwt/user/client/WindowTest.java ======================================= --- /trunk/eclipse/samples/Hello/.classpath Fri Jan 16 11:50:20 2009 +++ /trunk/eclipse/samples/Hello/.classpath Wed Nov 18 14:56:30 2009 @@ -3,6 +3,6 @@ <classpathentry kind="src" path="core/src"/> <classpathentry kind="src" output="war" path="core/war"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry combineaccessrules="false" kind="src" path="/gwt-user"/> + <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/> <classpathentry kind="output" path="war/WEB-INF/classes"/> </classpath> ======================================= --- /trunk/eclipse/samples/Hello/.project Fri Jan 16 11:50:20 2009 +++ /trunk/eclipse/samples/Hello/.project Wed Nov 18 14:56:30 2009 @@ -13,12 +13,24 @@ <buildCommand> <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.google.gdt.eclipse.core.webAppProjectValidator</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.google.gwt.eclipse.core.gwtProjectValidator</name> + <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> + <nature>com.google.gdt.eclipse.core.webAppNature</nature> + <nature>com.google.gwt.eclipse.core.gwtNature</nature> </natures> <linkedResources> <link> ======================================= --- /trunk/eclipse/user/.project Tue Oct 13 16:57:19 2009 +++ /trunk/eclipse/user/.project Wed Nov 18 14:56:30 2009 @@ -13,12 +13,18 @@ <buildCommand> <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.google.gwt.eclipse.core.gwtProjectValidator</name> + <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> + <nature>com.google.gwt.eclipse.core.gwtNature</nature> </natures> <linkedResources> <link> ======================================= --- /trunk/samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml Wed Oct 28 06:47:22 2009 +++ /trunk/samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml Wed Nov 18 14:56:30 2009 @@ -21,9 +21,5 @@ <entry-point class='com.google.gwt.sample.showcase.client.Showcase'/> <!-- Internationalization support. --> - <extend-property name="locale" values="en"/> - <extend-property name="locale" values="ar"/> - <extend-property name="locale" values="fr"/> - <extend-property name="locale" values="zh"/> <set-property-fallback name="locale" value="en"/> </module> ======================================= --- /trunk/user/src/com/google/gwt/user/client/Window.java Fri Oct 16 14:48:33 2009 +++ /trunk/user/src/com/google/gwt/user/client/Window.java Wed Nov 18 14:56:30 2009 @@ -337,6 +337,78 @@ private Location() { } } + + /** + * This class provides access to the browser's navigator object. The mimeTypes + * and plugins properties are not included. + */ + public static class Navigator { + /** + * Gets the navigator.appCodeName. + * + * @return the window's navigator.appCodeName. + */ + public static native String getAppCodeName() /*-{ + return $wnd.navigator.appCodeName; + }-*/; + + /** + * Gets the navigator.appName. + * + * @return the window's navigator.appName. + */ + public static native String getAppName() /*-{ + return $wnd.navigator.appName; + }-*/; + + /** + * Gets the navigator.appVersion. + * + * @return the window's navigator.appVersion. + */ + public static native String getAppVersion() /*-{ + return $wnd.navigator.appVersion; + }-*/; + + /** + * Gets the navigator.platform. + * + * @return the window's navigator.platform. + */ + public static native String getPlatform() /*-{ + return $wnd.navigator.platform; + }-*/; + + /** + * Gets the navigator.userAgent. + * + * @return the window's navigator.userAgent. + */ + public static native String getUserAgent() /*-{ + return $wnd.navigator.userAgent; + }-*/; + + /** + * Gets the navigator.cookieEnabled. + * + * @return the window's navigator.cookieEnabled. + */ + public static native boolean isCookieEnabled() /*-{ + return $wnd.navigator.cookieEnabled; + }-*/; + + /** + * Tests whether Java is enabled in the current browser. + * + * @return the window's navigator.javaEnabled. + */ + public static native boolean isJavaEnabled() /*-{ + return $wnd.navigator.javaEnabled(); + }-*/; + + private Navigator() { + } + } /** * Fired when the browser window is scrolled. ======================================= --- /trunk/user/test/com/google/gwt/user/client/WindowTest.java Mon Oct 26 18:35:41 2009 +++ /trunk/user/test/com/google/gwt/user/client/WindowTest.java Wed Nov 18 14:56:30 2009 @@ -15,12 +15,14 @@ */ package com.google.gwt.user.client; +import com.google.gwt.core.client.JavaScriptException; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.http.client.UrlBuilder; import com.google.gwt.junit.DoNotRunWith; import com.google.gwt.junit.Platform; import com.google.gwt.junit.client.GWTTestCase; import com.google.gwt.user.client.Window.Location; +import com.google.gwt.user.client.Window.Navigator; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; @@ -29,7 +31,7 @@ import java.util.Map; /** - * Test Case for {...@link Cookies}. + * Test Case for {...@link Window}. */ public class WindowTest extends GWTTestCase { @@ -164,6 +166,23 @@ map = Window.Location.buildListParamMap("?foo=bar%20baz%3aqux"); assertEquals(map.get("foo").get(0), "bar baz:qux"); } + + public void testNavigator() { + assertNotNull(Navigator.getAppCodeName()); + assertNotNull(Navigator.getAppName()); + assertNotNull(Navigator.getAppVersion()); + assertNotNull(Navigator.getPlatform()); + assertNotNull(Navigator.getUserAgent()); + assertTrue(Navigator.isCookieEnabled()); + // We don't care if Java is enabled, but need to make sure this call does + // not throw. The try/catch block keeps the compiled code from being + // optimized away. + try { + Navigator.isJavaEnabled(); + } catch (JavaScriptException e) { + throw e; + } + } /** * Tests the ability of the Window to get the client size correctly with and @@ -183,6 +202,12 @@ assertTrue("Expect positive oldClientHeight. " + "This will fail in WebKit if run headless", oldClientHeight > 0); assertTrue(oldClientWidth > 0); + + // Firefox hides scrollbar if clientHeight < 49 even when it should show. + // If we are in this case, simply return. + if (oldClientHeight < 49 && Navigator.getUserAgent().contains("Firefox")) { + return; + } // Compare to the dimensions with scroll bars Window.enableScrolling(true); -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
