Revision: 6987
Author: b...@google.com
Date: Wed Nov 18 08:54:53 2009
Log: Add support for calling into OS X's Application class to set the Dock  
icon and clean up the application menu.

Patch by: bobv
Review by: jat, bruce
http://code.google.com/p/google-web-toolkit/source/detail?r=6987

Modified:
  /trunk/dev/core/src/com/google/gwt/dev/BootStrapPlatform.java
  /trunk/dev/core/src/com/google/gwt/dev/SwingUI.java

=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/BootStrapPlatform.java       Fri Nov 
 
13 07:52:59 2009
+++ /trunk/dev/core/src/com/google/gwt/dev/BootStrapPlatform.java       Wed Nov 
 
18 08:54:53 2009
@@ -37,6 +37,9 @@
     */
    public static void initGui() {
      if (isMac() && !GraphicsEnvironment.isHeadless()) {
+      // This has to be set before any UI components are initialized
+      System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+          "Development Mode");
        GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
        Toolkit.getDefaultToolkit();
      }
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/SwingUI.java Wed Nov 18 08:39:41  
2009
+++ /trunk/dev/core/src/com/google/gwt/dev/SwingUI.java Wed Nov 18 08:54:53  
2009
@@ -224,6 +224,8 @@
      setIconImages(topLogger, gwtIcon48, gwtIcon32, gwtIcon64, gwtIcon128,
          gwtIcon16);
      frame.setVisible(true);
+
+    maybeInitializeOsXApplication();
    }

    @Override
@@ -316,6 +318,52 @@
      }
      return moduleTabPanel;
    }
+
+  /**
+   * This method contains code that will call certain Apple extensions to  
make
+   * the DevMode app integrate into the system UI a bit better. These  
methods
+   * are called reflectively so that we don't have to build gwt-dev  
against a
+   * no-op stub library.
+   */
+  private void maybeInitializeOsXApplication() {
+    Throwable ex;
+    try {
+      Class<?> applicationClass =  
Class.forName("com.apple.eawt.Application");
+
+      topLogger.log(TreeLogger.SPAM, "Got Application class, on OS X");
+
+      Object application =  
applicationClass.getMethod("getApplication").invoke(
+          null);
+      assert application != null : "application";
+
+      // Remove the about menu entry
+       
applicationClass.getMethod("removeAboutMenuItem").invoke(application);
+
+      // Remove the preferences menu entry
+      applicationClass.getMethod("removePreferencesMenuItem").invoke(
+          application);
+
+      // Make the Dock icon pretty
+      applicationClass.getMethod("setDockIconImage", Image.class).invoke(
+          application, loadImageIcon("icon128.png").getImage());
+
+      return;
+    } catch (ClassNotFoundException e) {
+      // Nothing to do here, this is expected on non-Apple JVMs.
+      return;
+    } catch (RuntimeException e) {
+      ex = e;
+    } catch (IllegalAccessException e) {
+      ex = e;
+    } catch (InvocationTargetException e) {
+      ex = e;
+    } catch (NoSuchMethodException e) {
+      ex = e;
+    }
+
+    topLogger.log(TreeLogger.WARN, "Unable to initialize some OS X UI  
support",
+        ex);
+  }

    /**
     * Set the images for the frame.  On JDK 1.5, only the last icon  
supplied is

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to