本文整理汇总了Java中com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel.addSdk方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectSdksModel.addSdk方法的具体用法?Java ProjectSdksModel.addSdk怎么用?Java ProjectSdksModel.addSdk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel
的用法示例。
在下文中一共展示了ProjectSdksModel.addSdk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDetectedSdk
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入方法依赖的package包/类
private static Sdk addDetectedSdk(@NotNull Sdk sdk, @NotNull Project project) {
final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
final String name = sdk.getName();
VirtualFile sdkHome = WriteAction.compute(() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(name));
sdk = SdkConfigurationUtil.createAndAddSDK(sdkHome.getPath(), PythonSdkType.getInstance());
if (sdk != null) {
PythonSdkUpdater.updateOrShowError(sdk, null, project, null);
}
model.addSdk(sdk);
try {
model.apply();
}
catch (ConfigurationException exception) {
LOG.error("Error adding detected python interpreter " + exception.getMessage());
}
return sdk;
}
示例2: testSatisfied
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入方法依赖的package包/类
public void testSatisfied() throws Exception {
ProjectSdksModel model = new ProjectSdksModel();
model.addSdk(IdeaTestUtil.getMockJdk17());
ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
Sdk sdk = jdkTable.createSdk("a", AndroidSdkType.getInstance());
mySdks.add(sdk);
jdkTable.addJdk(sdk);
AnAction action = getAddAction(model);
try {
action.actionPerformed(new TestActionEvent(action));
fail("Exception should be thrown");
}
catch (Exception e) {
assertEquals(AndroidBundle.message("cannot.parse.sdk.error"), e.getMessage());
}
}
示例3: consume
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入方法依赖的package包/类
@Override
public void consume(@Nullable ProjectSettingsStepBase step) {
if (!(step instanceof ProjectSpecificSettingsStep)) return;
final ProjectSpecificSettingsStep settingsStep = (ProjectSpecificSettingsStep)step;
Sdk sdk = settingsStep.getSdk();
final Project project = ProjectManager.getInstance().getDefaultProject();
final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
if (sdk instanceof PyDetectedSdk) {
final String name = sdk.getName();
VirtualFile sdkHome = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
@Override
public VirtualFile compute() {
return LocalFileSystem.getInstance().refreshAndFindFileByPath(name);
}
});
PySdkService.getInstance().solidifySdk(sdk);
sdk = SdkConfigurationUtil.createAndAddSDK(sdkHome.getPath(), PythonSdkType.getInstance());
if (sdk != null) {
PythonSdkType.getInstance().setupSdkPathsImmediately(sdk, project);
}
model.addSdk(sdk);
settingsStep.setSdk(sdk);
try {
model.apply();
}
catch (ConfigurationException exception) {
LOG.error("Error adding detected python interpreter " + exception.getMessage());
}
}
Project newProject = generateProject(project, settingsStep);
if (newProject != null) {
SdkConfigurationUtil.setDirectoryProjectSdk(newProject, sdk);
final List<Sdk> sdks = PythonSdkType.getAllSdks();
for (Sdk s : sdks) {
final SdkAdditionalData additionalData = s.getSdkAdditionalData();
if (additionalData instanceof PythonSdkAdditionalData) {
((PythonSdkAdditionalData)additionalData).reassociateWithCreatedProject(newProject);
}
}
}
}