[jsword-svn] r1292 - in trunk: bibledesktop/etc/eclipse bibledesktop/etc/installer/macosx bibledesktop/etc/jnlp bibledesktop/jar bibledesktop/jar/jsword-common-aqua-1.0.6 bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop common-swing/src/main/java/org/crosswire/common/swing common-swing/src/main/java/org/crosswire/common/swing/desktop
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Sat Apr 21 14:26:10 MST 2007
Author: dmsmith
Date: 2007-04-21 14:26:10 -0700 (Sat, 21 Apr 2007)
New Revision: 1292
Added:
trunk/bibledesktop/jar/jsword-common-aqua-1.0.6/
trunk/bibledesktop/jar/jsword-common-aqua-1.0.6/jsword-common-aqua-1.0.6.jar
trunk/common-swing/src/main/java/org/crosswire/common/swing/Actionable.java
Modified:
trunk/bibledesktop/etc/eclipse/bibledesktop-app-desktop.launch
trunk/bibledesktop/etc/installer/macosx/Info.plist
trunk/bibledesktop/etc/jnlp/bibledesktop.jnlp
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
trunk/common-swing/src/main/java/org/crosswire/common/swing/ActionFactory.java
trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ToolBar.java
Log:
Add code to allow BibleDesktop to integrate better on the Mac.
Modified: trunk/bibledesktop/etc/eclipse/bibledesktop-app-desktop.launch
===================================================================
--- trunk/bibledesktop/etc/eclipse/bibledesktop-app-desktop.launch 2007-04-21 21:17:54 UTC (rev 1291)
+++ trunk/bibledesktop/etc/eclipse/bibledesktop-app-desktop.launch 2007-04-21 21:26:10 UTC (rev 1292)
@@ -5,7 +5,7 @@
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="bibledesktop"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m -ea"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m -ea -Dcom.apple.mrj.application.apple.menu.about.name="Bible Desktop""/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
Modified: trunk/bibledesktop/etc/installer/macosx/Info.plist
===================================================================
--- trunk/bibledesktop/etc/installer/macosx/Info.plist 2007-04-21 21:17:54 UTC (rev 1291)
+++ trunk/bibledesktop/etc/installer/macosx/Info.plist 2007-04-21 21:26:10 UTC (rev 1292)
@@ -47,6 +47,7 @@
<string>$JAVAROOT/jsword-1.0.6.jar</string>
<string>$JAVAROOT/jsword-common-1.0.6.jar</string>
<string>$JAVAROOT/jsword-common-swing-1.0.6.jar</string>
+ <string>$JAVAROOT/jsword-common-aqua-1.0.6.jar</string>
<string>$JAVAROOT/lucene-core-2.1.0.jar</string>
</array>
<key>Properties</key>
Modified: trunk/bibledesktop/etc/jnlp/bibledesktop.jnlp
===================================================================
--- trunk/bibledesktop/etc/jnlp/bibledesktop.jnlp 2007-04-21 21:17:54 UTC (rev 1291)
+++ trunk/bibledesktop/etc/jnlp/bibledesktop.jnlp 2007-04-21 21:26:10 UTC (rev 1292)
@@ -32,6 +32,7 @@
<jar href="jsword- at release.version@.jar"/>
<jar href="jsword-common- at release.version@.jar"/>
<jar href="jsword-common-swing- at release.version@.jar"/>
+ <jar href="jsword-common-aqua- at release.version@.jar"/>
<jar href="javatar-2.5.jar"/>
<jar href="jdom-1.0.jar"/>
<jar href="commons-codec-1.3.jar"/>
@@ -41,7 +42,7 @@
<jar href="lucene-core-2.1.0.jar"/>
<jar href="jlfgr-1_0.jar"/>
<property name="apple.laf.useScreenMenuBar" value="true"/>
- <property name="com.apple.mrj.application.apple.menu.about.name" value="BibleDesktop"/>
+ <property name="com.apple.mrj.application.apple.menu.about.name" value="Bible Desktop"/>
</resources>
<application-desc main-class="org.crosswire.bibledesktop.desktop.Desktop"/>
Added: trunk/bibledesktop/jar/jsword-common-aqua-1.0.6/jsword-common-aqua-1.0.6.jar
===================================================================
(Binary files differ)
Property changes on: trunk/bibledesktop/jar/jsword-common-aqua-1.0.6/jsword-common-aqua-1.0.6.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2007-04-21 21:17:54 UTC (rev 1291)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2007-04-21 21:26:10 UTC (rev 1292)
@@ -56,10 +56,10 @@
import javax.swing.WindowConstants;
import org.crosswire.bibledesktop.book.BibleViewPane;
-import org.crosswire.bibledesktop.book.MultiBookPane;
import org.crosswire.bibledesktop.book.DisplaySelectEvent;
import org.crosswire.bibledesktop.book.DisplaySelectListener;
import org.crosswire.bibledesktop.book.DisplaySelectPane;
+import org.crosswire.bibledesktop.book.MultiBookPane;
import org.crosswire.bibledesktop.display.BookDataDisplay;
import org.crosswire.bibledesktop.display.URLEvent;
import org.crosswire.bibledesktop.display.URLEventListener;
@@ -84,6 +84,7 @@
import org.crosswire.common.util.CWClassLoader;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.LucidRuntimeException;
+import org.crosswire.common.util.OSType;
import org.crosswire.common.util.Reporter;
import org.crosswire.common.util.ResourceUtil;
import org.crosswire.common.xml.XMLUtil;
@@ -359,8 +360,6 @@
private ToolBar createToolBar()
{
ToolBar toolbar = new ToolBar(this);
- toolbar.setRollover(true);
- toolbar.setFloatable(true);
toolbar.add(views.getContextAction(ViewManager.NEW_TAB)).addMouseListener(barStatus);
toolbar.add(actions.getAction(DesktopActions.OPEN)).addMouseListener(barStatus);
@@ -377,8 +376,15 @@
//toolbar.add(actions.getAction("Diff")).addMouseListener(barStatus);
//toolbar.addSeparator();
toolbar.add(actions.getAction(DesktopActions.CONTENTS)).addMouseListener(barStatus);
- toolbar.add(actions.getAction(DesktopActions.ABOUT)).addMouseListener(barStatus);
+ toolbar.setRollover(true);
+ // Floating is not appropriate on a Mac
+ // It is the default on all others
+ if (!OSType.MAC.equals(OSType.getOSType()))
+ {
+ toolbar.add(actions.getAction(DesktopActions.ABOUT)).addMouseListener(barStatus);
+ }
+
return toolbar;
}
/**
@@ -401,8 +407,14 @@
menuFile.add(actions.getAction(DesktopActions.SAVE)).addMouseListener(barStatus);
menuFile.add(actions.getAction(DesktopActions.SAVE_AS)).addMouseListener(barStatus);
menuFile.add(actions.getAction(DesktopActions.SAVE_ALL)).addMouseListener(barStatus);
- menuFile.addSeparator();
- menuFile.add(actions.getAction(DesktopActions.EXIT)).addMouseListener(barStatus);
+
+ // Mac OSX provides "Quit" on the Program menu
+ if (!OSType.MAC.equals(OSType.getOSType()))
+ {
+ menuFile.addSeparator();
+ menuFile.add(actions.getAction(DesktopActions.EXIT)).addMouseListener(barStatus);
+ }
+
menuFile.setToolTipText(null);
return menuFile;
}
@@ -518,8 +530,14 @@
{
JMenu menuHelp = new JMenu(actions.getAction(DesktopActions.HELP));
menuHelp.add(actions.getAction(DesktopActions.CONTENTS)).addMouseListener(barStatus);
- menuHelp.addSeparator();
- menuHelp.add(actions.getAction(DesktopActions.ABOUT)).addMouseListener(barStatus);
+
+ // Mac provides the About action on the Program menu.
+ if (!OSType.MAC.equals(OSType.getOSType()))
+ {
+ menuHelp.addSeparator();
+ menuHelp.add(actions.getAction(DesktopActions.ABOUT)).addMouseListener(barStatus);
+ }
+
menuHelp.setToolTipText(null);
return menuHelp;
}
@@ -1050,6 +1068,13 @@
/* @Override */
public void run()
{
+ // These Mac properties give the application a Mac behavior
+ if (OSType.MAC.equals(OSType.getOSType()))
+ {
+ System.setProperty("apple.laf.useScreenMenuBar","true"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name", Msg.getApplicationTitle()); //$NON-NLS-1$
+ }
+
// new BusStart();
ExceptionPane.setHelpDeskListener(true);
LookAndFeelUtil.initialize();
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2007-04-21 21:17:54 UTC (rev 1291)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2007-04-21 21:26:10 UTC (rev 1292)
@@ -24,6 +24,7 @@
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.net.URL;
import java.util.Iterator;
@@ -38,8 +39,11 @@
import org.crosswire.bibledesktop.display.splitlist.SplitBookDataDisplay;
import org.crosswire.bibledesktop.display.tab.TabbedBookDataDisplay;
import org.crosswire.common.config.swing.ConfigEditorFactory;
+import org.crosswire.common.swing.Actionable;
import org.crosswire.common.swing.ActionFactory;
import org.crosswire.common.swing.desktop.ViewVisitor;
+import org.crosswire.common.util.Logger;
+import org.crosswire.common.util.OSType;
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.passage.Key;
@@ -59,7 +63,7 @@
* @author Joe Walker [joe at eireneh dot com]
* @author DM Smith [dmsmith555 at gmail dot com]
*/
-public class DesktopActions
+public class DesktopActions implements Actionable
{
/**
* Create the actions for the desktop
@@ -69,6 +73,8 @@
{
this.desktop = desktop;
actions = new ActionFactory(Desktop.class, this);
+
+ macOSXRegistration();
}
/**
@@ -81,6 +87,14 @@
return actions.getAction(key);
}
+ /* (non-Javadoc)
+ * @see org.crosswire.common.swing.Actionable#actionPerformed(java.lang.String)
+ */
+ public void actionPerformed(String action)
+ {
+ actions.actionPerformed(action);
+ }
+
/**
* @return the desktop to which these actions apply
*/
@@ -453,6 +467,54 @@
}
/**
+ * Register the application with Apple EAWT, which provides support for the Application Menu, with
+ * About, Preferences (Options) and Quit (Exit).
+ */
+ public void macOSXRegistration()
+ {
+ if (OSType.MAC.equals(OSType.getOSType()))
+ {
+ try
+ {
+ //org.crosswire.common.aqua.OSXAdapter.registerMacOSXApplication(actions, DesktopActions.ABOUT, DesktopActions.OPTIONS, DesktopActions.EXIT);
+
+ 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)
+ {
+ Object[] args = { actions, DesktopActions.ABOUT, DesktopActions.OPTIONS, DesktopActions.EXIT };
+ registerMethod.invoke(osxAdapter, args);
+ }
+
+ Class[] defEnablePrefArgs = { boolean.class };
+ Method prefsEnableMethod = osxAdapter.getDeclaredMethod("enablePrefs", defEnablePrefArgs); //$NON-NLS-1$
+ if (prefsEnableMethod != null)
+ {
+ Object args[] = { Boolean.TRUE };
+ prefsEnableMethod.invoke(osxAdapter, args);
+ }
+ }
+ catch (NoClassDefFoundError e)
+ {
+ // This is thrown when EAWT or MacOSXadapter is not present.
+ log.error("This version of Mac OS X does not support the Apple EAWT. Application Menu handling has been disabled (" + e + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ catch (ClassNotFoundException e)
+ {
+ // Should not happen
+ log.error("This version of Mac OS X does not support the Apple EAWT. Application Menu handling has been disabled (" + e + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ catch (Exception e)
+ {
+ // Everything else.
+ log.error("Exception while loading the OSXAdapter:", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
*
*/
private static final class ShowSideBarVisitor implements ViewVisitor
@@ -526,4 +588,9 @@
* The Book installer window
*/
private SitesPane sites;
+
+ /**
+ * The log stream
+ */
+ protected static final Logger log = Logger.getLogger(DesktopActions.class);
}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/ActionFactory.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/ActionFactory.java 2007-04-21 21:17:54 UTC (rev 1291)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/ActionFactory.java 2007-04-21 21:26:10 UTC (rev 1292)
@@ -58,7 +58,7 @@
* @author DM Smith [dmsmith555 at yahoo dot com]
* @author Joe Walker [joe at eireneh dot com]
*/
-public class ActionFactory implements ActionListener
+public class ActionFactory implements ActionListener, Actionable
{
/**
* Constructor that distinguishes between the object to call and the type
@@ -76,6 +76,15 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.common.swing.Actionable#performAction(java.lang.String)
+ */
+ public void actionPerformed(String action)
+ {
+ Action act = getAction(action);
+ act.actionPerformed(new ActionEvent(this, 0, action));
+ }
+
+ /* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent ev)
Added: trunk/common-swing/src/main/java/org/crosswire/common/swing/Actionable.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/Actionable.java (rev 0)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/Actionable.java 2007-04-21 21:26:10 UTC (rev 1292)
@@ -0,0 +1,34 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ * http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ * The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: ActionFactory.java 1286 2007-04-20 13:59:19 -0400 (Fri, 20 Apr 2007) dmsmith $
+ */
+package org.crosswire.common.swing;
+
+/**
+ * The Actionable provides the ability to perform an action by name.
+ *
+ * @see gnu.lgpl.License for license details.
+ * The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public interface Actionable
+{
+ void actionPerformed(String action);
+}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ToolBar.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ToolBar.java 2007-04-21 21:17:54 UTC (rev 1291)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ToolBar.java 2007-04-21 21:26:10 UTC (rev 1292)
@@ -39,6 +39,7 @@
import org.crosswire.common.swing.ActionFactory;
import org.crosswire.common.swing.CWAction;
+import org.crosswire.common.util.OSType;
/**
* This toolbar allows for manipulating how it looks. That is it allows for:<ul>
@@ -60,6 +61,15 @@
{
this.frame = frame;
actions = new ActionFactory(ToolBar.class, this);
+
+ setRollover(true);
+
+ // Floating is not appropriate on a Mac
+ // It is the default on all others
+ if (OSType.MAC.equals(OSType.getOSType()))
+ {
+ setFloatable(false);
+ }
}
/**
More information about the jsword-svn
mailing list