当前位置: 首页>>代码示例>>Java>>正文


Java ProjectSdksModel.addSdk方法代码示例

本文整理汇总了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;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:19,代码来源:PyStudyDirectoryProjectGenerator.java

示例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());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidSdkTypeNewProjectWizardTest.java

示例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);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:GenerateProjectCallback.java


注:本文中的com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel.addSdk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。