mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-128713 (option to prevent file chooser from peeking inside non-user directories)
This commit is contained in:
+8
-1
@@ -99,4 +99,11 @@ sun.java2d.pmoffscreen=false
|
||||
# Maximum size (kilobytes) IDEA will load for showing past file contents -
|
||||
# in Show Diff or when calculating Digest Diff
|
||||
#---------------------------------------------------------------------
|
||||
#idea.max.vcs.loaded.size.kb=20480
|
||||
#idea.max.vcs.loaded.size.kb=20480
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# IDEA file chooser peeks inside directories to detect whether they contain a valid project
|
||||
# (to mark such directories with a corresponding icon).
|
||||
# Uncommenting the option prevents this behavior outside of user home directory.
|
||||
#---------------------------------------------------------------------
|
||||
#idea.chooser.lookup.for.project.dirs=false
|
||||
|
||||
+9
-8
@@ -24,6 +24,7 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.projectImport.ProjectOpenProcessor;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -34,6 +35,7 @@ import javax.swing.*;
|
||||
*/
|
||||
public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
|
||||
private static final Icon ourProjectIcon = IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl());
|
||||
private static final boolean ourCanInspectDirs = SystemProperties.getBooleanProperty("idea.chooser.lookup.for.project.dirs", true);
|
||||
|
||||
public OpenProjectFileChooserDescriptor(boolean chooseFiles) {
|
||||
super(chooseFiles, true, chooseFiles, chooseFiles, false, false);
|
||||
@@ -64,15 +66,14 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
|
||||
}
|
||||
|
||||
private static boolean canInspectDirectory(VirtualFile file) {
|
||||
if (file.getParent() == null) return false;
|
||||
|
||||
VirtualFile home = VfsUtil.getUserHomeDir();
|
||||
if (home == null) return false; // unnatural situation
|
||||
VirtualFile homes = home.getParent();
|
||||
if (homes == null) return false; // another one
|
||||
if (homes.equals(file.getParent()) || VfsUtilCore.isAncestor(file, homes, false)) return false;
|
||||
|
||||
return true;
|
||||
if (home == null || VfsUtilCore.isAncestor(file, home, false)) {
|
||||
return false;
|
||||
}
|
||||
if (ourCanInspectDirs || VfsUtilCore.isAncestor(home, file, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Icon getImporterIcon(VirtualFile file) {
|
||||
|
||||
Reference in New Issue
Block a user