diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java b/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java index aa929d43c63b..4294e1d3df85 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public class RevealFileAction extends DumbAwareAction { @NotNull public static String getActionName() { - return SystemInfo.isMac ? "Reveal in Finder" : "Show in " + SystemInfo.getFileManagerName(); + return SystemInfo.isMac ? "Reveal in Finder" : "Show in " + ShowFilePathAction.getFileManagerName(); } @Override 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 c45f38bc41d7..22776d256dd6 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,9 +35,9 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; +import com.intellij.openapi.util.AtomicNotNullLazyValue; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; @@ -59,17 +59,51 @@ import java.util.regex.Pattern; public class ShowFilePathAction extends AnAction { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.ShowFilePathAction"); - private static NotNullLazyValue hasNautilusV3 = new NotNullLazyValue() { + private static NotNullLazyValue canUseNautilus = new NotNullLazyValue() { @NotNull @Override protected Boolean compute() { - final String version = ExecUtil.execAndReadLine("nautilus", "--version"); + if (!SystemInfo.isUnix || !SystemInfo.hasXdgMime() || !new File("/usr/bin/nautilus").canExecute()) { + return false; + } + + String fileManager = ExecUtil.execAndReadLine("xdg-mime", "query", "default", "inode/directory"); + if (fileManager == null || !fileManager.contains("nautilus.desktop")) return false; + + String version = ExecUtil.execAndReadLine("nautilus", "--version"); if (version == null) return false; - final Matcher m = Pattern.compile("GNOME nautilus ([0-9.]+)").matcher(version); + + Matcher m = Pattern.compile("GNOME nautilus ([0-9.]+)").matcher(version); return m.find() && StringUtil.compareVersionNumbers(m.group(1), "3") >= 0; } }; + private static final NotNullLazyValue fileManagerName = new AtomicNotNullLazyValue() { + @NotNull + @Override + protected String compute() { + if (SystemInfo.isMac) { + return "Finder"; + } + + if (SystemInfo.isWindows) { + return "Explorer"; + } + + if (SystemInfo.isUnix && SystemInfo.hasXdgMime()) { + String fileManager = ExecUtil.execAndReadLine("xdg-mime", "query", "default", "inode/directory"); + if (fileManager != null) { + Matcher m = Pattern.compile("(.+)\\.desktop").matcher(fileManager); + if (m.find()) { + return StringUtil.capitalize(m.group(1)); + } + } + } + + return "File Manager"; + } + }; + @Override public void update(final AnActionEvent e) { if (SystemInfo.isMac || !isSupported()) { @@ -180,7 +214,12 @@ public class ShowFilePathAction extends AnAction { public static boolean isSupported() { return SystemInfo.isWindows || Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN) || - SystemInfo.hasXdgOpen() || SystemInfo.hasNautilus(); + SystemInfo.hasXdgOpen() || canUseNautilus.getValue(); + } + + @NotNull + public static String getFileManagerName() { + return fileManagerName.getValue(); } /** @deprecated use {@linkplain #openFile(java.io.File)} (to remove in IDEA 13) */ @@ -224,7 +263,7 @@ public class ShowFilePathAction extends AnAction { } } - private static void doOpen(@NotNull final File dir, @Nullable final File toSelect) throws IOException, ExecutionException { + private static void doOpen(@NotNull File dir, @Nullable File toSelect) throws IOException, ExecutionException { if (SystemInfo.isWindows) { String cmd; if (toSelect != null) { @@ -253,23 +292,15 @@ public class ShowFilePathAction extends AnAction { return; } - if (Registry.is("ide.use.nautilus3") && SystemInfo.hasNautilus() && hasNautilusV3.getValue()) { - if (toSelect != null) { - new GeneralCommandLine("nautilus", toSelect.getAbsolutePath()).createProcess(); - } - else { - new GeneralCommandLine("nautilus", dir.getAbsolutePath()).createProcess(); - } + if (canUseNautilus.getValue()) { + new GeneralCommandLine("nautilus", (toSelect != null ? toSelect : dir).getAbsolutePath()).createProcess(); return; } - final String path = dir.getAbsolutePath(); + String path = dir.getAbsolutePath(); if (SystemInfo.hasXdgOpen()) { new GeneralCommandLine("/usr/bin/xdg-open", path).createProcess(); } - else if (SystemInfo.hasNautilus()) { - new GeneralCommandLine("nautilus", path).createProcess(); - } else if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { Desktop.getDesktop().open(new File(path)); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java index ed5914b49483..3b3ca49a6510 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,6 @@ public class ShowLogAction extends AnAction implements DumbAware { @NotNull public static String getActionName() { - return "Reveal Log in " + SystemInfo.getFileManagerName(); + return SystemInfo.isMac ? "Reveal in Finder" : "Show in " + ShowFilePathAction.getFileManagerName(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java index ec0024bcf658..f33b29e377d1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.intellij.openapi.fileEditor.impl; +import com.intellij.ide.actions.ShowFilePathAction; import com.intellij.ide.ui.UISettings; import com.intellij.openapi.actionSystem.KeyboardShortcut; import com.intellij.openapi.actionSystem.Shortcut; @@ -42,9 +43,7 @@ import com.intellij.ui.components.JBPanel; import com.intellij.ui.docking.DockManager; import com.intellij.ui.tabs.JBTabs; import com.intellij.util.Alarm; -import com.intellij.util.IconUtil; import com.intellij.util.PairFunction; -import com.intellij.util.PlatformUtils; import com.intellij.util.containers.ArrayListSet; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; @@ -174,7 +173,7 @@ public class EditorsSplitters extends JBPanel { painter.appendLine("Open a file by name with " + getActionShortcutText("GotoFile")).smaller().withBullet() .appendLine("Open Recent files with " + getActionShortcutText("RecentFiles")).smaller().withBullet() .appendLine("Open Navigation Bar with " + getActionShortcutText("ShowNavBar")).smaller().withBullet() - .appendLine("Drag'n'Drop file(s) here from " + SystemInfo.getFileManagerName()).smaller().withBullet() + .appendLine("Drag'n'Drop file(s) here from " + ShowFilePathAction.getFileManagerName()).smaller().withBullet() .draw(g, new PairFunction>() { @Override public Pair fun(Integer width, Integer height) { diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 6ccbbc5c6401..98b94dc97fff 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -238,10 +238,6 @@ enable.animation.on.dialogs=false type.ahead.logging.enabled=false fast.tree.expand.in.structure.view=false -ide.use.nautilus3=true -# suppress inspection "UnusedProperty" -ide.use.nautilus3.description=Use Nautilus (if available) for 'Show fine in %OS_file_manager_name%' actions. - ide.goto.implementation.show.interfaces=true # suppress inspection "UnusedProperty" ide.goto.implementation.show.interfaces.description=Whether to show sub-interfaces when invoking\ diff --git a/platform/util/src/com/intellij/openapi/util/SystemInfo.java b/platform/util/src/com/intellij/openapi/util/SystemInfo.java index 98ef2813fad9..028862694925 100644 --- a/platform/util/src/com/intellij/openapi/util/SystemInfo.java +++ b/platform/util/src/com/intellij/openapi/util/SystemInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,6 +93,17 @@ public class SystemInfo extends SystemInfoRt { return ourHasXdgOpen.getValue(); } + private static final NotNullLazyValue ourHasXdgMime = new AtomicNotNullLazyValue() { + @NotNull + @Override + protected Boolean compute() { + return isUnix && new File("/usr/bin/xdg-mime").canExecute(); + } + }; + public static boolean hasXdgMime() { + return ourHasXdgOpen.getValue(); + } + private static final NotNullLazyValue hasNautilus = new AtomicNotNullLazyValue() { @NotNull @Override @@ -100,11 +111,12 @@ public class SystemInfo extends SystemInfoRt { return isUnix && new File("/usr/bin/nautilus").canExecute(); } }; + /** @deprecated implementation details (to remove in IDEA 13) */ public static boolean hasNautilus() { return hasNautilus.getValue(); } - /** @deprecated use {@linkplain #getFileManagerName()} (to remove in IDEA 13) */ + /** @deprecated implementation details (to remove in IDEA 13) */ public static final String nativeFileManagerName = "File Manager"; private static final NotNullLazyValue ourFileManagerName = new AtomicNotNullLazyValue() { @NotNull @@ -112,11 +124,10 @@ public class SystemInfo extends SystemInfoRt { protected String compute() { return isMac ? "Finder" : isWindows ? "Explorer" : - hasNautilus() ? "Nautilus" : "File Manager"; } }; - @NotNull + /** @deprecated implementation details (to remove in IDEA 13) */ public static String getFileManagerName() { return ourFileManagerName.getValue(); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java index 02bad656ef2c..c9bfa4baeaa3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.intellij.openapi.vcs.configurable; +import com.intellij.ide.actions.ShowFilePathAction; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; @@ -96,7 +97,7 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { myPromptsPanel.setSize(myPromptsPanel.getPreferredSize()); // todo check text! myOnPatchCreation.setName((SystemInfo.isMac ? "Reveal patch in" : "Show patch in ") + - SystemInfo.getFileManagerName() + " after creation:"); + ShowFilePathAction.getFileManagerName() + " after creation:"); } public void apply() throws ConfigurationException {