cleaner check to look for projects inside selected directory
authorDmitry Jemerov <yole@jetbrains.com>
Mon, 5 Jul 2010 11:05:38 +0000 (15:05 +0400)
committerDmitry Jemerov <yole@jetbrains.com>
Mon, 5 Jul 2010 11:06:57 +0000 (15:06 +0400)
platform/platform-api/src/com/intellij/projectImport/ProjectOpenProcessor.java
platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java
platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java

index 909f49481ced04523acd43cd263b2f2fb7efa06a..a362abe8967f27a81035056b3caa09394a1bce7e 100644 (file)
@@ -41,6 +41,15 @@ public abstract class ProjectOpenProcessor {
   @Nullable
   public abstract Project doOpenProject(@NotNull VirtualFile virtualFile, Project projectToClose, boolean forceOpenInNewFrame);
 
+  /**
+   * Allow opening a directory directly if the project files are located in that directory.
+   *
+   * @return true if project files are searched inside the selected directory, false if the project files must be selected directly.
+   */
+  public boolean lookForProjectsInDirectory() {
+    return true;
+  }
+
   @Nullable
   public static ProjectOpenProcessor getImportProvider(VirtualFile file) {
     for (ProjectOpenProcessor provider : Extensions.getExtensions(EXTENSION_POINT_NAME)) {
index 30116458dad5340f339d32e36f5b67906112361d..9ed0988a998a8258afde8422dfff88c89b195e63 100644 (file)
@@ -22,7 +22,6 @@ import com.intellij.openapi.fileChooser.FileElement;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.platform.PlatformProjectOpenProcessor;
 import com.intellij.projectImport.ProjectOpenProcessor;
 import org.jetbrains.annotations.Nullable;
 
@@ -76,7 +75,7 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
       return true;
     }
     final ProjectOpenProcessor importProvider = ProjectOpenProcessor.getImportProvider(file);
-    if (importProvider != null && !(importProvider instanceof PlatformProjectOpenProcessor)) {
+    if (importProvider != null && importProvider.lookForProjectsInDirectory()) {
       return true;
     }
     return false;
index f5069208f44fa5612cef7c3c52746ff7e751ea4b..1834a3813a0b0309f8eaedd54d4abdbe40d53e46 100644 (file)
@@ -61,6 +61,11 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor {
     return file.isDirectory() || !file.getFileType().isBinary();
   }
 
+  @Override
+  public boolean lookForProjectsInDirectory() {
+    return false;
+  }
+
   @Nullable
   public Project doOpenProject(@NotNull final VirtualFile virtualFile, final Project projectToClose, final boolean forceOpenInNewFrame) {
     VirtualFile baseDir = virtualFile.isDirectory() ? virtualFile : virtualFile.getParent();