diff options
Diffstat (limited to 'platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java')
-rw-r--r-- | platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java b/platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java index 736dcd8afe22..c5843b3d53c8 100644 --- a/platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java +++ b/platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java @@ -127,6 +127,7 @@ public class BrowserLauncherAppless extends BrowserLauncher { GeneralSettings settings = getGeneralSettingsInstance(); if (settings.isUseDefaultBrowser()) { + boolean tryToUseCli = true; if (isDesktopActionSupported(Desktop.Action.BROWSE)) { try { Desktop.getDesktop().browse(uri); @@ -135,13 +136,17 @@ public class BrowserLauncherAppless extends BrowserLauncher { } catch (Exception e) { LOG.warn("Error while using Desktop API, fallback to CLI", e); + // if "No application knows how to open", then we must not try to use OS open + tryToUseCli = !e.getMessage().contains("Error code: -10814"); } } - List<String> command = getDefaultBrowserCommand(); - if (command != null) { - doLaunch(uri.toString(), command, null, project, ArrayUtil.EMPTY_STRING_ARRAY, null); - return; + if (tryToUseCli) { + List<String> command = getDefaultBrowserCommand(); + if (command != null) { + doLaunch(uri.toString(), command, null, project, ArrayUtil.EMPTY_STRING_ARRAY, null); + return; + } } } @@ -171,7 +176,7 @@ public class BrowserLauncherAppless extends BrowserLauncher { File file = new File(url); if (!browse && isDesktopActionSupported(Desktop.Action.OPEN)) { if (!file.exists()) { - doShowError(IdeBundle.message("error.file.does.not.exist", file.getPath()), null, null, null, null); + showError(IdeBundle.message("error.file.does.not.exist", file.getPath()), null, null, null, null); return; } @@ -189,10 +194,10 @@ public class BrowserLauncherAppless extends BrowserLauncher { } if (uri == null) { - doShowError(IdeBundle.message("error.malformed.url", url), null, project, null, null); + showError(IdeBundle.message("error.malformed.url", url), null, project, null, null); } else { - browse(uri); + browse(uri, project); } } @@ -438,7 +443,7 @@ public class BrowserLauncherAppless extends BrowserLauncher { String message = browser != null ? browser.getBrowserNotFoundMessage() : IdeBundle.message("error.please.specify.path.to.web.browser", CommonBundle.settingsActionPath()); - doShowError(message, browser, project, IdeBundle.message("title.browser.not.found"), launchTask); + showError(message, browser, project, IdeBundle.message("title.browser.not.found"), launchTask); return false; } @@ -475,7 +480,7 @@ public class BrowserLauncherAppless extends BrowserLauncher { return true; } catch (ExecutionException e) { - doShowError(e.getMessage(), browser, project, null, null); + showError(e.getMessage(), browser, project, null, null); return false; } } @@ -487,7 +492,7 @@ public class BrowserLauncherAppless extends BrowserLauncher { @Nullable Runnable launchTask) { } - protected void doShowError(@Nullable String error, @Nullable WebBrowser browser, @Nullable Project project, String title, @Nullable Runnable launchTask) { + protected void showError(@Nullable String error, @Nullable WebBrowser browser, @Nullable Project project, String title, @Nullable Runnable launchTask) { // Not started yet. Not able to show message up. (Could happen in License panel under Linux). LOG.warn(error); } |