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


Java ProjectJdkTable类代码示例

本文整理汇总了Java中com.intellij.openapi.projectRoots.ProjectJdkTable的典型用法代码示例。如果您正苦于以下问题:Java ProjectJdkTable类的具体用法?Java ProjectJdkTable怎么用?Java ProjectJdkTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProjectJdkTable类属于com.intellij.openapi.projectRoots包,在下文中一共展示了ProjectJdkTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  myOldDefaultProjectSdk = ProjectRootManager.getInstance(myProjectManager.getDefaultProject()).getProjectSdk();
  Sdk projectSdk = ProjectRootManager.getInstance(getProject()).getProjectSdk();
  for (final Sdk jdk : ProjectJdkTable.getInstance().getAllJdks()) {
    if (projectSdk != jdk) {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          ProjectJdkTable.getInstance().removeJdk(jdk);
        }
      });
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ProjectWizardTestCase.java

示例2: findJdk

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Nullable
private static Sdk findJdk(@NotNull JavaSdkVersion version) {
  JavaSdk javaSdk = JavaSdk.getInstance();
  List<Sdk> javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk);
  Sdk candidate = null;
  for (Sdk sdk : javaSdks) {
    JavaSdkVersion v = javaSdk.getVersion(sdk);
    if (v == version) {
      return sdk;
    }
    else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) {
      candidate = sdk;
    }
  }
  return candidate;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaProjectDataService.java

示例3: testEditLibraryForModuleLoadFromXml

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
public void testEditLibraryForModuleLoadFromXml() throws IOException {
  final File tempDirectory = createTempDirectory();
  ApplicationManager.getApplication().runWriteAction(() -> {
    Module a = loadModule(PathManagerEx.getHomePath(getClass()) + "/java/java-tests/testData/moduleRootManager/rootsChanged/emptyModule/a.iml");
    assertEventsCount(1);

    final Sdk jdk = IdeaTestUtil.getMockJdk17();
    ProjectJdkTable.getInstance().addJdk(jdk);
    assertEventsCount(0);

    ModuleRootModificationUtil.setModuleSdk(a, jdk);
    assertEventsCount(1);

    final SdkModificator sdkModificator = jdk.getSdkModificator();
    sdkModificator.addRoot(getVirtualFile(tempDirectory), OrderRootType.CLASSES);
    sdkModificator.commitChanges();
  });

  assertEventsCount(1);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:RootsChangedTest.java

示例4: fillList

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
public void fillList(final @Nullable SdkType type, final @Nullable Sdk[] globalSdks) {
  myListModel.clear();
  final Sdk[] jdks;
  if (myProject == null || myProject.isDefault()) {
    final Sdk[] allJdks = globalSdks != null ? globalSdks : ProjectJdkTable.getInstance().getAllJdks();
    jdks = getCompatibleJdks(type, Arrays.asList(allJdks));
  }
  else {
    final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(myProject).getProjectJdksModel();
    if (!projectJdksModel.isInitialized()){ //should be initialized
      projectJdksModel.reset(myProject);
    }
    final Collection<Sdk> collection = projectJdksModel.getProjectSdks().values();
    jdks = getCompatibleJdks(type, collection);
  }
  Arrays.sort(jdks, new Comparator<Sdk>() {
    public int compare(final Sdk o1, final Sdk o2) {
      return o1.getName().compareToIgnoreCase(o2.getName());
    }
  });
  for (Sdk jdk : jdks) {
    myListModel.addElement(jdk);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JdkChooserPanel.java

示例5: jdkNameChanged

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Override
public void jdkNameChanged(final Sdk jdk, final String previousName) {
  mergeRootsChangesDuring(new Runnable() {
    @Override
    public void run() {
      for (ProjectJdkTable.Listener listener : getListeners()) {
        listener.jdkNameChanged(jdk, previousName);
      }
    }
  });
  String currentName = getProjectSdkName();
  if (previousName != null && previousName.equals(currentName)) {
    // if already had jdk name and that name was the name of the jdk just changed
    myProjectSdkName = jdk.getName();
    myProjectSdkType = jdk.getSdkType().getName();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ProjectRootManagerImpl.java

示例6: createAndAddSDK

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
/**
 * 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>() {
    @Override
    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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SdkConfigurationUtil.java

示例7: selectSdkHome

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
public static void selectSdkHome(@NotNull final SdkType sdkType, @NotNull final Consumer<String> consumer) {
  final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor();
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(sdkType);
    if (sdk == null) throw new RuntimeException("No SDK of type " + sdkType + " found");
    consumer.consume(sdk.getHomePath());
    return;
  }
  FileChooser.chooseFiles(descriptor, null, getSuggestedSdkRoot(sdkType), new Consumer<List<VirtualFile>>() {
    @Override
    public void consume(final List<VirtualFile> chosen) {
      final String path = chosen.get(0).getPath();
      if (sdkType.isValidSdkHome(path)) {
        consumer.consume(path);
        return;
      }

      final String adjustedPath = sdkType.adjustSelectedSdkHome(path);
      if (sdkType.isValidSdkHome(adjustedPath)) {
        consumer.consume(adjustedPath);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SdkConfigurationUtil.java

示例8: rebuildSdksListAndSelectSdk

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
public void rebuildSdksListAndSelectSdk(final Sdk selectedSdk) {
  final List<Sdk> sdks = ProjectJdkTable.getInstance().getSdksOfType(AndroidSdkType.getInstance());

  final JComboBox sdksComboBox = getComboBox();
  sdksComboBox.setModel(new DefaultComboBoxModel(sdks.toArray()));

  if (selectedSdk != null) {
    for (Sdk candidateSdk : sdks) {
      if (candidateSdk != null && candidateSdk.getName().equals(selectedSdk.getName())) {
        sdksComboBox.setSelectedItem(candidateSdk);
        return;
      }
    }
  }
  sdksComboBox.setSelectedItem(null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidSdkComboBoxWithBrowseButton.java

示例9: createNewAndroidPlatform

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Nullable
public static Sdk createNewAndroidPlatform(@NotNull IAndroidTarget target,
                                           @NotNull String sdkPath,
                                           @NotNull String sdkName,
                                           @Nullable Sdk jdk,
                                           boolean addRoots) {
  ProjectJdkTable table = ProjectJdkTable.getInstance();
  String tmpName = createUniqueSdkName(SDK_NAME, Arrays.asList(table.getAllJdks()));

  final Sdk sdk = table.createSdk(tmpName, AndroidSdkType.getInstance());

  SdkModificator sdkModificator = sdk.getSdkModificator();
  sdkModificator.setHomePath(sdkPath);
  sdkModificator.commitChanges();

  setUpSdk(sdk, sdkName, table.getAllJdks(), target, jdk, addRoots);

  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      ProjectJdkTable.getInstance().addJdk(sdk);
    }
  });
  return sdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidSdkUtils.java

示例10: setupPlatform

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
private static void setupPlatform(@NotNull Module module) {
  String targetHashString = getTargetHashStringFromPropertyFile(module);
  if (targetHashString != null && findAndSetSdkWithHashString(module, targetHashString)) {
    return;
  }

  PropertiesComponent component = PropertiesComponent.getInstance();
  if (component.isValueSet(DEFAULT_PLATFORM_NAME_PROPERTY)) {
    String defaultPlatformName = component.getValue(DEFAULT_PLATFORM_NAME_PROPERTY);
    Sdk defaultLib = ProjectJdkTable.getInstance().findJdk(defaultPlatformName, AndroidSdkType.getInstance().getName());
    if (defaultLib != null && tryToSetAndroidPlatform(module, defaultLib)) {
      return;
    }
  }
  for (Sdk sdk : getAllAndroidSdks()) {
    AndroidPlatform platform = AndroidPlatform.getInstance(sdk);

    if (platform != null &&
        checkSdkRoots(sdk, platform.getTarget(), false) &&
        tryToSetAndroidPlatform(module, sdk)) {
      component.setValue(DEFAULT_PLATFORM_NAME_PROPERTY, sdk.getName());
      return;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidSdkUtils.java

示例11: findAppropriateAndroidPlatform

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Nullable
public static Sdk findAppropriateAndroidPlatform(@NotNull IAndroidTarget target, @NotNull AndroidSdkData sdkData, boolean forMaven) {
  for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
    String homePath = sdk.getHomePath();

    if (homePath != null && isAndroidSdk(sdk)) {
      AndroidSdkData currentSdkData = getSdkData(homePath);

      if (sdkData.equals(currentSdkData)) {
        AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(sdk);
        if (data != null) {
          IAndroidTarget currentTarget = data.getBuildTarget(currentSdkData);
          if (currentTarget != null &&
              target.hashString().equals(currentTarget.hashString()) &&
              checkSdkRoots(sdk, target, forMaven)) {
            return sdk;
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidSdkUtils.java

示例12: getJavaSdk

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Nullable
public Sdk getJavaSdk() {
  final ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
  if (myJavaSdk == null) {
    if (myJavaSdkName != null) {
      myJavaSdk = jdkTable.findJdk(myJavaSdkName);
      myJavaSdkName = null;
    }
    else {
      for (Sdk jdk : jdkTable.getAllJdks()) {
        if (Jdks.isApplicableJdk(jdk)) {
          myJavaSdk = jdk;
          break;
        }
      }
    }
  }
  return myJavaSdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidSdkAdditionalData.java

示例13: run

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Override
public void run() {
  final Set<String> sdkNames = getSdkNamesFromModules(myProblemModules);
  if (sdkNames.size() == 1) {
    final Sdk sdk = ProjectJdkTable.getInstance().findJdk(sdkNames.iterator().next());
    if (sdk != null && sdk.getSdkType() instanceof AndroidSdkType) {
      final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
      if (ShowSettingsUtil.getInstance().editConfigurable(myProject, config, new Runnable() {
        @Override
        public void run() {
          config.select(sdk, true);
        }
      })) {
        askAndRebuild(myProject);
      }
      return;
    }
  }

  final String moduleToSelect = myProblemModules.size() > 0
                                ? myProblemModules.iterator().next().getName()
                                : null;
  if (ModulesConfigurator.showDialog(myProject, moduleToSelect, ClasspathEditor.NAME)) {
    askAndRebuild(myProject);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:RenderErrorPanel.java

示例14: chooseOrCreateJavaSdk

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Nullable
public static Sdk chooseOrCreateJavaSdk(@Nullable LanguageLevel langLevel) {
  if (langLevel == null) {
    langLevel = DEFAULT_LANG_LEVEL;
  }
  for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
    if (isApplicableJdk(sdk, langLevel)) {
      return sdk;
    }
  }
  String jdkHomePath = getJdkHomePath(langLevel);
  if (jdkHomePath != null) {
    return createJdk(jdkHomePath);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:Jdks.java

示例15: setUp

import com.intellij.openapi.projectRoots.ProjectJdkTable; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
      Sdk defaultJdk = jdkTable.createSdk(ANDROID, AndroidSdkType.getInstance());
      jdkTable.addJdk(defaultJdk);
      mySdks.add(defaultJdk);

      Project defaultProject = ProjectManager.getInstance().getDefaultProject();
      ProjectRootManager.getInstance(defaultProject).setProjectSdk(defaultJdk);
    }
  });

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AndroidProjectWizardTest.java


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