package org.nuxeo.intellij.ui;

import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;

/**
 * Utility class to show a
 * {@link com.intellij.openapi.fileChooser.FileChooserDialog} to select only
 * Nuxeo SDKs.
 */
public final class NuxeoSDKChooser {

    public static final String NXSERVER_FOLDER_NAME = "nxserver";

    public static final String SDK_FOLDER_NAME = "sdk";

    public static final String COMPONENTS_INDEX_NAME = "components.index";

    private static final NuxeoSDKChooserDescriptor descriptor = new NuxeoSDKChooserDescriptor();

    private NuxeoSDKChooser() {
        // utility class
    }

    public static VirtualFile chooseNuxeoSDK(Project project) {
        return FileChooser.chooseFile(descriptor, project, null);
    }

    public static class NuxeoSDKChooserDescriptor extends FileChooserDescriptor {

        public NuxeoSDKChooserDescriptor() {
            super(false, true, false, false, false, false);
            setTitle("Choose a Nuxeo SDK Folder");
        }

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            return file.isDirectory() && file.isValid()
                    && file.findChild(NXSERVER_FOLDER_NAME) != null
                    && file.findChild(SDK_FOLDER_NAME) != null
                    && file.findChild(COMPONENTS_INDEX_NAME) != null;
        }
    }
}

@@ -1240,74 +1240,110 @@
     
-return file.isDirectory() && file.isValid()%0A                    &&
+VirtualFile nxserverFolder = file.findChild(NXSERVER_FOLDER_NAME);%0A            VirtualFile sdkFolder =
  fil
@@ -1350,32 +1350,27 @@
 e.findChild(
-NXSERVER
+SDK
 _FOLDER_NAME
@@ -1374,71 +1374,124 @@
 AME)
- != null%0A                    && file.findChild(SDK_FOLDER_NAME)
+;%0A            return file.isDirectory() && file.isValid()%0A                    && nxserverFolder != null && sdkFolder
  != 
@@ -1518,20 +1518,25 @@
      && 
-file
+sdkFolder
 .findChi

Fix detection of Nuxeo SDK folder