Implement OSX DesktopBrowser

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@349 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-02-11 23:01:14 +00:00
parent ad70032056
commit c0127ddef5
2 changed files with 35 additions and 10 deletions

View File

@ -23,6 +23,14 @@ public final class DesktopBrowser {
AwtDesktopBrowser.browse(location);
} catch (ClassNotFoundException e) {
DavGatewayTray.debug("Java 6 Desktop class not available");
// 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
@ -34,6 +42,7 @@ public final class DesktopBrowser {
} catch (Exception e2) {
DavGatewayTray.error("Unable to open link", e2);
}
}
} catch (Exception e) {
DavGatewayTray.error("Unable to open link", e);
}

View File

@ -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());
}
}