Java 类com.intellij.openapi.projectRoots.SdkModificator 实例源码

项目:manifold-ij    文件:ManSupportProvider.java   
static void addToolsJar( @NotNull ModifiableRootModel rootModel )
{
  if( hasToolsJar( rootModel ) )
  {
    return;
  }

  VirtualFile toolsJarFile = findToolsJarFile( rootModel.getProject() );
  if( toolsJarFile == null )
  {
    Notifications.Bus.notify( new Notification( "Project JDK", "tools.jar not found!", "Please add tools.jar to your JDK", NotificationType.ERROR ) );
    return;
  }

  SdkModificator sdkModificator = rootModel.getSdk().getSdkModificator();
  sdkModificator.addRoot( toolsJarFile, OrderRootType.CLASSES );
  sdkModificator.commitChanges();
}
项目:intellij-ce-playground    文件:RootsChangedTest.java   
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);
}
项目:intellij-ce-playground    文件:ModuleRootManagerTestCase.java   
@NotNull
private static Sdk retainRtJarOnlyAndSetVersion(Sdk jdk) {
  final SdkModificator modificator = jdk.getSdkModificator();
  VirtualFile rtJar = null;
  for (VirtualFile root : modificator.getRoots(OrderRootType.CLASSES)) {
    if (root.getName().equals("rt.jar")) {
      rtJar = root;
      break;
    }
  }
  assertNotNull("rt.jar not found in jdk: " + jdk, rtJar);
  modificator.setVersionString(IdeaTestUtil.getMockJdkVersion(jdk.getHomePath()));
  modificator.removeAllRoots();
  modificator.addRoot(rtJar, OrderRootType.CLASSES);
  modificator.commitChanges();
  return jdk;
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
private void addCreatedSdk(@Nullable final Sdk sdk, boolean newVirtualEnv) {
  if (sdk != null) {
    final PySdkService sdkService = PySdkService.getInstance();
    sdkService.restoreSdk(sdk);

    boolean isVirtualEnv = PythonSdkType.isVirtualEnv(sdk);
    if (isVirtualEnv && !newVirtualEnv) {
      AddVEnvOptionsDialog dialog = new AddVEnvOptionsDialog(myMainPanel);
      dialog.show();
      if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
        return;
      }
      SdkModificator modificator = myModificators.get(sdk);
      setSdkAssociated(modificator, !dialog.makeAvailableToAll());
      myModifiedModificators.add(modificator);
    }
    final Sdk oldSdk = myProjectSdksModel.findSdk(sdk);
    if (oldSdk == null) {
      myProjectSdksModel.addSdk(sdk);
    }
    refreshSdkList();
    mySdkList.setSelectedValue(myProjectSdksModel.findSdk(sdk.getName()), true);
    mySdkListChanged = true;
  }
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
@Override
public void actionPerformed(AnActionEvent e) {
  Sdk sdk = getSelectedSdk();
  final PythonPathEditor pathEditor = createPathEditor(sdk);
  final SdkModificator sdkModificator = myModificators.get(sdk);

  PythonPathDialog dialog = new PythonPathDialog(myProject, pathEditor);
  pathEditor.reset(sdk != null ? sdkModificator : null);
  if (dialog.showAndGet()) {
    if (pathEditor.isModified()) {
      pathEditor.apply(sdkModificator);
      myModifiedModificators.add(sdkModificator);
    }
  }
  updateOkButton();
}
项目:intellij-ce-playground    文件:PythonPathEditor.java   
public List<VirtualFile> reset(List<VirtualFile> list, SdkModificator modificator) {
  myFilteredOut.clear();
  List<VirtualFile> result = filterOutStubs(list, myFilteredOut);

  myFoundFiles.clear();
  myFoundFiles.addAll(list);
  myUserAddedToRemove.clear();

  if (modificator.getSdkAdditionalData() instanceof PythonSdkAdditionalData) {
    PythonSdkAdditionalData data = (PythonSdkAdditionalData)modificator.getSdkAdditionalData();
    setAdded(data.getAddedPathFiles());
    setExcluded(data.getExcludedPathFiles());
    result.addAll(myExcluded);
    result.addAll(myAdded);
  }
  else if (modificator.getSdkAdditionalData() == null) {
    myAdded.clear();
    myExcluded.clear();
  }
  return result;
}
项目:intellij-ce-playground    文件:AndroidSdkUtils.java   
@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;
}
项目:intellij-ce-playground    文件:ExternalAnnotationsSupport.java   
public static void attachJdkAnnotations(@NotNull SdkModificator modificator) {
  String homePath = FileUtil.toSystemIndependentName(PathManager.getHomePath());
  VirtualFileManager fileManager = VirtualFileManager.getInstance();

  // release build?
  String releaseLocation = homePath + "/plugins/android/lib/androidAnnotations.jar";
  VirtualFile root = fileManager.findFileByUrl("jar://" + releaseLocation + "!/");

  for (String relativePath : DEVELOPMENT_ANNOTATIONS_PATHS) {
    if (root != null) break;
    String developmentLocation = homePath + relativePath;
    root = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(developmentLocation));
  }

  if (root == null) {
    // error message tailored for release build file layout
    LOG.error("jdk annotations not found in: " + releaseLocation);
    return;
  }

  OrderRootType annoType = AnnotationOrderRootType.getInstance();
  modificator.removeRoot(root, annoType);
  modificator.addRoot(root, annoType);
}
项目:consulo-nodejs    文件:NodeJSBundleType.java   
@Override
public void setupSdkPaths(Sdk sdk)
{
    SdkModificator modificator = sdk.getSdkModificator();

    VirtualFile stubsDirectory = LocalFileSystem.getInstance().findFileByIoFile(new File(PluginManager.getPluginPath(NodeJSBundleType.class), "stubs"));
    if(stubsDirectory != null)
    {
        for(VirtualFile file : stubsDirectory.getChildren())
        {
            if(file.getFileType() == JavaScriptFileType.INSTANCE)
            {
                modificator.addRoot(file, BinariesOrderRootType.getInstance());
                modificator.addRoot(file, SourcesOrderRootType.getInstance());
            }
        }
    }

    modificator.commitChanges();
}
项目:tools-idea    文件:ModuleRootManagerTestCase.java   
@Override
protected Sdk getTestProjectJdk() {
  final Sdk jdk = super.getTestProjectJdk();
  final SdkModificator modificator = jdk.getSdkModificator();
  VirtualFile rtJar = null;
  for (VirtualFile root : modificator.getRoots(OrderRootType.CLASSES)) {
    if (root.getName().equals("rt.jar")) {
      rtJar = root;
      break;
    }
  }
  assertNotNull("rt.jar not found in jdk: " + jdk, rtJar);
  modificator.removeAllRoots();
  modificator.addRoot(rtJar, OrderRootType.CLASSES);
  modificator.commitChanges();
  return jdk;
}
项目:tools-idea    文件:PluginModuleCompilationTest.java   
@Override
protected void setUpJdk() {
  super.setUpJdk();
  new WriteAction() {
    protected void run(final Result result) {
      ProjectJdkTable table = ProjectJdkTable.getInstance();
      myPluginSdk = table.createSdk("IDEA plugin SDK", SdkType.findInstance(IdeaJdk.class));
      SdkModificator modificator = myPluginSdk.getSdkModificator();
      modificator.setSdkAdditionalData(new Sandbox(getSandboxPath(), getTestProjectJdk(), myPluginSdk));
      String rootPath = FileUtil.toSystemIndependentName(PathManager.getJarPathForClass(FileUtilRt.class));
      modificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(rootPath), OrderRootType.CLASSES);
      modificator.commitChanges();
      table.addJdk(myPluginSdk);
    }
  }.execute();
}
项目:consulo-ikvm    文件:MonoIkvmModuleExtension.java   
@Override
protected Sdk createSdk(VirtualFile virtualFile)
{
    SdkImpl sdk = new SdkImpl("Mono IKVM.NET", IkvmBundleType.getInstance());
    VirtualFile mainMonoPath = virtualFile.getParent().getParent().getParent();
    sdk.setHomePath(mainMonoPath.getPath());
    sdk.setPredefined(true);
    sdk.setVersionString(IkvmBundleType.getInstance().getVersionString(sdk));

    SdkModificator sdkModificator = sdk.getSdkModificator();
    for(String library : IkvmBundleType.ourLibraries)
    {
        VirtualFile libraryFile = mainMonoPath.findFileByRelativePath("lib/mono/ikvm/" + library);
        if(libraryFile != null)
        {
            VirtualFile archiveLibraryFile = ArchiveVfsUtil.getArchiveRootForLocalFile(libraryFile);
            if(archiveLibraryFile != null)
            {
                sdkModificator.addRoot(archiveLibraryFile, BinariesOrderRootType.getInstance());
            }
        }
    }

    sdkModificator.commitChanges();
    return sdk;
}
项目:intellij-haxe    文件:HaxeAdditionalConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  final HaxeSdkData haxeSdkData = getHaxeSdkData();
  if (haxeSdkData == null) {
    return;
  }

  final HaxeSdkData newData = new HaxeSdkData(haxeSdkData.getHomePath(), haxeSdkData.getVersion());
  newData.setNekoBinPath(FileUtil.toSystemIndependentName(myHaxeAdditionalConfigurablePanel.getNekoBinPath()));
  newData.setHaxelibPath(FileUtil.toSystemIndependentName(myHaxeAdditionalConfigurablePanel.getHaxelibPath()));
  newData.setUseCompilerCompletionFlag(myHaxeAdditionalConfigurablePanel.getUseCompilerCompletionFlag());
  newData.setRemoveCompletionDuplicatesFlag(myHaxeAdditionalConfigurablePanel.getRemoveCompletionDuplicatesFlag());

  final SdkModificator modificator = mySdk.getSdkModificator();
  modificator.setSdkAdditionalData(newData);
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      modificator.commitChanges();
    }
  });
}
项目:consulo-haxe    文件:HaxeAdditionalConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  final HaxeSdkData haxeSdkData = getHaxeSdkData();
  if (haxeSdkData == null) {
    return;
  }

  final HaxeSdkData newData = new HaxeSdkData(haxeSdkData.getHomePath(), haxeSdkData.getVersion());
  newData.setNekoBinPath(FileUtil.toSystemIndependentName(myHaxeAdditionalConfigurablePanel.getNekoBinPath()));
  newData.setHaxelibPath(FileUtil.toSystemIndependentName(myHaxeAdditionalConfigurablePanel.getHaxelibPath()));

  final SdkModificator modificator = mySdk.getSdkModificator();
  modificator.setSdkAdditionalData(newData);
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      modificator.commitChanges();
    }
  });
}
项目:consulo-apache-ant    文件:AntSdkType.java   
@Override
public void setupSdkPaths(Sdk sdk)
{
    SdkModificator sdkModificator = sdk.getSdkModificator();
    VirtualFile homeDirectory = sdk.getHomeDirectory();
    VirtualFile lib = homeDirectory.findChild("lib");
    if(lib != null)
    {
        for(VirtualFile virtualFile : lib.getChildren())
        {
            VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(virtualFile);
            if(archiveRootForLocalFile != null)
            {
                sdkModificator.addRoot(archiveRootForLocalFile, BinariesOrderRootType.getInstance());
            }
        }
    }
    sdkModificator.commitChanges();
}
项目:consulo-java    文件:ExternalAnnotationsManagerImpl.java   
private void appendChosenAnnotationsRoot(@NotNull final OrderEntry entry, @NotNull final VirtualFile vFile)
{
    if(entry instanceof LibraryOrderEntry)
    {
        Library library = ((LibraryOrderEntry) entry).getLibrary();
        LOG.assertTrue(library != null);
        final Library.ModifiableModel model = library.getModifiableModel();
        model.addRoot(vFile, AnnotationOrderRootType.getInstance());
        model.commit();
    }
    else if(entry instanceof ModuleExtensionWithSdkOrderEntry)
    {
        Sdk sdk = ((ModuleExtensionWithSdkOrderEntry) entry).getSdk();
        LOG.assertTrue(sdk != null);
        final SdkModificator sdkModificator = sdk.getSdkModificator();
        sdkModificator.addRoot(vFile, AnnotationOrderRootType.getInstance());
        sdkModificator.commitChanges();
    }
    dropCache();
}
项目:consulo-java    文件:JavaSdkImpl.java   
public static boolean attachJdkAnnotations(@NotNull SdkModificator modificator)
{
    File pluginPath = PluginManager.getPluginPath(JavaSdkImpl.class);

    File file = new File(pluginPath, "jdk-annotations.jar");

    VirtualFile localFile = LocalFileSystem.getInstance().findFileByIoFile(file);

    if(localFile == null)
    {
        LOG.error("jdk annotations not found in: " + file);
        return false;
    }

    VirtualFile jarFile = ArchiveVfsUtil.getArchiveRootForLocalFile(localFile);
    if(jarFile == null)
    {
        LOG.error("jdk annotations is not archive: " + file);
        return false;
    }

    OrderRootType annoType = AnnotationOrderRootType.getInstance();
    modificator.removeRoot(jarFile, annoType);
    modificator.addRoot(jarFile, annoType);
    return true;
}
项目:consulo-java    文件:ModuleRootManagerTestCase.java   
@Override
protected Sdk getTestProjectJdk() {
  final Sdk jdk = super.getTestProjectJdk();
  final SdkModificator modificator = jdk.getSdkModificator();
  VirtualFile rtJar = null;
  for (VirtualFile root : modificator.getRoots(OrderRootType.CLASSES)) {
    if (root.getName().equals("rt.jar")) {
      rtJar = root;
      break;
    }
  }
  assertNotNull("rt.jar not found in jdk: " + jdk, rtJar);
  modificator.removeAllRoots();
  modificator.addRoot(rtJar, OrderRootType.CLASSES);
  modificator.commitChanges();
  return jdk;
}
项目:intellij-ce-playground    文件:NullableStuffInspectionAncientTest.java   
private static void removeAnnotationsJar(final Sdk sdk) {
  ApplicationManager.getApplication().runWriteAction(() -> {
    final SdkModificator sdkMod = sdk.getSdkModificator();
    for (VirtualFile file : sdkMod.getRoots(OrderRootType.CLASSES)) {
      if ("annotations.jar".equals(file.getName())) {
        sdkMod.removeRoot(file, OrderRootType.CLASSES);
        break;
      }
    }
    sdkMod.commitChanges();
  });
}
项目:intellij-ce-playground    文件:BytecodeAnalysisIntegrationTest.java   
private void setUpExternalUpAnnotations() {
  String annotationsPath = PathManagerEx.getTestDataPath() + "/codeInspection/bytecodeAnalysis/annotations";
  final VirtualFile annotationsDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(annotationsPath);
  assertNotNull(annotationsDir);

  ModuleRootModificationUtil.updateModel(myModule, new AsynchConsumer<ModifiableRootModel>() {
    @Override
    public void finished() {
    }

    @Override
    public void consume(ModifiableRootModel modifiableRootModel) {
      final LibraryTable libraryTable = modifiableRootModel.getModuleLibraryTable();
      Library[] libs = libraryTable.getLibraries();
      for (Library library : libs) {
        final Library.ModifiableModel libraryModel = library.getModifiableModel();
        libraryModel.addRoot(annotationsDir, AnnotationOrderRootType.getInstance());
        libraryModel.commit();
      }
      Sdk sdk = modifiableRootModel.getSdk();
      if (sdk != null) {
        SdkModificator sdkModificator = sdk.getSdkModificator();
        sdkModificator.addRoot(annotationsDir, AnnotationOrderRootType.getInstance());
        sdkModificator.commitChanges();
      }
    }
  });

  VfsUtilCore.visitChildrenRecursively(annotationsDir, new VirtualFileVisitor() { });
  annotationsDir.refresh(false, true);
}
项目:intellij-ce-playground    文件:RootsChangedTest.java   
public void testModuleJdkEditing() throws Exception {
  final File tempDirectory = createTempDirectory();
  ApplicationManager.getApplication().runWriteAction(() -> {
    final Module moduleA = createModule("a.iml");
    final Module moduleB = createModule("b.iml");
    assertEventsCount(2);

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

    final ModifiableRootModel rootModelA = ModuleRootManager.getInstance(moduleA).getModifiableModel();
    final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
    rootModelA.setSdk(jdk);
    rootModelB.setSdk(jdk);
    ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
    ModifiableModelCommitter.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
    assertEventsCount(1);

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

    ProjectJdkTable.getInstance().removeJdk(jdk);
    assertEventsCount(1);
  });
}
项目:intellij-ce-playground    文件:RootsChangedTest.java   
public void testInheritedJdkEditing() throws Exception {
  final File tempDirectory = createTempDirectory();
  ApplicationManager.getApplication().runWriteAction(() -> {
    final Module moduleA = createModule("a.iml");
    final Module moduleB = createModule("b.iml");
    assertEventsCount(2);

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

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

    ProjectRootManager.getInstance(myProject).setProjectSdk(jdkBBB);
    assertEventsCount(0);

    final ModifiableRootModel rootModelA = ModuleRootManager.getInstance(moduleA).getModifiableModel();
    final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
    rootModelA.inheritSdk();
    rootModelB.inheritSdk();
    ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
    if (rootModels.length > 0) {
      ModifiableModelCommitter.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
    }
    assertEventsCount(1);

    ProjectRootManager.getInstance(myProject).setProjectSdk(jdk);
    assertEventsCount(1);

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

    ProjectJdkTable.getInstance().removeJdk(jdk);
    assertEventsCount(1);
  });
}
项目:intellij-ce-playground    文件:PsiTestUtil.java   
public static Sdk addJdkAnnotations(Sdk sdk) {
  VirtualFile root = LocalFileSystem.getInstance().findFileByPath(
    FileUtil.toSystemIndependentName(PlatformTestUtil.getCommunityPath()) + "/java/jdkAnnotations");
  if (root != null) {
    SdkModificator sdkModificator = sdk.getSdkModificator();
    sdkModificator.addRoot(root, AnnotationOrderRootType.getInstance());
    sdkModificator.commitChanges();
  }
  return sdk;
}
项目:intellij-ce-playground    文件:SdkPathEditor.java   
public void apply(SdkModificator sdkModificator) {
  sdkModificator.removeRoots(myOrderRootType);
  // add all items
  for (int i = 0; i < getRowCount(); i++) {
    sdkModificator.addRoot(getValueAt(i), myOrderRootType);
  }
  setModified(false);
}
项目:intellij-ce-playground    文件:SdkPathEditor.java   
public void reset(@Nullable SdkModificator modificator) {
  if (modificator != null) {
    resetPath(ContainerUtil.newArrayList(modificator.getRoots(myOrderRootType)));
  }
  else {
    setEnabled(false);
  }
}
项目:intellij-ce-playground    文件:PySdkUpdater.java   
public void addRoot(@NotNull final VirtualFile root, @NotNull final OrderRootType rootType) {
  modifySdk(new SdkModificationProcessor() {
    @Override
    public void process(@NotNull Sdk sdk, @NotNull SdkModificator sdkModificator) {
      sdkModificator.addRoot(root, rootType);
    }
  });
}
项目:intellij-ce-playground    文件:PySdkUpdater.java   
public void removeRoots(@NotNull final OrderRootType rootType) {
  modifySdk(new PySdkUpdater.SdkModificationProcessor() {
    @Override
    public void process(@NotNull Sdk sdk, @NotNull SdkModificator sdkModificator) {
      sdkModificator.removeRoots(rootType);
    }
  });
}
项目:intellij-ce-playground    文件:PySdkUpdater.java   
public void modifySdk(@NotNull SdkModificationProcessor processor) {
  ApplicationManager.getApplication().assertIsDispatchThread();

  Sdk sdk = PythonSdkType.findSdkByPath(mySdkPath);

  if (sdk != null) {
    SdkModificator modificator = getSdk().getSdkModificator();
    processor.process(sdk, modificator);
    modificator.commitChanges();
  }
}
项目:intellij-ce-playground    文件:PythonMockSdk.java   
public static Sdk create(final String version, @NotNull final VirtualFile ... additionalRoots) {
  final String mock_path = PythonTestUtil.getTestDataPath() + "/MockSdk" + version + "/";

  String sdkHome = new File(mock_path, "bin/python"+version).getPath();
  SdkType sdkType = PythonSdkType.getInstance();


  final Sdk sdk = new ProjectJdkImpl(MOCK_SDK_NAME + " " + version, sdkType) {
    @Override
    public String getVersionString() {
      return "Python " + version + " Mock SDK";
    }
  };
  final SdkModificator sdkModificator = sdk.getSdkModificator();
  sdkModificator.setHomePath(sdkHome);

  File libPath = new File(mock_path, "Lib");
  if (libPath.exists()) {
    sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libPath), OrderRootType.CLASSES);
  }

  PyUserSkeletonsUtil.addUserSkeletonsRoot(PySdkUpdater.fromSdkModificator(sdk, sdkModificator));

  String mock_stubs_path = mock_path + PythonSdkType.SKELETON_DIR_NAME;
  sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(mock_stubs_path), PythonSdkType.BUILTIN_ROOT_TYPE);

  for (final VirtualFile root : additionalRoots) {
    sdkModificator.addRoot(root, OrderRootType.CLASSES);
  }

  sdkModificator.commitChanges();

  final FileBasedIndex index = FileBasedIndex.getInstance();
  index.requestRebuild(StubUpdatingIndex.INDEX_ID);
  index.requestRebuild(PyModuleNameIndex.NAME);

  return sdk;
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
public void apply() throws ConfigurationException {
  if (!myModifiedModificators.isEmpty()) {
    mySdkSettingsWereModified.run();
  }
  for (SdkModificator modificator : myModifiedModificators) {
    modificator.commitChanges();
  }
  myModificators.clear();
  myModifiedModificators.clear();
  mySdkListChanged = false;
  myShowMoreCallback.consume(getSelectedSdk());
  Disposer.dispose(getDisposable());
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
private void editRemoteSdk(Sdk currentSdk) {
  PythonRemoteInterpreterManager remoteInterpreterManager = PythonRemoteInterpreterManager.getInstance();
  if (remoteInterpreterManager != null) {
    final SdkModificator modificator = myModificators.get(currentSdk);
    Set<Sdk> existingSdks = Sets.newHashSet(myProjectSdksModel.getSdks());
    existingSdks.remove(currentSdk);
    if (remoteInterpreterManager.editSdk(myProject, modificator, existingSdks)) {
      myModifiedModificators.add(modificator);
    }
  }
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
private void editSdk(final Sdk currentSdk) {
  final SdkModificator modificator = myModificators.get(currentSdk);
  final EditSdkDialog dialog = new EditSdkDialog(myProject, modificator, new NullableFunction<String, String>() {
    @Override
    public String fun(String s) {
      if (isDuplicateSdkName(s, currentSdk)) {
        return PyBundle.message("sdk.details.dialog.error.duplicate.name");
      }
      return null;
    }
  });
  if (dialog.showAndGet()) {
    mySdkList.repaint();
    final boolean pathChanged = !Comparing.equal(currentSdk.getHomePath(), dialog.getHomePath());
    if (!modificator.getName().equals(dialog.getName()) || pathChanged || dialog.isAssociateChanged()) {
      myModifiedModificators.add(modificator);
      modificator.setName(dialog.getName());
      modificator.setHomePath(dialog.getHomePath());

      if (dialog.isAssociateChanged()) {
        setSdkAssociated(modificator, dialog.associateWithProject());
      }
      if (pathChanged) {
        reloadSdk(currentSdk);
      }
    }
  }
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
private void setSdkAssociated(SdkModificator modificator, boolean isAssociated) {
  PythonSdkAdditionalData additionalData = (PythonSdkAdditionalData)modificator.getSdkAdditionalData();
  if (additionalData == null) {
    additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(modificator.getHomePath()));
    modificator.setSdkAdditionalData(additionalData);
  }
  if (isAssociated) {
    additionalData.associateWithProject(myProject);
  }
  else {
    additionalData.setAssociatedProjectPath(null);
  }
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
private void removeSdk() {
  final Sdk currentSdk = getSelectedSdk();
  if (currentSdk != null) {
    final Sdk sdk = myProjectSdksModel.findSdk(currentSdk);
    final PySdkService sdkService = PySdkService.getInstance();
    sdkService.removeSdk(currentSdk);
    DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_MODAL, new Runnable() {
      @Override
      public void run() {
        SdkConfigurationUtil.removeSdk(sdk);
      }
    });

    myProjectSdksModel.removeSdk(sdk);
    myProjectSdksModel.removeSdk(currentSdk);

    if (myModificators.containsKey(currentSdk)) {
      SdkModificator modificator = myModificators.get(currentSdk);
      myModifiedModificators.remove(modificator);
      myModificators.remove(currentSdk);
    }
    refreshSdkList();
    mySdkListChanged = true;
    // TODO select initially selected SDK
    if (mySdkList.getSelectedIndex() < 0) {
      mySdkList.setSelectedIndex(0);
    }
  }
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
@Override
public void apply(SdkModificator sdkModificator) {
  if (sdkModificator.getSdkAdditionalData() instanceof PyRemoteSdkAdditionalDataBase) {
    for (PathMappingSettings.PathMapping mapping : myNewMappings) {
      ((PyRemoteSdkAdditionalDataBase)sdkModificator.getSdkAdditionalData()).getPathMappings()
        .addMappingCheckUnique(mapping.getLocalRoot(), mapping.getRemoteRoot());
    }
  }
  super.apply(sdkModificator);
}
项目:intellij-ce-playground    文件:PythonPathEditor.java   
public void reset(@Nullable SdkModificator modificator) {
  if (modificator != null) {
    List<VirtualFile> list = Lists.newArrayList(modificator.getRoots(getOrderRootType()));
    resetPath(myPathListModel.reset(list, modificator));
  }
  else {
    setEnabled(false);
  }
}
项目:intellij-ce-playground    文件:PythonPathEditor.java   
public void reload(@Nullable SdkModificator sdkModificator) {
  if (sdkModificator != null) {
    List<VirtualFile> list = Lists.newArrayList(sdkModificator.getRoots(getOrderRootType()));
    resetPath(myPathListModel.reload(list));
    setModified(true);
  }
  else {
    setEnabled(false);
  }
}
项目:intellij-ce-playground    文件:PythonPathEditor.java   
@Override
public void apply(SdkModificator sdkModificator) {
  sdkModificator.removeRoots(getOrderRootType());
  // add all items
  for (int i = 0; i < myPathListModel.getRowCount(); i++) {
    VirtualFile path = myPathListModel.getValueAt(i);
    if (!myPathListModel.isExcluded(path)) {
      sdkModificator.addRoot(path, getOrderRootType());
    }
  }
  setModified(false);
  myPathListModel.apply(sdkModificator);
}
项目:intellij-ce-playground    文件:PythonPathEditor.java   
private SdkAdditionalData collectSdkAdditionalData(SdkModificator sdkModificator) {
  PythonSdkAdditionalData data = (PythonSdkAdditionalData)sdkModificator.getSdkAdditionalData();
  if (data == null) {
    data = new PythonSdkAdditionalData(null);
  }
  data.setAddedPathsFromVirtualFiles(myAdded);
  data.setExcludedPathsFromVirtualFiles(myExcluded);
  return data;
}
项目:intellij-ce-playground    文件:AndroidFacetImporterBase.java   
@Nullable
private static Sdk createNewAndroidSdkForMaven(String sdkPath, IAndroidTarget target) {
  String sdkName = "Maven " + AndroidSdkUtils.chooseNameForNewLibrary(target);
  Sdk sdk = AndroidSdkUtils.createNewAndroidPlatform(target, sdkPath, sdkName, false);

  if (sdk == null) {
    return null;
  }
  SdkModificator modificator = sdk.getSdkModificator();

  for (OrderRoot root : AndroidSdkUtils.getLibraryRootsForTarget(target, sdkPath, false)) {
    modificator.addRoot(root.getFile(), root.getType());
  }
  AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(sdk);

  if (data != null) {
    final Sdk javaSdk = data.getJavaSdk();

    if (javaSdk != null) {
      for (VirtualFile file : javaSdk.getRootProvider().getFiles(OrderRootType.CLASSES)) {
        modificator.addRoot(file, OrderRootType.CLASSES);
      }
    }
    else {
      LOG.error("AndroidSdkUtils.createNewAndroidPlatform should return Android SDK with a valid JDK reference, or return null");
    }
  }
  modificator.commitChanges();
  return sdk;
}