mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
"Show in file manager" fixed for .jar roots
This commit is contained in:
@@ -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.
|
||||
@@ -30,15 +30,17 @@ import java.io.File;
|
||||
*/
|
||||
public class ProjectViewSelectInExplorerTarget implements SelectInTarget, DumbAware {
|
||||
@Override
|
||||
public boolean canSelect(final SelectInContext context) {
|
||||
final VirtualFile file = context.getVirtualFile();
|
||||
return RevealFileAction.isLocalFile(file);
|
||||
public boolean canSelect(SelectInContext context) {
|
||||
VirtualFile file = ShowFilePathAction.findLocalFile(context.getVirtualFile());
|
||||
return file != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectIn(final SelectInContext context, final boolean requestFocus) {
|
||||
final VirtualFile file = context.getVirtualFile();
|
||||
ShowFilePathAction.openFile(new File(file.getPresentableUrl()));
|
||||
public void selectIn(SelectInContext context, boolean requestFocus) {
|
||||
VirtualFile file = ShowFilePathAction.findLocalFile(context.getVirtualFile());
|
||||
if (file != null) {
|
||||
ShowFilePathAction.openFile(new File(file.getPresentableUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,21 +22,16 @@ import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class RevealFileAction extends DumbAwareAction {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
|
||||
final Presentation presentation = e.getPresentation();
|
||||
VirtualFile file = ShowFilePathAction.findLocalFile(PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()));
|
||||
Presentation presentation = e.getPresentation();
|
||||
presentation.setText(getActionName());
|
||||
presentation.setEnabled(isLocalFile(file));
|
||||
}
|
||||
|
||||
public static boolean isLocalFile(@Nullable final VirtualFile file) {
|
||||
return file != null && file.isInLocalFileSystem();
|
||||
presentation.setEnabled(file != null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -46,12 +41,9 @@ public class RevealFileAction extends DumbAwareAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
|
||||
assert file != null;
|
||||
revealFile(file);
|
||||
}
|
||||
|
||||
private static void revealFile(@NotNull final VirtualFile file) {
|
||||
ShowFilePathAction.openFile(new File(file.getPresentableUrl()));
|
||||
VirtualFile file = ShowFilePathAction.findLocalFile(PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()));
|
||||
if (file != null) {
|
||||
ShowFilePathAction.openFile(new File(file.getPresentableUrl()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -391,4 +392,20 @@ public class ShowFilePathAction extends AnAction {
|
||||
openFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile findLocalFile(@Nullable VirtualFile file) {
|
||||
if (file == null) return null;
|
||||
|
||||
if (file.isInLocalFileSystem()) {
|
||||
return file;
|
||||
}
|
||||
|
||||
VirtualFileSystem fs = file.getFileSystem();
|
||||
if (fs instanceof JarFileSystem && file.getParent() == null) {
|
||||
return ((JarFileSystem)fs).getLocalVirtualFileFor(file);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user