mirror of https://github.com/rusefi/RomRaider.git
Enhance browser support. Use java.awt.Desktop in case his desktop supports it.
This commit is contained in:
parent
589ee639f4
commit
632c736db5
|
@ -21,6 +21,8 @@ package com.romraider.net;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
public class BrowserControl {
|
||||
private static final Logger LOGGER = Logger.getLogger(BrowserControl.class);
|
||||
|
@ -30,6 +32,18 @@ public class BrowserControl {
|
|||
}
|
||||
|
||||
public static void displayURL(String url) {
|
||||
try {
|
||||
Class<?> display = Class.forName("java.awt.Desktop");
|
||||
Object getDesktopMethod = display.getDeclaredMethod("getDesktop").invoke(null);
|
||||
Method browseMethod = display.getDeclaredMethod("browse", java.net.URI.class);
|
||||
browseMethod.invoke(getDesktopMethod, new URI(url));
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Failed to display URL via java.awt.Desktop. Calling by OS depended method.", e);
|
||||
displayURLtraditional(url);
|
||||
}
|
||||
}
|
||||
|
||||
private static void displayURLtraditional(String url) {
|
||||
boolean windows = isWindowsPlatform();
|
||||
String cmd = null;
|
||||
try {
|
||||
|
@ -72,4 +86,4 @@ public class BrowserControl {
|
|||
private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
|
||||
private static final String UNIX_PATH = "netscape";
|
||||
private static final String UNIX_FLAG = "-remote openURL";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue