content entry editor: respect DirectoryIndexExcludePolicy#getExcludeRootsForProject...
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Mon, 8 Aug 2016 17:12:17 +0000 (20:12 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Mon, 8 Aug 2016 17:12:40 +0000 (20:12 +0300)
platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryEditor.java
platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryTreeCellRenderer.java
platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryTreeEditor.java
platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexExcludePolicy.java

index 91c8405896058cae488cfff3e9b65c454dcb40d0..a905dd56e54215b6b81a51c6035b4cebc522ec69 100644 (file)
 
 package com.intellij.openapi.roots.ui.configuration;
 
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.roots.*;
+import com.intellij.openapi.roots.impl.DirectoryIndexExcludePolicy;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.VfsUtilCore;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.EventDispatcher;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.jps.model.JpsElement;
@@ -285,12 +288,23 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
   }
 
   public boolean isExcludedOrUnderExcludedDirectory(@NotNull final VirtualFile file) {
+    Project project = getModel().getProject();
     final ContentEntry contentEntry = getContentEntry();
     if (contentEntry == null) {
       return false;
     }
-    for (VirtualFile excludedDir : contentEntry.getExcludeFolderFiles()) {
-      if (VfsUtilCore.isAncestor(excludedDir, file, false)) {
+    return isExcludedOrUnderExcludedDirectory(project, contentEntry, file);
+  }
+
+  public static boolean isExcludedOrUnderExcludedDirectory(@NotNull Project project,
+                                                           @NotNull ContentEntry entry,
+                                                           @NotNull VirtualFile file) {
+    List<VirtualFile> excludedFiles = ContainerUtil.newArrayList(entry.getExcludeFolderFiles());
+    for (DirectoryIndexExcludePolicy policy : DirectoryIndexExcludePolicy.getExtensions(project)) {
+      ContainerUtil.addAllNotNull(excludedFiles, policy.getExcludeRootsForProject());
+    }
+    for (VirtualFile excludedFile : excludedFiles) {
+      if (VfsUtilCore.isAncestor(excludedFile, file, false)) {
         return true;
       }
     }
index 9231343414ac0e533b7e44a0a5c630c109a45b14..8b423d76f2f567ef1426b91fe59ced883c53c1bd 100644 (file)
@@ -87,10 +87,8 @@ public class ContentEntryTreeCellRenderer extends NodeRenderer {
   }
 
   protected Icon updateIcon(final ContentEntry entry, final VirtualFile file, Icon originalIcon) {
-    for (VirtualFile excludePath : entry.getExcludeFolderFiles()) {
-      if (VfsUtilCore.isAncestor(excludePath, file, false)) {
-        return AllIcons.Modules.ExcludeRoot;
-      }
+    if (ContentEntryEditor.isExcludedOrUnderExcludedDirectory(myTreeEditor.getProject(), entry, file)) {
+      return AllIcons.Modules.ExcludeRoot;
     }
 
     final SourceFolder[] sourceFolders = entry.getSourceFolders();
index 3326a7c5c5929da7b9cb312825f0f380b9459da2..8795c2a6a291483db5f9df1f406ccbf1f7845e92 100644 (file)
@@ -21,7 +21,10 @@ import com.intellij.ide.util.treeView.AbstractTreeBuilder;
 import com.intellij.ide.util.treeView.AbstractTreeStructure;
 import com.intellij.ide.util.treeView.NodeDescriptor;
 import com.intellij.idea.ActionsBundle;
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.CustomShortcutSet;
+import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.actionSystem.Presentation;
 import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
@@ -180,6 +183,11 @@ public class ContentEntryTreeEditor {
     return myContentEntryEditor;
   }
 
+  @NotNull
+  public Project getProject() {
+    return myProject;
+  }
+
   public JComponent createComponent() {
     createEditingActions();
     return myTreePanel;
index 61838f51ac1d340029c8ea4517cbc2a6d6c9c9b2..a9eee660c7e27f193e27c38bb8c71a8d14e9691d 100644 (file)
@@ -16,7 +16,9 @@
 
 package com.intellij.openapi.roots.impl;
 
+import com.intellij.openapi.extensions.AreaInstance;
 import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.roots.ModuleRootModel;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
@@ -33,4 +35,9 @@ public interface DirectoryIndexExcludePolicy {
 
   @NotNull
   VirtualFilePointer[] getExcludeRootsForModule(@NotNull ModuleRootModel rootModel);
+
+  @NotNull
+  static DirectoryIndexExcludePolicy[] getExtensions(@NotNull AreaInstance areaInstance) {
+    return Extensions.getExtensions(EP_NAME, areaInstance);
+  }
 }