mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 13:11:39 +07:00
[ui] hides "Reveal In" action when unavailable (IDEA-218224)
GitOrigin-RevId: c2fcb0f95138de04f8143face4e01848d2be7667
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a1919a60ba
commit
004feeac3a
@@ -11,7 +11,6 @@ import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
@@ -72,20 +71,23 @@ public class RevealFileAction extends DumbAwareAction {
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
VirtualFile file = findLocalFile(e.getData(CommonDataKeys.VIRTUAL_FILE));
|
||||
Presentation presentation = e.getPresentation();
|
||||
presentation.setText(getActionName());
|
||||
presentation.setEnabled(file != null);
|
||||
e.getPresentation().setEnabledAndVisible(isSupported() && getFile(e) != null);
|
||||
e.getPresentation().setText(getActionName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
VirtualFile file = findLocalFile(e.getData(CommonDataKeys.VIRTUAL_FILE));
|
||||
VirtualFile file = getFile(e);
|
||||
if (file != null) {
|
||||
openFile(new File(file.getPresentableUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile getFile(@NotNull AnActionEvent e) {
|
||||
return findLocalFile(e.getData(CommonDataKeys.VIRTUAL_FILE));
|
||||
}
|
||||
|
||||
public static boolean isSupported() {
|
||||
return SystemInfo.isWindows || SystemInfo.isMac || SystemInfo.hasXdgOpen() ||
|
||||
Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN);
|
||||
|
||||
Reference in New Issue
Block a user