From 3ac41c5c7eefa0aa260d34aba29621ee05f0b0d5 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 10 Nov 2011 23:45:11 +0100 Subject: [PATCH] IDEA-75242 (workaround for unknown Ubuntu/GnomeVFS bug) --- .../ide/actions/ShowFilePathAction.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java index af8fa01d04e6..2fc467d8b923 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java @@ -186,22 +186,36 @@ public class ShowFilePathAction extends AnAction { } private static void doOpen(@NotNull final String path) throws IOException, ExecutionException { - if (SystemInfo.isWindows) { new GeneralCommandLine("explorer", "/select,", path).createProcess(); + return; } - else if (SystemInfo.isMac) { + + if (SystemInfo.isMac) { final String script = String.format( "tell application \"Finder\"\n" + "\treveal {\"%s\"} as POSIX file\n" + "\tactivate\n" + "end tell", path); new GeneralCommandLine(ExecUtil.getOsascriptPath(), "-e", script).createProcess(); + return; } - else if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { - Desktop.getDesktop().open(new File(path)); + + // workaround for Ubuntu 11.10 inability to open file:/path/ URLs + try { + if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { + Desktop.getDesktop().open(new File(path)); + return; + } } - else if (SystemInfo.hasXdgOpen) { + catch (IOException e) { + final String message = e.getMessage(); + if (!new File(path).isDirectory() || message == null || !message.startsWith("Failed to show URI:file")) { + throw e; + } + } + + if (SystemInfo.hasXdgOpen) { new GeneralCommandLine("/usr/bin/xdg-open", path).createProcess(); } else if (SystemInfo.isGnome) {