From c0127ddef5eb43e50aff55b9bd5867076e5bea53 Mon Sep 17 00:00:00 2001 From: mguessan Date: Wed, 11 Feb 2009 23:01:14 +0000 Subject: [PATCH] Implement OSX DesktopBrowser git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@349 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/ui/DesktopBrowser.java | 29 ++++++++++++++-------- src/java/davmail/ui/OSXDesktopBrowser.java | 16 ++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 src/java/davmail/ui/OSXDesktopBrowser.java diff --git a/src/java/davmail/ui/DesktopBrowser.java b/src/java/davmail/ui/DesktopBrowser.java index 46dddf22..e2cba11e 100644 --- a/src/java/davmail/ui/DesktopBrowser.java +++ b/src/java/davmail/ui/DesktopBrowser.java @@ -23,16 +23,25 @@ public final class DesktopBrowser { AwtDesktopBrowser.browse(location); } catch (ClassNotFoundException e) { DavGatewayTray.debug("Java 6 Desktop class not available"); - // failover : try SWT - try { - // trigger ClassNotFoundException - ClassLoader classloader = AboutFrame.class.getClassLoader(); - classloader.loadClass("org.eclipse.swt.program.Program"); - SwtDesktopBrowser.browse(location); - } catch (ClassNotFoundException e2) { - DavGatewayTray.error("Open link not supported (tried AWT Desktop and SWT Program"); - } catch (Exception e2) { - DavGatewayTray.error("Unable to open link", e2); + // failover for MacOSX + if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) { + try { + OSXDesktopBrowser.browse(location); + } catch (Exception e2) { + DavGatewayTray.error("Unable to open link", e2); + } + } else { + // failover : try SWT + try { + // trigger ClassNotFoundException + ClassLoader classloader = AboutFrame.class.getClassLoader(); + classloader.loadClass("org.eclipse.swt.program.Program"); + SwtDesktopBrowser.browse(location); + } catch (ClassNotFoundException e2) { + DavGatewayTray.error("Open link not supported (tried AWT Desktop and SWT Program"); + } catch (Exception e2) { + DavGatewayTray.error("Unable to open link", e2); + } } } catch (Exception e) { DavGatewayTray.error("Unable to open link", e); diff --git a/src/java/davmail/ui/OSXDesktopBrowser.java b/src/java/davmail/ui/OSXDesktopBrowser.java new file mode 100644 index 00000000..040bf1ba --- /dev/null +++ b/src/java/davmail/ui/OSXDesktopBrowser.java @@ -0,0 +1,16 @@ +package davmail.ui; + +import java.io.IOException; +import java.net.URI; + +/** + * Failover: Runtime.exec open URL + */ +public class OSXDesktopBrowser { + private OSXDesktopBrowser() { + } + + public static void browse(URI location) throws IOException { + Runtime.getRuntime().exec("open "+location.toString()); + } +}