2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.Desktop;
24 import java.io.IOException;
26 import java.net.URISyntaxException;
27 import java.util.ArrayList;
28 import java.util.List;
30 import jalview.bin.Cache;
31 import jalview.bin.Console;
33 public class BrowserLauncher
35 private static BrowserLauncher INSTANCE = null;
37 private static String preferredBrowser = null;
39 public static BrowserLauncher getInstance()
45 INSTANCE = new BrowserLauncher();
49 public static void openURL(String url)
53 Platform.openURL(url);
63 Desktop d = Desktop.getDesktop();
64 if (d != null && d.isSupported(Desktop.Action.BROWSE))
68 d.browse(new URI(url));
69 } catch (IOException e)
71 Console.warn(MessageManager.formatMessage(
72 "exception.browser_unable_to_launch", url));
73 Console.warn(e.getMessage());
74 Console.debug(Cache.getStackTraceString(e));
75 } catch (URISyntaxException e1)
77 Console.warn(MessageManager.formatMessage(
78 "exception.browser_unable_to_launch", url));
79 Console.warn(e1.getMessage());
80 Console.debug(Cache.getStackTraceString(e1));
85 Console.warn(MessageManager
86 .formatMessage("exception.browser_os_not_supported", url));
91 public static void resetBrowser()
96 public static void resetBrowser(boolean removeIfNull)
98 String defaultBrowser = Cache.getProperty("DEFAULT_BROWSER");
99 preferredBrowser = defaultBrowser;
100 // System.setProperty(getBrowserSystemProperty(),
101 // Cache.getProperty("DEFAULT_BROWSER"));
102 if (defaultBrowser == null && removeIfNull)
104 // System.clearProperty(getBrowserSystemProperty());
109 public static List<String> getBrowserList()
111 return new ArrayList<String>();
114 public static String getBrowserSystemProperty()
116 // return IBrowserLaunching.BROWSER_SYSTEM_PROPERTY;
117 return "jalview.default.browser";