public static void selectSdkHome(@NotNull final SdkType sdkType,
                                   @Nullable Component component,
                                   @NotNull final Consumer<? super String> consumer) {
    if (selectSdkHomeForTests(sdkType, consumer)) return;

    final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor();

    Future<VirtualFile> sdkRootFuture = PooledThreadExecutor.INSTANCE.submit(() -> getSuggestedSdkRoot(sdkType));
    VirtualFile suggestedSdkRoot = null;
    try {
      suggestedSdkRoot = sdkRootFuture.get(200, TimeUnit.MILLISECONDS);
    }
    catch (InterruptedException | ExecutionException | TimeoutException ignored) {
    }

    // passing project instance here seems to be the right idea, but it would make the dialog
    // selecting the last opened project path, instead of the suggested detected JDK home (one of many).
    // The behaviour may also depend on the FileChooser implementations which does not reuse that code
    FileChooser.chooseFiles(descriptor, null, component, suggestedSdkRoot, chosen -> {
      final String path = chosen.get(0).getPath();
      final String adjustedPath = sdkType.adjustSelectedSdkHome(path);
      AtomicBoolean isAdjustedPathValid = new AtomicBoolean(false);
      ProgressManager.getInstance().runProcessWithProgressSynchronously(
        () -> isAdjustedPathValid.set(DiskQueryRelay.compute(() -> sdkType.isValidSdkHome(adjustedPath))),
        ProjectBundle.message("progress.title.checking.sdk.home"), true, null
      );
      consumer.consume(isAdjustedPathValid.get() ? adjustedPath : path);
    });
  }
public static void selectSdkHome(@NotNull final SdkType sdkType,
                                   @Nullable Component component,
                                   @NotNull final Consumer<? super String> consumer)