Restrict non Desktop API for linux only (Win7 cause problems)

This commit is contained in:
Manfred Karrer 2014-11-20 00:58:26 +01:00
parent 5b5bacc397
commit 15854bdf06

View File

@ -21,6 +21,8 @@ import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.awt.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -78,6 +80,24 @@ public class Utilities {
}
}
public static void openURI(URI uri) throws IOException {
if (!isLinux()
&& Desktop.isDesktopSupported()
&& Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(uri);
}
else {
// On Linux Desktop is poorly implemented.
// See https://stackoverflow.com/questions/18004150/desktop-api-is-not-supported-on-the-current-platform
if (!DesktopApi.browse(uri))
throw new IOException("Failed to open URI: " + uri.toString());
}
}
public static void openWebPage(String target) throws Exception {
openURI(new URI(target));
}
public static <T> T jsonToObject(String jsonString, Class<T> classOfT) {
Gson gson =
@ -138,16 +158,6 @@ public class Utilities {
printElapsedTime("");
}
public static void openURI(URI uri) throws Exception {
// On Linux Desktop is poorly implemented.
// See https://stackoverflow.com/questions/18004150/desktop-api-is-not-supported-on-the-current-platform
if (!DesktopApi.browse(uri))
throw new Exception("Failed to open URI: " + uri.toString());
}
public static void openWebPage(String target) throws Exception {
openURI(new URI(target));
}
public static Object copy(Serializable orig) {
Object obj = null;