public static void createSdk(
      @Nullable final Project project,
      final Sdk[] existingSdks,
      final NullableConsumer<Sdk> onSdkCreatedCallBack,
      final boolean createIfExists,
      final SdkType... sdkTypes) {
    if (sdkTypes.length == 0) {
      onSdkCreatedCallBack.consume(null);
      return;
    }

    FileChooserDescriptor descriptor = createCompositeDescriptor(sdkTypes);
    VirtualFile suggestedDir = getSuggestedSdkRoot(sdkTypes[0]);
    FileChooser.chooseFiles(
        descriptor,
        project,
        suggestedDir,
        new FileChooser.FileChooserConsumer() {
          @Override
          public void consume(List<VirtualFile> selectedFiles) {
            for (SdkType sdkType : sdkTypes) {
              final String path = selectedFiles.get(0).getPath();
              if (sdkType.isValidSdkHome(path)) {
                Sdk newSdk = null;
                if (!createIfExists) {
                  for (Sdk sdk : existingSdks) {
                    if (path.equals(sdk.getHomePath())) {
                      newSdk = sdk;
                      break;
                    }
                  }
                }
                if (newSdk == null) {
                  newSdk = setupSdk(existingSdks, selectedFiles.get(0), sdkType, false, null, null);
                }
                onSdkCreatedCallBack.consume(newSdk);
                return;
              }
            }
            onSdkCreatedCallBack.consume(null);
          }

          @Override
          public void cancelled() {
            onSdkCreatedCallBack.consume(null);
          }
        });
  }
 public void apply() throws ConfigurationException {
   if (!myModifiedModificators.isEmpty()) {
     mySdkSettingsWereModified.run();
   }
   for (SdkModificator modificator : myModifiedModificators) {
     /* This should always be true barring bug elsewhere, log error on else? */
     if (modificator.isWritable()) {
       modificator.commitChanges();
     }
   }
   myModificators.clear();
   myModifiedModificators.clear();
   mySdkListChanged = false;
   final Sdk sdk = getSelectedSdk();
   myShowMoreCallback.consume(sdk);
   PyPackageManagers.getInstance().clearCache(sdk);
   Disposer.dispose(getDisposable());
 }