use of com.intellij.openapi.projectRoots.ProjectJdkTable in project moe-ide-integration by multi-os-engine.
the class MOESdkType method getMOESdk.
public static Sdk getMOESdk(Module module) {
if (module == null) {
return null;
}
String modulePath = ModuleUtils.getModulePath(module);
if (modulePath == null) {
return null;
}
final Properties properties = ProjectUtil.retrievePropertiesFromGradle(new File(modulePath), ProjectUtil.SDK_PROPERTIES_TASK);
String moeRootPath = properties.getProperty(ProjectUtil.SDK_PATH_KEY);
if (moeRootPath == null) {
return null;
}
String name = new File(moeRootPath).getName();
ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
for (Sdk sdk : jdkTable.getAllJdks()) {
if (sdk != null && sdk.getHomePath() != null && sdk.getHomePath().equals(moeRootPath)) {
return sdk;
}
}
Sdk jdk = getJDK();
if (jdk == null) {
jdk = findValidJdk();
}
if (jdk == null) {
Messages.showMessageDialog(MOEText.get("JDK.Not.Found"), "Error", MOEIcons.MOELogo);
return null;
}
MOESdkType sdkType = new MOESdkType(name, moeRootPath);
final Sdk sdk = ProjectJdkTable.getInstance().createSdk(sdkType.suggestSdkName(null, null), sdkType);
sdkType.setupSdkRoots(sdk, jdk);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ProjectJdkTable.getInstance().addJdk(sdk);
}
});
return sdk;
}
Aggregations