allow marking as excluded directories under source roots (PY-4498)
authorDmitry Jemerov <yole@jetbrains.com>
Fri, 7 Oct 2011 12:23:21 +0000 (14:23 +0200)
committerDmitry Jemerov <yole@jetbrains.com>
Fri, 7 Oct 2011 12:41:31 +0000 (14:41 +0200)
platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkExcludeRootAction.java
platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootAction.java
platform/lang-impl/src/com/intellij/ide/projectView/actions/UnmarkRootAction.java

index 9238074e63ebc4561273a3a104f0abd7d4a47e53..1096a067fc88e36b15ce1a16c7b1c3b90d664eb5 100644 (file)
@@ -43,6 +43,6 @@ public class MarkExcludeRootAction extends MarkRootAction {
 
   protected String getPromptText(String message) {
     return "Are you sure you would like to exclude " + message +
-           " from the project?\nYou can restore excluded folders later using the Project Structure dialog.";
+           " from the project?\nYou can restore excluded directories later using the Project Structure dialog.";
   }
 }
index c03d3921e67039149deb5fc302ada02d23801e62..218937ed2dd47f94cd6062372e5999526813f817 100644 (file)
@@ -101,12 +101,17 @@ public class MarkRootAction extends AnAction {
 
   @Override
   public void update(AnActionEvent e) {
-    boolean enabled = canMark(e, myMarkAsTestSources || myMarkAsExcluded || myUnmark, !myMarkAsTestSources || myMarkAsExcluded || myUnmark, null);
+    boolean enabled = canMark(e, myMarkAsTestSources || myMarkAsExcluded || myUnmark, !myMarkAsTestSources || myMarkAsExcluded || myUnmark,
+                              myMarkAsExcluded, null);
     e.getPresentation().setVisible(enabled);
     e.getPresentation().setEnabled(enabled);
   }
 
-  public static boolean canMark(AnActionEvent e, boolean acceptSourceRoot, boolean acceptTestSourceRoot, Ref<Boolean> rootType) {
+  public static boolean canMark(AnActionEvent e,
+                                boolean acceptSourceRoot,
+                                boolean acceptTestSourceRoot,
+                                boolean acceptInSourceContent,
+                                @Nullable Ref<Boolean> rootType) {
     Module module = e.getData(LangDataKeys.MODULE);
     VirtualFile[] vFiles = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
     if (module == null || vFiles == null) {
@@ -131,7 +136,7 @@ public class MarkRootAction extends AnAction {
           return true;
         }
       }
-      if (fileIndex.isInSourceContent(vFile)) {
+      if (fileIndex.isInSourceContent(vFile) && !acceptInSourceContent) {
         return false;
       }
     }
index 3e1ec83d14597716465d5758e2ee5dd500c14f00..ca122bc84cc1e56cfe66d0b6bbede86932e8cf4c 100644 (file)
@@ -29,7 +29,7 @@ public class UnmarkRootAction extends MarkRootAction {
   @Override
   public void update(AnActionEvent e) {
     Ref<Boolean> rootType = new Ref<Boolean>();
-    boolean enabled = canMark(e, true, true, rootType);
+    boolean enabled = canMark(e, true, true, false, rootType);
     if (rootType.get() == null) {
       enabled = false;
     }