mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Drop no longer needed path APIs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -380,7 +380,7 @@ public class SourcePathsStep extends AbstractStepWithProgress<List<JavaModuleSou
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final VirtualFile contentEntryDir = getContentEntryDir();
|
||||
if (contentEntryDir != null) {
|
||||
myChooserDescriptor.setRoot(contentEntryDir);
|
||||
myChooserDescriptor.setRoots(contentEntryDir);
|
||||
final String textBefore = myField.getText().trim();
|
||||
super.actionPerformed(e);
|
||||
if (!textBefore.equals(myField.getText().trim())) {
|
||||
|
||||
+21
-18
@@ -20,6 +20,7 @@ import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ExcludeFolder;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -42,9 +43,9 @@ public abstract class JavaContentEntryEditor extends ContentEntryEditor {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExcludeFolder doAddExcludeFolder(@NotNull final String path) {
|
||||
final boolean isCompilerOutput = isCompilerOutput(path);
|
||||
final boolean isExplodedDirectory = isExplodedDirectory(path);
|
||||
protected ExcludeFolder doAddExcludeFolder(@NotNull final VirtualFile file) {
|
||||
final boolean isCompilerOutput = isCompilerOutput(file);
|
||||
final boolean isExplodedDirectory = isExplodedDirectory(file);
|
||||
if (isCompilerOutput || isExplodedDirectory) {
|
||||
if (isCompilerOutput) {
|
||||
myCompilerExtension.setExcludeOutput(true);
|
||||
@@ -54,32 +55,35 @@ public abstract class JavaContentEntryEditor extends ContentEntryEditor {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return super.doAddExcludeFolder(path);
|
||||
return super.doAddExcludeFolder(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRemoveExcludeFolder(@NotNull final ExcludeFolder excludeFolder) {
|
||||
final String path = VfsUtil.urlToPath(excludeFolder.getUrl());
|
||||
if (isCompilerOutput(path)) {
|
||||
myCompilerExtension.setExcludeOutput(false);
|
||||
}
|
||||
if (isExplodedDirectory(path)) {
|
||||
getModel().setExcludeExplodedDirectory(false);
|
||||
final VirtualFile file = excludeFolder.getFile();
|
||||
if (file != null) {
|
||||
if (isCompilerOutput(file)) {
|
||||
myCompilerExtension.setExcludeOutput(false);
|
||||
}
|
||||
if (isExplodedDirectory(file)) {
|
||||
getModel().setExcludeExplodedDirectory(false);
|
||||
}
|
||||
}
|
||||
super.doRemoveExcludeFolder(excludeFolder);
|
||||
}
|
||||
|
||||
private boolean isCompilerOutput(final String path) {
|
||||
final String compilerOutputPath = VfsUtil.urlToPath(myCompilerExtension.getCompilerOutputUrl());
|
||||
if (FileUtil.pathsEqual(compilerOutputPath, path, true)) {
|
||||
private boolean isCompilerOutput(@NotNull final VirtualFile file) {
|
||||
final VirtualFile compilerOutputPath = myCompilerExtension.getCompilerOutputPath();
|
||||
if (file.equals(compilerOutputPath)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final String compilerOutputPathForTests = VfsUtil.urlToPath(myCompilerExtension.getCompilerOutputUrlForTests());
|
||||
if (FileUtil.pathsEqual(compilerOutputPathForTests, path, true)) {
|
||||
final VirtualFile compilerOutputPathForTests = myCompilerExtension.getCompilerOutputPathForTests();
|
||||
if (file.equals(compilerOutputPathForTests)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final String path = file.getPath();
|
||||
if (myCompilerExtension.isCompilerOutputPathInherited()) {
|
||||
final ProjectStructureConfigurable instance = ProjectStructureConfigurable.getInstance(getModel().getModule().getProject());
|
||||
final String compilerOutput = VfsUtil.urlToPath(instance.getProjectConfig().getCompilerOutputUrl());
|
||||
@@ -91,8 +95,7 @@ public abstract class JavaContentEntryEditor extends ContentEntryEditor {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isExplodedDirectory(final String path) {
|
||||
final String explodedUrl = getModel().getExplodedDirectoryUrl();
|
||||
return explodedUrl != null && FileUtil.pathsEqual(VfsUtil.urlToPath(explodedUrl), path, true);
|
||||
private boolean isExplodedDirectory(@NotNull final VirtualFile file) {
|
||||
return file.equals(getModel().getExplodedDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
+21
-10
@@ -21,33 +21,44 @@ import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.fileChooser.FileSystemTree;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class GotoModuleDirectory extends FileChooserAction {
|
||||
protected void actionPerformed(final FileSystemTree fileSystemTree, final AnActionEvent e) {
|
||||
final String path = getModulePath(e);
|
||||
if (path != null) {
|
||||
fileSystemTree.select(new Runnable() {
|
||||
final VirtualFile moduleDir = getModuleDir(e);
|
||||
if (moduleDir != null) {
|
||||
fileSystemTree.select(moduleDir, new Runnable() {
|
||||
public void run() {
|
||||
fileSystemTree.expand(path, null);
|
||||
fileSystemTree.expand(moduleDir, null);
|
||||
}
|
||||
}, path);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void update(final FileSystemTree fileSystemTree, final AnActionEvent e) {
|
||||
final Presentation presentation = e.getPresentation();
|
||||
final String path = getModulePath(e);
|
||||
presentation.setEnabled(path != null && fileSystemTree.isUnderRoots(path));
|
||||
final VirtualFile moduleDir = getModuleDir(e);
|
||||
presentation.setEnabled(moduleDir != null && fileSystemTree.isUnderRoots(moduleDir));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getModulePath(final AnActionEvent e) {
|
||||
private static VirtualFile getModuleDir(final AnActionEvent e) {
|
||||
Module module = e.getData(LangDataKeys.MODULE_CONTEXT);
|
||||
if (module == null) {
|
||||
module = e.getData(LangDataKeys.MODULE);
|
||||
}
|
||||
return module == null || module.isDisposed() ? null : PathUtil.getParentPath(module.getModuleFilePath());
|
||||
|
||||
if (module != null && !module.isDisposed()) {
|
||||
final VirtualFile moduleFile = module.getModuleFile();
|
||||
if (moduleFile != null && moduleFile.isValid()) {
|
||||
final VirtualFile moduleDir = moduleFile.getParent();
|
||||
if (moduleDir != null && moduleDir.isValid()) {
|
||||
return moduleDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-113
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.openapi.fileChooser.FileChooserUtil;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
@@ -40,7 +39,6 @@ import java.util.EventListener;
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallback {
|
||||
|
||||
private boolean myIsSelected;
|
||||
private ContentRootPanel myContentRootPanel;
|
||||
private JPanel myMainPanel;
|
||||
@@ -193,24 +191,7 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SourceFolder addSourceFolder(@NotNull final String path, final boolean isTestSource) {
|
||||
final SourceFolder sourceFolder = doAddSourceFolder(path, isTestSource);
|
||||
if (sourceFolder != null) {
|
||||
myEventDispatcher.getMulticaster().sourceFolderAdded(this, sourceFolder);
|
||||
update();
|
||||
}
|
||||
return sourceFolder;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected SourceFolder doAddSourceFolder(@NotNull final String path, final boolean isTestSource) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
return contentEntry != null ? contentEntry.addSourceFolder(VfsUtil.pathToUrl(path), isTestSource) : null;
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #addSourceFolder(String, boolean)} (to remove in IDEA 12) */
|
||||
@Nullable
|
||||
public SourceFolder addSourceFolder(VirtualFile file, boolean isTestSource) {
|
||||
public SourceFolder addSourceFolder(@NotNull final VirtualFile file, boolean isTestSource) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
if (contentEntry != null) {
|
||||
final SourceFolder sourceFolder = contentEntry.addSourceFolder(file, isTestSource);
|
||||
@@ -226,6 +207,12 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected SourceFolder doAddSourceFolder(@NotNull final VirtualFile file, final boolean isTestSource) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
return contentEntry != null ? contentEntry.addSourceFolder(file, isTestSource) : null;
|
||||
}
|
||||
|
||||
public void removeSourceFolder(@NotNull final SourceFolder sourceFolder) {
|
||||
try {
|
||||
doRemoveSourceFolder(sourceFolder);
|
||||
@@ -242,21 +229,9 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ExcludeFolder addExcludeFolder(@NotNull final String path) {
|
||||
public ExcludeFolder addExcludeFolder(@NotNull final VirtualFile file) {
|
||||
try {
|
||||
return doAddExcludeFolder(path);
|
||||
}
|
||||
finally {
|
||||
myEventDispatcher.getMulticaster().folderExcluded(this, FileChooserUtil.pathToFile(path, false));
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #addExcludeFolder(String)} (to remove in IDEA 12) */
|
||||
@Nullable
|
||||
public ExcludeFolder addExcludeFolder(VirtualFile file) {
|
||||
try {
|
||||
return doAddExcludeFolder(file.getPath());
|
||||
return doAddExcludeFolder(file);
|
||||
}
|
||||
finally {
|
||||
myEventDispatcher.getMulticaster().folderExcluded(this, file);
|
||||
@@ -265,14 +240,7 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ExcludeFolder doAddExcludeFolder(@NotNull final String path) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
return contentEntry != null ? contentEntry.addExcludeFolder(path) : null;
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #doAddExcludeFolder(String)} (to remove in IDEA 12) */
|
||||
@Nullable
|
||||
protected ExcludeFolder doAddExcludeFolder(VirtualFile file) {
|
||||
protected ExcludeFolder doAddExcludeFolder(@NotNull final VirtualFile file) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
return contentEntry != null ? contentEntry.addExcludeFolder(file) : null;
|
||||
}
|
||||
@@ -302,51 +270,20 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSource(@NotNull final String path) {
|
||||
final SourceFolder sourceFolder = getSourceFolder(path);
|
||||
public boolean isSource(@NotNull final VirtualFile file) {
|
||||
final SourceFolder sourceFolder = getSourceFolder(file);
|
||||
return sourceFolder != null && !sourceFolder.isTestSource();
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #isSource(String)} (to remove in IDEA 12) */
|
||||
public boolean isSource(VirtualFile file) {
|
||||
return file != null && !isTestSource(file.getPath());
|
||||
}
|
||||
|
||||
public boolean isTestSource(@NotNull final String path) {
|
||||
final SourceFolder sourceFolder = getSourceFolder(path);
|
||||
public boolean isTestSource(@NotNull final VirtualFile file) {
|
||||
final SourceFolder sourceFolder = getSourceFolder(file);
|
||||
return sourceFolder != null && sourceFolder.isTestSource();
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #isTestSource(String)} (to remove in IDEA 12) */
|
||||
public boolean isTestSource(VirtualFile file) {
|
||||
return file != null && isTestSource(file.getPath());
|
||||
public boolean isExcluded(@NotNull final VirtualFile file) {
|
||||
return getExcludeFolder(file) != null;
|
||||
}
|
||||
|
||||
public boolean isExcluded(@NotNull final String path) {
|
||||
return getExcludeFolder(path) != null;
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #isExcluded(String)} (to remove in IDEA 12) */
|
||||
public boolean isExcluded(VirtualFile file) {
|
||||
return file != null && getExcludeFolder(file.getPath()) != null;
|
||||
}
|
||||
|
||||
public boolean isUnderExcludedDirectory(@NotNull final String path) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
if (contentEntry == null) {
|
||||
return false;
|
||||
}
|
||||
final ExcludeFolder[] excludeFolders = contentEntry.getExcludeFolders();
|
||||
for (ExcludeFolder excludeFolder : excludeFolders) {
|
||||
final String excludedPath = VfsUtil.urlToPath(excludeFolder.getUrl());
|
||||
if (FileUtil.isAncestor(excludedPath, path, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #isUnderExcludedDirectory(String)} (to remove in IDEA 12) */
|
||||
public boolean isUnderExcludedDirectory(@NotNull final VirtualFile file) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
if (contentEntry == null) {
|
||||
@@ -366,23 +303,7 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ExcludeFolder getExcludeFolder(@NotNull final String path) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
if (contentEntry == null) {
|
||||
return null;
|
||||
}
|
||||
for (final ExcludeFolder excludeFolder : contentEntry.getExcludeFolders()) {
|
||||
final String excludedPath = VfsUtil.urlToPath(excludeFolder.getUrl());
|
||||
if (FileUtil.pathsEqual(excludedPath, path, true)) {
|
||||
return excludeFolder;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #getExcludeFolder(String)} (to remove in IDEA 12) */
|
||||
@Nullable
|
||||
public ExcludeFolder getExcludeFolder(VirtualFile file) {
|
||||
public ExcludeFolder getExcludeFolder(@NotNull final VirtualFile file) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
if (contentEntry == null) {
|
||||
return null;
|
||||
@@ -401,23 +322,7 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SourceFolder getSourceFolder(@NotNull final String path) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
if (contentEntry == null) {
|
||||
return null;
|
||||
}
|
||||
for (SourceFolder sourceFolder : contentEntry.getSourceFolders()) {
|
||||
final String sourcePath = VfsUtil.urlToPath(sourceFolder.getUrl());
|
||||
if (FileUtil.pathsEqual(sourcePath, path, true)) {
|
||||
return sourceFolder;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #getSourceFolder(String)} (to remove in IDEA 12) */
|
||||
@Nullable
|
||||
public SourceFolder getSourceFolder(VirtualFile file) {
|
||||
public SourceFolder getSourceFolder(@NotNull final VirtualFile file) {
|
||||
final ContentEntry contentEntry = getContentEntry();
|
||||
if (contentEntry == null) {
|
||||
return null;
|
||||
|
||||
+15
-25
@@ -22,8 +22,7 @@ import com.intellij.openapi.fileChooser.FileElement;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ExcludeFolder;
|
||||
import com.intellij.openapi.roots.SourceFolder;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,7 +30,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
public class ContentEntryTreeCellRenderer extends NodeRenderer {
|
||||
protected final ContentEntryTreeEditor myTreeEditor;
|
||||
@@ -49,15 +47,15 @@ public class ContentEntryTreeCellRenderer extends NodeRenderer {
|
||||
if (userObject instanceof NodeDescriptor) {
|
||||
final Object element = ((NodeDescriptor)userObject).getElement();
|
||||
if (element instanceof FileElement) {
|
||||
final String path = ((FileElement)element).getPath();
|
||||
if (new File(path).isDirectory()) {
|
||||
final VirtualFile file = ((FileElement)element).getFile();
|
||||
if (file != null && file.isDirectory()) {
|
||||
final ContentEntry contentEntry = editor.getContentEntry();
|
||||
if (contentEntry != null) {
|
||||
final String prefix = getPrefix(contentEntry, path);
|
||||
final String prefix = getPrefix(contentEntry, file);
|
||||
if (prefix.length() > 0) {
|
||||
append(" (" + prefix + ")", new SimpleTextAttributes(Font.PLAIN, Color.GRAY));
|
||||
}
|
||||
setIcon(updateIcon(contentEntry, path, getIcon(), expanded));
|
||||
setIcon(updateIcon(contentEntry, file, getIcon(), expanded));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,38 +63,36 @@ public class ContentEntryTreeCellRenderer extends NodeRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPrefix(final ContentEntry entry, final String path) {
|
||||
private static String getPrefix(final ContentEntry entry, final VirtualFile file) {
|
||||
for (final SourceFolder sourceFolder : entry.getSourceFolders()) {
|
||||
final String sourcePath = VfsUtil.urlToPath(sourceFolder.getUrl());
|
||||
if (FileUtil.pathsEqual(sourcePath, path, true)) {
|
||||
if (file.equals(sourceFolder.getFile())) {
|
||||
return sourceFolder.getPackagePrefix();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected Icon updateIcon(final ContentEntry entry, final String path, final Icon originalIcon, final boolean expanded) {
|
||||
protected Icon updateIcon(final ContentEntry entry, final VirtualFile file, Icon originalIcon, final boolean expanded) {
|
||||
for (ExcludeFolder excludeFolder : entry.getExcludeFolders()) {
|
||||
final String excludePath = VfsUtil.urlToPath(excludeFolder.getUrl());
|
||||
if (FileUtil.isAncestor(excludePath, path, false)) {
|
||||
final VirtualFile excludePath = excludeFolder.getFile();
|
||||
if (excludePath != null && VfsUtilCore.isAncestor(excludePath, file, false)) {
|
||||
return IconSet.getExcludeIcon(expanded);
|
||||
}
|
||||
}
|
||||
|
||||
final SourceFolder[] sourceFolders = entry.getSourceFolders();
|
||||
for (SourceFolder sourceFolder : sourceFolders) {
|
||||
final String sourcePath = VfsUtil.urlToPath(sourceFolder.getUrl());
|
||||
if (FileUtil.pathsEqual(sourcePath, path, true)) {
|
||||
if (file.equals(sourceFolder.getFile())) {
|
||||
return IconSet.getSourceRootIcon(sourceFolder.isTestSource(), expanded);
|
||||
}
|
||||
}
|
||||
|
||||
Icon icon = originalIcon;
|
||||
String currentRoot = null;
|
||||
VirtualFile currentRoot = null;
|
||||
for (SourceFolder sourceFolder : sourceFolders) {
|
||||
final String sourcePath = VfsUtil.urlToPath(sourceFolder.getUrl());
|
||||
if (FileUtil.isAncestor(sourcePath, path, true)) {
|
||||
if (currentRoot != null && FileUtil.isAncestor(sourcePath, currentRoot, false)) {
|
||||
final VirtualFile sourcePath = sourceFolder.getFile();
|
||||
if (sourcePath != null && VfsUtilCore.isAncestor(sourcePath, file, true)) {
|
||||
if (currentRoot != null && VfsUtilCore.isAncestor(sourcePath, currentRoot, false)) {
|
||||
continue;
|
||||
}
|
||||
icon = IconSet.getSourceFolderIcon(sourceFolder.isTestSource(), expanded);
|
||||
@@ -105,10 +101,4 @@ public class ContentEntryTreeCellRenderer extends NodeRenderer {
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #updateIcon(com.intellij.openapi.roots.ContentEntry, String, javax.swing.Icon, boolean)} (to remove in IDEA 12) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
protected Icon updateIcon(final ContentEntry entry, final VirtualFile file, Icon originalIcon, final boolean expanded) {
|
||||
return updateIcon(entry, file.getPath(), originalIcon, expanded);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-6
@@ -33,16 +33,14 @@ import com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl;
|
||||
import com.intellij.openapi.fileChooser.impl.FileTreeBuilder;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.SourceFolder;
|
||||
import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction;
|
||||
import com.intellij.openapi.roots.ui.configuration.actions.ToggleExcludedStateAction;
|
||||
import com.intellij.openapi.roots.ui.configuration.actions.ToggleSourcesStateAction;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.TreeSpeedSearch;
|
||||
import com.intellij.ui.roots.ToolbarPanel;
|
||||
@@ -143,14 +141,17 @@ public class ContentEntryTreeEditor {
|
||||
myContentEntryEditor = contentEntryEditor;
|
||||
myContentEntryEditor.addContentEntryEditorListener(myContentEntryEditorListener);
|
||||
|
||||
final String path = FileUtil.toSystemDependentName(VfsUtil.urlToPath(contentEntryEditor.getContentEntryUrl()));
|
||||
myDescriptor.setRoots(path);
|
||||
final ContentEntry entry = contentEntryEditor.getContentEntry();
|
||||
assert entry != null : contentEntryEditor;
|
||||
final VirtualFile file = entry.getFile();
|
||||
assert file != null : entry;
|
||||
myDescriptor.setRoots(file);
|
||||
|
||||
final Runnable init = new Runnable() {
|
||||
public void run() {
|
||||
//noinspection ConstantConditions
|
||||
myFileSystemTree.updateTree();
|
||||
myFileSystemTree.select(null, path);
|
||||
myFileSystemTree.select(file, null);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+5
-21
@@ -25,14 +25,11 @@ import com.intellij.openapi.fileChooser.ex.FileNodeDescriptor;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -51,8 +48,8 @@ public abstract class ContentEntryEditingAction extends ToggleAction implements
|
||||
super.update(e);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabled(true);
|
||||
final VirtualFile[] files = doGetSelectedFiles();
|
||||
if (files == null || files.length == 0) {
|
||||
final VirtualFile[] files = getSelectedFiles();
|
||||
if (files.length == 0) {
|
||||
presentation.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
@@ -64,25 +61,18 @@ public abstract class ContentEntryEditingAction extends ToggleAction implements
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #getSelectedPaths()} (to remove in IDEA 12) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
@Nullable
|
||||
@NotNull
|
||||
protected final VirtualFile[] getSelectedFiles() {
|
||||
return doGetSelectedFiles();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private VirtualFile[] doGetSelectedFiles() {
|
||||
final TreePath[] selectionPaths = myTree.getSelectionPaths();
|
||||
if (selectionPaths == null) {
|
||||
return null;
|
||||
return VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
final List<VirtualFile> selected = new ArrayList<VirtualFile>();
|
||||
for (TreePath treePath : selectionPaths) {
|
||||
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)treePath.getLastPathComponent();
|
||||
final Object nodeDescriptor = node.getUserObject();
|
||||
if (!(nodeDescriptor instanceof FileNodeDescriptor)) {
|
||||
return null;
|
||||
return VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
final FileElement fileElement = ((FileNodeDescriptor)nodeDescriptor).getElement();
|
||||
final VirtualFile file = fileElement.getFile();
|
||||
@@ -94,12 +84,6 @@ public abstract class ContentEntryEditingAction extends ToggleAction implements
|
||||
return selected.toArray(new VirtualFile[selected.size()]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected List<String> getSelectedPaths() {
|
||||
final VirtualFile[] files = doGetSelectedFiles();
|
||||
return files != null ? Arrays.asList(FileChooserUtil.filesToPaths(files)) : Collections.<String>emptyList();
|
||||
}
|
||||
|
||||
public JComponent createCustomComponent(Presentation presentation) {
|
||||
return new ActionButtonWithText(this, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
|
||||
}
|
||||
|
||||
+9
-9
@@ -23,9 +23,9 @@ import com.intellij.openapi.roots.ExcludeFolder;
|
||||
import com.intellij.openapi.roots.ui.configuration.ContentEntryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.ContentEntryTreeEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.IconSet;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -45,23 +45,23 @@ public class ToggleExcludedStateAction extends ContentEntryEditingAction {
|
||||
|
||||
@Override
|
||||
public boolean isSelected(final AnActionEvent e) {
|
||||
final List<String> selectedPaths = getSelectedPaths();
|
||||
if (selectedPaths.size() == 0) return false;
|
||||
final VirtualFile[] selectedFiles = getSelectedFiles();
|
||||
if (selectedFiles.length == 0) return false;
|
||||
|
||||
final ContentEntryEditor editor = myEntryTreeEditor.getContentEntryEditor();
|
||||
return editor.isExcluded(selectedPaths.get(0)) || editor.isUnderExcludedDirectory(selectedPaths.get(0));
|
||||
return editor.isExcluded(selectedFiles[0]) || editor.isUnderExcludedDirectory(selectedFiles[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(final AnActionEvent e, final boolean isSelected) {
|
||||
final List<String> selectedPaths = getSelectedPaths();
|
||||
assert selectedPaths.size() != 0;
|
||||
final VirtualFile[] selectedFiles = getSelectedFiles();
|
||||
assert selectedFiles.length != 0;
|
||||
|
||||
for (String selectedPath : selectedPaths) {
|
||||
final ExcludeFolder excludeFolder = myEntryTreeEditor.getContentEntryEditor().getExcludeFolder(selectedPath);
|
||||
for (VirtualFile selectedFile : selectedFiles) {
|
||||
final ExcludeFolder excludeFolder = myEntryTreeEditor.getContentEntryEditor().getExcludeFolder(selectedFile);
|
||||
if (isSelected) {
|
||||
if (excludeFolder == null) { // not excluded yet
|
||||
myEntryTreeEditor.getContentEntryEditor().addExcludeFolder(selectedPath);
|
||||
myEntryTreeEditor.getContentEntryEditor().addExcludeFolder(selectedFile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+10
-10
@@ -23,9 +23,9 @@ import com.intellij.openapi.roots.SourceFolder;
|
||||
import com.intellij.openapi.roots.ui.configuration.ContentEntryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.ContentEntryTreeEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.IconSet;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -54,29 +54,29 @@ public class ToggleSourcesStateAction extends ContentEntryEditingAction {
|
||||
|
||||
@Override
|
||||
public boolean isSelected(final AnActionEvent e) {
|
||||
final List<String> selectedPaths = getSelectedPaths();
|
||||
if (selectedPaths.size() == 0) return false;
|
||||
final VirtualFile[] selectedFiles = getSelectedFiles();
|
||||
if (selectedFiles.length == 0) return false;
|
||||
|
||||
final ContentEntryEditor editor = myEntryTreeEditor.getContentEntryEditor();
|
||||
return myEditTestSources ? editor.isTestSource(selectedPaths.get(0)) : editor.isSource(selectedPaths.get(0));
|
||||
return myEditTestSources ? editor.isTestSource(selectedFiles[0]) : editor.isSource(selectedFiles[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(final AnActionEvent e, final boolean isSelected) {
|
||||
final List<String> selectedPaths = getSelectedPaths();
|
||||
assert selectedPaths.size() != 0;
|
||||
final VirtualFile[] selectedFiles = getSelectedFiles();
|
||||
assert selectedFiles.length != 0;
|
||||
|
||||
final ContentEntryEditor contentEntryEditor = myEntryTreeEditor.getContentEntryEditor();
|
||||
for (String selectedPath : selectedPaths) {
|
||||
final SourceFolder sourceFolder = contentEntryEditor.getSourceFolder(selectedPath);
|
||||
for (VirtualFile selectedFile : selectedFiles) {
|
||||
final SourceFolder sourceFolder = contentEntryEditor.getSourceFolder(selectedFile);
|
||||
if (isSelected) {
|
||||
if (sourceFolder == null) { // not marked yet
|
||||
contentEntryEditor.addSourceFolder(selectedPath, myEditTestSources);
|
||||
contentEntryEditor.addSourceFolder(selectedFile, myEditTestSources);
|
||||
}
|
||||
else {
|
||||
if (myEditTestSources != sourceFolder.isTestSource()) {
|
||||
contentEntryEditor.removeSourceFolder(sourceFolder);
|
||||
contentEntryEditor.addSourceFolder(selectedPath, myEditTestSources);
|
||||
contentEntryEditor.addSourceFolder(selectedFile, myEditTestSources);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-14
@@ -46,7 +46,7 @@ public class FileChooserDescriptor implements Cloneable {
|
||||
private String myDescription;
|
||||
|
||||
private boolean myHideIgnored = true;
|
||||
private final List<String> myRoots = new ArrayList<String>();
|
||||
private final List<VirtualFile> myRoots = new ArrayList<VirtualFile>();
|
||||
private boolean myShowFileSystemRoots = true;
|
||||
private boolean myIsTreeRootVisible = false;
|
||||
|
||||
@@ -240,34 +240,30 @@ public class FileChooserDescriptor implements Cloneable {
|
||||
myHideIgnored = hideIgnored;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final List<String> getRootPaths() {
|
||||
public final List<VirtualFile> getRoots() {
|
||||
return Collections.unmodifiableList(myRoots);
|
||||
}
|
||||
|
||||
public final void setRoots(final String... roots) {
|
||||
public final void setRoots(final VirtualFile... roots) {
|
||||
setRoots(Arrays.asList(roots));
|
||||
}
|
||||
|
||||
public final void setRoots(@NotNull final Collection<String> roots) {
|
||||
public final void setRoots(@NotNull final List<VirtualFile> roots) {
|
||||
myRoots.clear();
|
||||
myRoots.addAll(roots);
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #getRootPaths()} (to remove in IDEA 13) */
|
||||
public final List<VirtualFile> getRoots() {
|
||||
return FileChooserUtil.pathsToFiles(myRoots, false);
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #setRoots(java.util.Collection)} (to remove in IDEA 13) */
|
||||
/** @deprecated use {@linkplain #setRoots(com.intellij.openapi.vfs.VirtualFile...)} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public final void setRoot(VirtualFile root) {
|
||||
myRoots.clear();
|
||||
myRoots.add(root.getPresentableUrl());
|
||||
myRoots.add(root);
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #setRoots(java.util.Collection)} (to remove in IDEA 13) */
|
||||
/** @deprecated use {@linkplain #setRoots(com.intellij.openapi.vfs.VirtualFile...)} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public final void addRoot(VirtualFile root) {
|
||||
myRoots.add(root.getPresentableUrl());
|
||||
myRoots.add(root);
|
||||
}
|
||||
|
||||
public boolean isTreeRootVisible() {
|
||||
|
||||
@@ -40,16 +40,13 @@ public interface FileSystemTree extends Disposable {
|
||||
@Nullable
|
||||
VirtualFile getNewFileParent();
|
||||
|
||||
void select(@Nullable Runnable onDone, String... paths);
|
||||
void select(VirtualFile file, @Nullable Runnable onDone);
|
||||
void select(VirtualFile[] files, @Nullable Runnable onDone);
|
||||
|
||||
void expand(@NotNull String path, @Nullable final Runnable onDone);
|
||||
void expand(VirtualFile file, @Nullable Runnable onDone);
|
||||
|
||||
void addListener(Listener listener, Disposable parent);
|
||||
|
||||
boolean isUnderRoots(@NotNull String path);
|
||||
boolean isUnderRoots(@NotNull VirtualFile file);
|
||||
|
||||
boolean selectionExists();
|
||||
|
||||
@@ -680,4 +680,9 @@ public class VfsUtil extends VfsUtilCore {
|
||||
//noinspection SSBasedInspection
|
||||
return files.toArray(new VirtualFile[size]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getReadableUrl(@NotNull final VirtualFile file) {
|
||||
return file.isInLocalFileSystem() ? file.getPresentableUrl() : file.getUrl();
|
||||
}
|
||||
}
|
||||
|
||||
+17
-8
@@ -18,21 +18,24 @@ package com.intellij.openapi.fileChooser.actions;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.fileChooser.FileSystemTree;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
public final class GotoHomeAction extends FileChooserAction {
|
||||
protected void actionPerformed(final FileSystemTree fileSystemTree, final AnActionEvent e) {
|
||||
final String userHome = SystemProperties.getUserHome();
|
||||
if (!StringUtil.isEmptyOrSpaces(userHome)) {
|
||||
fileSystemTree.select(new Runnable() {
|
||||
final VirtualFile userHomeDir = getUserHomeDir();
|
||||
if (userHomeDir != null) {
|
||||
fileSystemTree.select(userHomeDir, new Runnable() {
|
||||
public void run() {
|
||||
fileSystemTree.expand(userHome, null);
|
||||
fileSystemTree.expand(userHomeDir, null);
|
||||
}
|
||||
}, userHome);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +43,13 @@ public final class GotoHomeAction extends FileChooserAction {
|
||||
final Presentation presentation = e.getPresentation();
|
||||
if (!presentation.isEnabled()) return;
|
||||
|
||||
final String userHome = SystemProperties.getUserHome();
|
||||
presentation.setEnabled(!StringUtil.isEmptyOrSpaces(userHome) && fileSystemTree.isUnderRoots(userHome));
|
||||
final VirtualFile userHomeDir = getUserHomeDir();
|
||||
presentation.setEnabled(userHomeDir != null && fileSystemTree.isUnderRoots(userHomeDir));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile getUserHomeDir() {
|
||||
final String path = SystemProperties.getUserHome();
|
||||
return LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(path));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ public final class GotoProjectDirectory extends FileChooserAction {
|
||||
private static final Icon ourIcon = IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl());
|
||||
|
||||
protected void actionPerformed(final FileSystemTree fileSystemTree, final AnActionEvent e) {
|
||||
final VirtualFile projectPath = getProjectPath(e);
|
||||
final VirtualFile projectPath = getProjectDir(e);
|
||||
if (projectPath != null) {
|
||||
fileSystemTree.select(projectPath, new Runnable() {
|
||||
public void run() {
|
||||
@@ -43,12 +43,12 @@ public final class GotoProjectDirectory extends FileChooserAction {
|
||||
protected void update(final FileSystemTree fileSystemTree, final AnActionEvent e) {
|
||||
final Presentation presentation = e.getPresentation();
|
||||
presentation.setIcon(ourIcon);
|
||||
final VirtualFile projectPath = getProjectPath(e);
|
||||
final VirtualFile projectPath = getProjectDir(e);
|
||||
presentation.setEnabled(projectPath != null && fileSystemTree.isUnderRoots(projectPath));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile getProjectPath(final AnActionEvent e) {
|
||||
private static VirtualFile getProjectDir(final AnActionEvent e) {
|
||||
final VirtualFile projectFileDir = e.getData(PlatformDataKeys.PROJECT_FILE_DIRECTORY);
|
||||
return projectFileDir != null && projectFileDir.isValid() ? projectFileDir : null;
|
||||
}
|
||||
|
||||
+3
-3
@@ -495,9 +495,9 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
|
||||
text = getFilePath(selection.get(0));
|
||||
}
|
||||
else {
|
||||
final List<String> rootPaths = myChooserDescriptor.getRootPaths();
|
||||
if (!myFileSystemTree.getTree().isRootVisible() && rootPaths.size() == 1) {
|
||||
text = rootPaths.get(0);
|
||||
final List<VirtualFile> roots = myChooserDescriptor.getRoots();
|
||||
if (!myFileSystemTree.getTree().isRootVisible() && roots.size() == 1) {
|
||||
text = VfsUtil.getReadableUrl(roots.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-38
@@ -36,10 +36,10 @@ import com.intellij.openapi.fileChooser.impl.FileTreeStructure;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
@@ -50,7 +50,6 @@ import com.intellij.ui.UIBundle;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -63,7 +62,6 @@ import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -245,20 +243,6 @@ public class FileSystemTreeImpl implements FileSystemTree {
|
||||
select(new VirtualFile[]{file}, onDone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(@Nullable final Runnable onDone, final String... paths) {
|
||||
final List<Object> elements = ContainerUtil.mapNotNull(paths, new NullableFunction<String, Object>() {
|
||||
@Override
|
||||
public Object fun(final String path) {
|
||||
final VirtualFile file = FileChooserUtil.pathToFile(path, false);
|
||||
return file != null ? getFileElementFor(file) : null;
|
||||
}
|
||||
});
|
||||
if (elements.size() > 0) {
|
||||
myTreeBuilder.select(elements.toArray(), onDone);
|
||||
}
|
||||
}
|
||||
|
||||
public void select(VirtualFile[] file, @Nullable final Runnable onDone) {
|
||||
Object[] elements = new Object[file.length];
|
||||
for (int i = 0; i < file.length; i++) {
|
||||
@@ -269,14 +253,6 @@ public class FileSystemTreeImpl implements FileSystemTree {
|
||||
myTreeBuilder.select(elements, onDone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(@NotNull final String path, @Nullable final Runnable onDone) {
|
||||
final VirtualFile file = FileChooserUtil.pathToFile(path, false);
|
||||
if (file != null) {
|
||||
myTreeBuilder.expand(getFileElementFor(file), onDone);
|
||||
}
|
||||
}
|
||||
|
||||
public void expand(final VirtualFile file, @Nullable final Runnable onDone) {
|
||||
myTreeBuilder.expand(getFileElementFor(file), onDone);
|
||||
}
|
||||
@@ -373,8 +349,8 @@ public class FileSystemTreeImpl implements FileSystemTree {
|
||||
final VirtualFile selected = getSelectedFile();
|
||||
if (selected != null) return selected;
|
||||
|
||||
final List<String> rootPaths = myDescriptor.getRootPaths();
|
||||
return rootPaths.size() == 1 ? FileChooserUtil.pathToFile(rootPaths.get(0), false) : null;
|
||||
final List<VirtualFile> roots = myDescriptor.getRoots();
|
||||
return roots.size() == 1 ? roots.get(0) : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -432,13 +408,12 @@ public class FileSystemTreeImpl implements FileSystemTree {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderRoots(@NotNull final String path) {
|
||||
final List<String> rootPaths = myDescriptor.getRootPaths();
|
||||
if (rootPaths.size() == 0) return true;
|
||||
public boolean isUnderRoots(@NotNull VirtualFile file) {
|
||||
final List<VirtualFile> roots = myDescriptor.getRoots();
|
||||
if (roots.size() == 0) return true;
|
||||
|
||||
final File candidate = new File(FileUtil.toSystemDependentName(path));
|
||||
for (String rootPath : rootPaths) {
|
||||
if (FileUtil.isAncestor(new File(FileUtil.toSystemDependentName(rootPath)), candidate, false)) {
|
||||
for (VirtualFile root : roots) {
|
||||
if (root != null && VfsUtilCore.isAncestor(root, file, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -446,11 +421,6 @@ public class FileSystemTreeImpl implements FileSystemTree {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderRoots(@NotNull VirtualFile file) {
|
||||
return isUnderRoots(file.getPath());
|
||||
}
|
||||
|
||||
public void addListener(final Listener listener, final Disposable parent) {
|
||||
myListeners.add(listener);
|
||||
Disposer.register(parent, new Disposable() {
|
||||
|
||||
+2
-5
@@ -21,7 +21,6 @@ import com.intellij.ide.util.treeView.AbstractTreeStructure;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserUtil;
|
||||
import com.intellij.openapi.fileChooser.FileElement;
|
||||
import com.intellij.openapi.fileChooser.ex.FileNodeDescriptor;
|
||||
import com.intellij.openapi.fileChooser.ex.RootFileElement;
|
||||
@@ -36,7 +35,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Yura Cangea
|
||||
@@ -51,9 +49,8 @@ public class FileTreeStructure extends AbstractTreeStructure {
|
||||
|
||||
public FileTreeStructure(Project project, FileChooserDescriptor chooserDescriptor) {
|
||||
myProject = project;
|
||||
final List<String> rootPaths = chooserDescriptor.getRootPaths();
|
||||
final String name = rootPaths.size() == 1 ? rootPaths.get(0) : chooserDescriptor.getTitle();
|
||||
final VirtualFile[] rootFiles = VfsUtil.toVirtualFileArray(FileChooserUtil.pathsToFiles(rootPaths, false));
|
||||
final VirtualFile[] rootFiles = VfsUtil.toVirtualFileArray(chooserDescriptor.getRoots());
|
||||
final String name = rootFiles.length == 1 && rootFiles[0] != null ? rootFiles[0].getPresentableUrl() : chooserDescriptor.getTitle();
|
||||
myRootElement = new RootFileElement(rootFiles, name, chooserDescriptor.isShowFileSystemRoots());
|
||||
myChooserDescriptor = chooserDescriptor;
|
||||
myShowHidden = PropertiesComponent.getInstance().getBoolean("FileChooser.showHiddens", false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -57,7 +57,7 @@ public class FilesystemToolwindow {
|
||||
myContent = new MyContent();
|
||||
|
||||
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, false, true, true);
|
||||
descriptor.addRoot(myRoot);
|
||||
descriptor.setRoots(myRoot);
|
||||
|
||||
myFsTree = new FileSystemTreeImpl(project, descriptor);
|
||||
myContent.add(ScrollPaneFactory.createScrollPane(myFsTree.getTree()), BorderLayout.CENTER);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -70,10 +70,7 @@ public class MigrateRootDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
};
|
||||
final VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRootsFromAllModules();
|
||||
for (VirtualFile vFile : roots) {
|
||||
descriptor.addRoot(vFile);
|
||||
}
|
||||
descriptor.setRoots(ProjectRootManager.getInstance(project).getContentRootsFromAllModules());
|
||||
myDirectoryField.addBrowseFolderListener("Select directory to migrate to a new CVS root", "", project, descriptor);
|
||||
FileChooserFactory.getInstance().installFileCompletion(myDirectoryField.getChildComponent(), descriptor, true, getDisposable());
|
||||
myDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
+4
-3
@@ -31,6 +31,7 @@ import com.intellij.openapi.fileChooser.ex.LocalFsFinder;
|
||||
import com.intellij.openapi.fileChooser.impl.FileChooserFactoryImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
@@ -260,9 +261,9 @@ public abstract class SelectLocationStep extends WizardStep {
|
||||
}
|
||||
}
|
||||
else {
|
||||
final List<String> rootPaths = myChooserDescriptor.getRootPaths();
|
||||
if (!myFileSystemTree.getTree().isRootVisible() && rootPaths.size() == 1) {
|
||||
text = rootPaths.get(0);
|
||||
final List<VirtualFile> roots = myChooserDescriptor.getRoots();
|
||||
if (!myFileSystemTree.getTree().isRootVisible() && roots.size() == 1) {
|
||||
text = VfsUtil.getReadableUrl(roots.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -33,7 +33,6 @@ import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.changes.ui.VirtualFileListCellRenderer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.*;
|
||||
@@ -163,9 +162,7 @@ public class VcsStructureChooser extends DialogWrapper {
|
||||
return path1.compareToIgnoreCase(path2);
|
||||
}
|
||||
};
|
||||
for (VirtualFile root : list) {
|
||||
descriptor.addRoot(root);
|
||||
}
|
||||
descriptor.setRoots(list);
|
||||
myTree = new Tree();
|
||||
myTree.setMinimumSize(new Dimension(200, 200));
|
||||
myTree.setBorder(BORDER);
|
||||
|
||||
+12
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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,11 +30,15 @@ import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyIcons;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -63,11 +67,13 @@ public class GroovyCompilerConfigurable implements SearchableConfigurable, Confi
|
||||
return super.isFileVisible(file, showHiddenFiles) && !index.isIgnored(file);
|
||||
}
|
||||
};
|
||||
for (final Module module: ModuleManager.getInstance(project).getModules()) {
|
||||
for (VirtualFile file : ModuleRootManager.getInstance(module).getSourceRoots()) {
|
||||
descriptor.addRoot(file);
|
||||
}
|
||||
}
|
||||
descriptor.setRoots(ContainerUtil.concat(
|
||||
ContainerUtil.map(ModuleManager.getInstance(project).getModules(), new Function<Module, List<VirtualFile>>() {
|
||||
@Override
|
||||
public List<VirtualFile> fun(final Module module) {
|
||||
return Arrays.asList(ModuleRootManager.getInstance(module).getSourceRoots());
|
||||
}
|
||||
})));
|
||||
return new ExcludedEntriesConfigurable(project, descriptor, configuration);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user