[jsword-svn] r1313 - trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Fri May 4 13:40:20 MST 2007


Author: dmsmith
Date: 2007-05-04 13:40:19 -0700 (Fri, 04 May 2007)
New Revision: 1313

Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
Log:
Fixed a jnlp macosx integration bug.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java	2007-05-03 21:39:51 UTC (rev 1312)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java	2007-05-04 20:40:19 UTC (rev 1313)
@@ -380,7 +380,7 @@
 
         // Floating is not appropriate on a Mac
         // It is the default on all others
-        if (!OSType.MAC.equals(OSType.getOSType()))
+        if (!actions.isOSXRegistered())
         {
             toolbar.add(actions.getAction(DesktopActions.ABOUT)).addMouseListener(barStatus);
         }
@@ -409,7 +409,7 @@
         menuFile.add(actions.getAction(DesktopActions.SAVE_ALL)).addMouseListener(barStatus);
 
         // Mac OSX provides "Quit" on the Program menu
-        if (!OSType.MAC.equals(OSType.getOSType()))
+        if (!actions.isOSXRegistered())
         {
             menuFile.addSeparator();
             menuFile.add(actions.getAction(DesktopActions.EXIT)).addMouseListener(barStatus);
@@ -522,7 +522,7 @@
         //menuTools.addSeparator();
         menuTools.add(actions.getAction(DesktopActions.BOOKS)).addMouseListener(barStatus);
 
-        if (!OSType.MAC.equals(OSType.getOSType()))
+        if (!actions.isOSXRegistered())
         {
             menuTools.add(actions.getAction(DesktopActions.OPTIONS)).addMouseListener(barStatus);
         }
@@ -537,7 +537,7 @@
         menuHelp.add(actions.getAction(DesktopActions.CONTENTS)).addMouseListener(barStatus);
 
         // Mac provides the About action on the Program menu.
-        if (!OSType.MAC.equals(OSType.getOSType()))
+        if (!actions.isOSXRegistered())
         {
             menuHelp.addSeparator();
             menuHelp.add(actions.getAction(DesktopActions.ABOUT)).addMouseListener(barStatus);

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java	2007-05-03 21:39:51 UTC (rev 1312)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java	2007-05-04 20:40:19 UTC (rev 1313)
@@ -74,7 +74,7 @@
         this.desktop = desktop;
         actions = new ActionFactory(Desktop.class, this);
 
-        macOSXRegistration();
+        osxRegistered = macOSXRegistration();
     }
 
     /**
@@ -104,6 +104,15 @@
     }
 
     /**
+     * Determines whether MacOSX has been registered.
+     * @return true when there is full MacOSX integration.
+     */
+    public boolean isOSXRegistered()
+    {
+        return osxRegistered;
+    }
+
+    /**
      * @return the Bible installer dialog
      */
     public SitesPane getSites()
@@ -469,17 +478,17 @@
     /**
      * Register the application with Apple EAWT, which provides support for the Application Menu, with
      * About, Preferences (Options) and Quit (Exit).
+     * @return true on success
      */
-    public void macOSXRegistration()
+    public boolean macOSXRegistration()
     {
         if (OSType.MAC.equals(OSType.getOSType()))
         {
             try
             {
-                //org.crosswire.common.aqua.OSXAdapter.registerMacOSXApplication(actions, DesktopActions.ABOUT, DesktopActions.OPTIONS, DesktopActions.EXIT);
+                // Get a class object
+                Class osxAdapter = Class.forName("org.crosswire.common.aqua.OSXAdapter"); //$NON-NLS-1$
 
-                Class osxAdapter = ClassLoader.getSystemClassLoader().loadClass("org.crosswire.common.aqua.OSXAdapter"); //$NON-NLS-1$
-
                 Class[] defRegisterArgs = { Actionable.class, String.class, String.class, String.class };
                 Method registerMethod = osxAdapter.getDeclaredMethod("registerMacOSXApplication", defRegisterArgs); //$NON-NLS-1$
                 if (registerMethod != null)
@@ -495,6 +504,7 @@
                     Object[] args = { Boolean.TRUE };
                     prefsEnableMethod.invoke(osxAdapter, args);
                 }
+                return true;
             }
             catch (NoClassDefFoundError e)
             {
@@ -512,6 +522,7 @@
                 log.error("Exception while loading the OSXAdapter:", e); //$NON-NLS-1$
             }
         }
+        return false;
     }
 
     /**
@@ -580,6 +591,10 @@
     private ActionFactory actions;
 
     /**
+     * Indicates whether there is MacOSX integration.
+     */
+    boolean osxRegistered;
+    /**
      * The About window
      */
     private AboutPane atp;




More information about the jsword-svn mailing list