X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Futil%2FBrowserLauncher.java;h=f9fa80d11e70ad4c4454b2afe51d53116c44ab4f;hb=a7169b1c72607f3c9357195b4999869650a2a891;hp=cddbecbc40538c5c3c642ef79631dd13ae26aedb;hpb=f4b18ae31d37e694b59875f26e0863179de248f1;p=jalview.git
diff --git a/src/jalview/util/BrowserLauncher.java b/src/jalview/util/BrowserLauncher.java
index cddbecb..f9fa80d 100644
--- a/src/jalview/util/BrowserLauncher.java
+++ b/src/jalview/util/BrowserLauncher.java
@@ -1,43 +1,51 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.util;
-import edu.stanford.ejalbert.exception.BrowserLaunchingInitializingException;
-import edu.stanford.ejalbert.exception.UnsupportedOperatingSystemException;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
import jalview.bin.Cache;
import jalview.bin.Console;
-public class BrowserLauncher extends edu.stanford.ejalbert.BrowserLauncher
+public class BrowserLauncher
{
private static BrowserLauncher INSTANCE = null;
- // get singleton BrowserLauncher instance
+ private static String preferredBrowser = null;
+
public static BrowserLauncher getInstance()
{
- if (INSTANCE == null)
+ if (INSTANCE != null)
{
- try
- {
- INSTANCE = new BrowserLauncher();
- } catch (BrowserLaunchingInitializingException e)
- {
- Console.warn(MessageManager.formatMessage(
- "exception.browser_unable_to_launch", e.getMessage()));
- } catch (UnsupportedOperatingSystemException e)
- {
- Console.warn(MessageManager.formatMessage("exception."));
- Console.debug(e.getMessage());
- }
+ return INSTANCE;
}
+ INSTANCE = new BrowserLauncher();
return INSTANCE;
}
- public BrowserLauncher() throws BrowserLaunchingInitializingException,
- UnsupportedOperatingSystemException
- {
- super();
- }
-
- private static String preferredBrowser = null;
-
public static void openURL(String url)
{
if (Platform.isJS())
@@ -52,28 +60,61 @@ public class BrowserLauncher extends edu.stanford.ejalbert.BrowserLauncher
* @j2sIgnore
*/
{
- BrowserLauncher bl = getInstance();
- if (bl != null)
+ Desktop d = Desktop.getDesktop();
+ if (d != null && d.isSupported(Desktop.Action.BROWSE))
{
- if (Platform.isMac() || preferredBrowser == null)
+ try
{
- bl.openURLinBrowser(url);
- }
- else
+ d.browse(new URI(url));
+ } catch (IOException e)
+ {
+ Console.warn(MessageManager.formatMessage(
+ "exception.browser_unable_to_launch", url));
+ Console.warn(e.getMessage());
+ Console.debug(Cache.getStackTraceString(e));
+ } catch (URISyntaxException e1)
{
- bl.openURLinBrowser(preferredBrowser, url);
+ Console.warn(MessageManager.formatMessage(
+ "exception.browser_unable_to_launch", url));
+ Console.warn(e1.getMessage());
+ Console.debug(Cache.getStackTraceString(e1));
}
}
else
{
- Console.warn("Could not open URL '" + url + "'");
+ Console.warn(MessageManager
+ .formatMessage("exception.browser_os_not_supported", url));
}
}
}
public static void resetBrowser()
{
+ resetBrowser(false);
+ }
+
+ public static void resetBrowser(boolean removeIfNull)
+ {
String defaultBrowser = Cache.getProperty("DEFAULT_BROWSER");
preferredBrowser = defaultBrowser;
+ // System.setProperty(getBrowserSystemProperty(),
+ // Cache.getProperty("DEFAULT_BROWSER"));
+ if (defaultBrowser == null && removeIfNull)
+ {
+ // System.clearProperty(getBrowserSystemProperty());
+ }
+
}
+
+ public static List getBrowserList()
+ {
+ return new ArrayList();
+ }
+
+ public static String getBrowserSystemProperty()
+ {
+ // return IBrowserLaunching.BROWSER_SYSTEM_PROPERTY;
+ return "jalview.default.browser";
+ }
+
}
\ No newline at end of file