mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Factored out createAndAddSDK()
This commit is contained in:
+25
-12
@@ -215,23 +215,36 @@ public class SdkConfigurationUtil {
|
||||
for (SdkType sdkType : sdkTypes) {
|
||||
final String suggestedHomePath = sdkType.suggestHomePath();
|
||||
if (suggestedHomePath != null && sdkType.isValidSdkHome(suggestedHomePath)) {
|
||||
VirtualFile sdkHome = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
|
||||
public VirtualFile compute() {
|
||||
return LocalFileSystem.getInstance().refreshAndFindFileByPath(suggestedHomePath);
|
||||
}
|
||||
});
|
||||
if (sdkHome != null) {
|
||||
final Sdk newSdk = setupSdk(ProjectJdkTable.getInstance().getAllJdks(), sdkHome, sdkType, true, null, null);
|
||||
if (newSdk != null) {
|
||||
addSdk(newSdk);
|
||||
}
|
||||
return newSdk;
|
||||
}
|
||||
Sdk an_sdk = createAndAddSDK(suggestedHomePath, sdkType);
|
||||
if (an_sdk != null) return an_sdk;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to create an SDK identified by path; if successful, add the SDK to the global SDK table.
|
||||
* @param path identifies the SDK
|
||||
* @param sdkType
|
||||
* @return newly created SDK, or null.
|
||||
*/
|
||||
@Nullable
|
||||
public static Sdk createAndAddSDK(final String path, SdkType sdkType) {
|
||||
VirtualFile sdkHome = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
|
||||
public VirtualFile compute() {
|
||||
return LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
|
||||
}
|
||||
});
|
||||
if (sdkHome != null) {
|
||||
final Sdk newSdk = setupSdk(ProjectJdkTable.getInstance().getAllJdks(), sdkHome, sdkType, true, null, null);
|
||||
if (newSdk != null) {
|
||||
addSdk(newSdk);
|
||||
}
|
||||
return newSdk;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String createUniqueSdkName(SdkType type, String home, final Collection<Sdk> sdks) {
|
||||
return createUniqueSdkName(type.suggestSdkName(null, home), sdks);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user