3 import java.awt.Desktop;
4 import java.io.IOException;
6 import java.net.URISyntaxException;
7 import java.util.ArrayList;
10 import jalview.bin.Cache;
11 import jalview.bin.Console;
13 public class BrowserLauncher
15 private static BrowserLauncher INSTANCE = null;
17 private static String preferredBrowser = null;
19 public static BrowserLauncher getInstance()
25 INSTANCE = new BrowserLauncher();
29 public static void openURL(String url)
33 Platform.openURL(url);
43 Desktop d = Desktop.getDesktop();
44 if (d != null && d.isSupported(Desktop.Action.BROWSE))
48 d.browse(new URI(url));
49 } catch (IOException e)
51 Console.warn(MessageManager.formatMessage(
52 "exception.browser_unable_to_launch", url));
53 Console.warn(e.getMessage());
54 Console.debug(Cache.getStackTraceString(e));
55 } catch (URISyntaxException e1)
57 Console.warn(MessageManager.formatMessage(
58 "exception.browser_unable_to_launch", url));
59 Console.warn(e1.getMessage());
60 Console.debug(Cache.getStackTraceString(e1));
65 Console.warn(MessageManager
66 .formatMessage("exception.browser_os_not_supported", url));
71 public static void resetBrowser()
76 public static void resetBrowser(boolean removeIfNull)
78 String defaultBrowser = Cache.getProperty("DEFAULT_BROWSER");
79 preferredBrowser = defaultBrowser;
80 // System.setProperty(getBrowserSystemProperty(),
81 // Cache.getProperty("DEFAULT_BROWSER"));
82 if (defaultBrowser == null && removeIfNull)
84 // System.clearProperty(getBrowserSystemProperty());
89 public static List<String> getBrowserList()
91 return new ArrayList<String>();
94 public static String getBrowserSystemProperty()
96 // return IBrowserLaunching.BROWSER_SYSTEM_PROPERTY;
97 return "jalview.default.browser";