From 61fe161c39c8f92e8560ec4ecf916a56a734d52f Mon Sep 17 00:00:00 2001 From: Damien Goutte-Gattat Date: Mon, 24 Feb 2025 21:39:30 +0000 Subject: [PATCH 1/2] Use xdg-open to open URLs. On GNU/Linux (or similar, non-macOS, non-Windows platforms), when attempting to open a URL, try using the `xdg-open` command first, before any other possible browser. This would ensure that the link is open using the user's preferred browser (assuming a FreeDesktop.org-compliant desktop environment). closes #1263 --- .../org/protege/editor/core/ui/util/NativeBrowserLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protege-editor-core/src/main/java/org/protege/editor/core/ui/util/NativeBrowserLauncher.java b/protege-editor-core/src/main/java/org/protege/editor/core/ui/util/NativeBrowserLauncher.java index 9e19da101..d4334afd0 100644 --- a/protege-editor-core/src/main/java/org/protege/editor/core/ui/util/NativeBrowserLauncher.java +++ b/protege-editor-core/src/main/java/org/protege/editor/core/ui/util/NativeBrowserLauncher.java @@ -34,7 +34,7 @@ else if (OSUtils.isWindows()){ } else { //assume Unix or Linux String[] browsers = { - "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" }; + "xdg-open", "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" }; String browser = null; for (int count = 0; count < browsers.length && browser == null; count++) if (Runtime.getRuntime().exec( From f6d053a0a8c42bb53c83445ec2fb2fcad7c6bc2c Mon Sep 17 00:00:00 2001 From: Damien Goutte-Gattat Date: Mon, 24 Feb 2025 21:43:13 +0000 Subject: [PATCH 2/2] Misc fixes to the NativeBrowserLauncher. Silence some warnings in the NativeBrowserLauncher by: * avoiding using a "raw type" `Class`; * avoiding the single-argument form of `java.lang.Runtime.exec` (deprecated in Java18). --- .../protege/editor/core/ui/util/NativeBrowserLauncher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protege-editor-core/src/main/java/org/protege/editor/core/ui/util/NativeBrowserLauncher.java b/protege-editor-core/src/main/java/org/protege/editor/core/ui/util/NativeBrowserLauncher.java index d4334afd0..bc3a9d4f0 100644 --- a/protege-editor-core/src/main/java/org/protege/editor/core/ui/util/NativeBrowserLauncher.java +++ b/protege-editor-core/src/main/java/org/protege/editor/core/ui/util/NativeBrowserLauncher.java @@ -25,12 +25,12 @@ public class NativeBrowserLauncher { public static void openURL(String url) { try { if (OSUtils.isOSX()) { - Class fileMgr = Class.forName("com.apple.eio.FileManager"); + Class fileMgr = Class.forName("com.apple.eio.FileManager"); Method openURL = fileMgr.getDeclaredMethod("openURL", String.class); openURL.invoke(null, url); } else if (OSUtils.isWindows()){ - Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); + Runtime.getRuntime().exec(new String[] {"rundll32", "url.dll,FileProtocolHandler", url}); } else { //assume Unix or Linux String[] browsers = {