FileChooserDescriptor (SdkType @NotNull ... sdkTypes) { return new FileChooserDescriptor(sdkTypes[0].getHomeChooserDescriptor()) { @Override public void validateSelectedFiles(final VirtualFile @NotNull [] files) throws Exception { if (files.length > 0) { for (SdkType type : sdkTypes) { if (type.isValidSdkHome(files[0].getPath())) { return; } } } String key = files.length > 0 && files[0].isDirectory() ? "sdk.configure.home.invalid.error" : "sdk.configure.home.file.invalid.error"; throw new Exception(ProjectBundle.message(key, sdkTypes[0].getPresentableName())); } }; }