| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.util; |
| 22 |
|
|
| 23 |
|
import java.awt.Desktop; |
| 24 |
|
import java.io.IOException; |
| 25 |
|
import java.net.URI; |
| 26 |
|
import java.net.URISyntaxException; |
| 27 |
|
import java.util.ArrayList; |
| 28 |
|
import java.util.List; |
| 29 |
|
|
| 30 |
|
import jalview.bin.Cache; |
| 31 |
|
import jalview.bin.Console; |
| 32 |
|
|
| |
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 14 |
Complexity Density: 0.58 |
|
| 33 |
|
public class BrowserLauncher |
| 34 |
|
{ |
| 35 |
|
private static BrowserLauncher INSTANCE = null; |
| 36 |
|
|
| 37 |
|
private static String preferredBrowser = null; |
| 38 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 39 |
0 |
public static BrowserLauncher getInstance()... |
| 40 |
|
{ |
| 41 |
0 |
if (INSTANCE != null) |
| 42 |
|
{ |
| 43 |
0 |
return INSTANCE; |
| 44 |
|
} |
| 45 |
0 |
INSTANCE = new BrowserLauncher(); |
| 46 |
0 |
return INSTANCE; |
| 47 |
|
} |
| 48 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.43 |
|
| 49 |
0 |
public static void openURL(String url)... |
| 50 |
|
{ |
| 51 |
0 |
if (Platform.isJS()) |
| 52 |
|
{ |
| 53 |
0 |
Platform.openURL(url); |
| 54 |
0 |
return; |
| 55 |
|
} |
| 56 |
|
else |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
{ |
| 63 |
0 |
Desktop d = Desktop.getDesktop(); |
| 64 |
0 |
if (d != null && d.isSupported(Desktop.Action.BROWSE)) |
| 65 |
|
{ |
| 66 |
0 |
try |
| 67 |
|
{ |
| 68 |
0 |
d.browse(new URI(url)); |
| 69 |
|
} catch (IOException e) |
| 70 |
|
{ |
| 71 |
0 |
Console.warn(MessageManager.formatMessage( |
| 72 |
|
"exception.browser_unable_to_launch", url)); |
| 73 |
0 |
Console.warn(e.getMessage()); |
| 74 |
0 |
Console.debug(Cache.getStackTraceString(e)); |
| 75 |
|
} catch (URISyntaxException e1) |
| 76 |
|
{ |
| 77 |
0 |
Console.warn(MessageManager.formatMessage( |
| 78 |
|
"exception.browser_unable_to_launch", url)); |
| 79 |
0 |
Console.warn(e1.getMessage()); |
| 80 |
0 |
Console.debug(Cache.getStackTraceString(e1)); |
| 81 |
|
} |
| 82 |
|
} |
| 83 |
|
else |
| 84 |
|
{ |
| 85 |
0 |
Console.warn(MessageManager |
| 86 |
|
.formatMessage("exception.browser_os_not_supported", url)); |
| 87 |
|
} |
| 88 |
|
} |
| 89 |
|
} |
| 90 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 91 |
0 |
public static void resetBrowser()... |
| 92 |
|
{ |
| 93 |
0 |
resetBrowser(false); |
| 94 |
|
} |
| 95 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 96 |
0 |
public static void resetBrowser(boolean removeIfNull)... |
| 97 |
|
{ |
| 98 |
0 |
String defaultBrowser = Cache.getProperty("DEFAULT_BROWSER"); |
| 99 |
0 |
preferredBrowser = defaultBrowser; |
| 100 |
|
|
| 101 |
|
|
| 102 |
0 |
if (defaultBrowser == null && removeIfNull) |
| 103 |
|
{ |
| 104 |
|
|
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
} |
| 108 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 109 |
0 |
public static List<String> getBrowserList()... |
| 110 |
|
{ |
| 111 |
0 |
return new ArrayList<String>(); |
| 112 |
|
} |
| 113 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 114 |
0 |
public static String getBrowserSystemProperty()... |
| 115 |
|
{ |
| 116 |
|
|
| 117 |
0 |
return "jalview.default.browser"; |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
} |