com.intellij.openapi.projectRoots.SdkModificator Java Examples
The following examples show how to use
com.intellij.openapi.projectRoots.SdkModificator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OCamlSdkType.java From reasonml-idea-plugin with MIT License | 6 votes |
public static void reindexSourceRoots(@NotNull Sdk sdk) { VirtualFile[] ocamlSources = sdk.getRootProvider().getFiles(OCamlSourcesOrderRootType.getInstance()); VirtualFile[] javaSources = sdk.getRootProvider().getFiles(OrderRootType.SOURCES); boolean equals = ArrayUtil.equals(ocamlSources, javaSources, (Equality<VirtualFile>) (v1, v2) -> v1.getPath().equals(v2.getPath())); if (!equals) { SdkModificator sdkModificator = sdk.getSdkModificator(); sdkModificator.removeRoots(OrderRootType.SOURCES); for (VirtualFile root : ocamlSources) { sdkModificator.addRoot(root, OrderRootType.SOURCES); } Application application = ApplicationManager.getApplication(); application.invokeLater(() -> application.runWriteAction(sdkModificator::commitChanges)); } }
Example #2
Source File: HaxeProjectSdkSetupValidator.java From intellij-haxe with Apache License 2.0 | 6 votes |
private void pruneExcessiveRoots(Project project, VirtualFile file) { final Module module = ModuleUtilCore.findModuleForFile(file, project); if (module != null && !module.isDisposed()) { final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null) { final SdkModificator modificator = sdk.getSdkModificator(); final VirtualFile stdRoot = getDistinctRootsStream(sdk) .filter(root -> root.findChild(STD_TYPES_HX) != null) .findFirst() .orElse(null); if (stdRoot != null) { modificator.removeAllRoots(); modificator.addRoot(stdRoot, OrderRootType.CLASSES); modificator.addRoot(stdRoot, OrderRootType.SOURCES); WriteAction.run(modificator::commitChanges); } } } }
Example #3
Source File: HaxeAdditionalConfigurable.java From intellij-haxe with Apache License 2.0 | 6 votes |
@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(); } }); }
Example #4
Source File: OclProjectJdkWizardStep.java From reasonml-idea-plugin with MIT License | 5 votes |
private void addSdkSources(@NotNull SdkModificator odkModificator, @NotNull File targetSdkLocation) throws IOException { VirtualFileSystem fileSystem = LocalFileSystem.getInstance(); Files.walkFileTree(targetSdkLocation.toPath(), new SimpleFileVisitor<Path>() { @NotNull @Override public FileVisitResult visitFile(@NotNull Path path, BasicFileAttributes basicFileAttributes) { VirtualFile file = fileSystem.findFileByPath(path.toString()); if (file != null) { odkModificator.addRoot(file, OCamlSourcesOrderRootType.getInstance()); } return FileVisitResult.CONTINUE; } }); }
Example #5
Source File: HaxeSdkUtil.java From intellij-haxe with Apache License 2.0 | 5 votes |
public static void setupSdkPaths(@Nullable VirtualFile sdkRoot, SdkModificator modificator) { if (sdkRoot == null) { return; } VirtualFile stdRoot; final String stdPath = System.getenv("HAXE_STD_PATH"); if (stdPath != null) { stdRoot = VirtualFileManager.getInstance().findFileByUrl("file://" + stdPath); } else { stdRoot = sdkRoot.findChild("std"); } if (stdRoot != null) { modificator.addRoot(stdRoot, OrderRootType.SOURCES); modificator.addRoot(stdRoot, OrderRootType.CLASSES); } VirtualFile docRoot; final String docPath = System.getenv("HAXE_DOC_PATH"); if (docPath != null) { docRoot = VirtualFileManager.getInstance().findFileByUrl(docPath); } else { docRoot = sdkRoot.findChild("doc"); } if (docRoot != null) { modificator.addRoot(docRoot, JavadocOrderRootType.getInstance()); } }
Example #6
Source File: SdkPathEditor.java From consulo with Apache License 2.0 | 5 votes |
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); }
Example #7
Source File: SdkPathEditor.java From consulo with Apache License 2.0 | 5 votes |
public void reset(@Nullable SdkModificator modificator) { if (modificator != null) { resetPath(ContainerUtil.newArrayList(modificator.getRoots(myOrderRootType))); } else { setEnabled(false); } }
Example #8
Source File: DefaultPredefinedBundlesProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override public void createBundles(@Nonnull Context context) { for (SdkType sdkType : SdkType.EP_NAME.getExtensionList()) { try { if (sdkType.canCreatePredefinedSdks()) { Collection<String> paths = sdkType.suggestHomePaths(); for (String path : paths) { path = sdkType.adjustSelectedSdkHome(path); if (sdkType.isValidSdkHome(path)) { VirtualFile dirPath = LocalFileSystem.getInstance().findFileByPath(path); if (dirPath == null) { continue; } String sdkPath = sdkType.sdkPath(dirPath); Sdk sdk = context.createSdk(sdkType, sdkPath); SdkModificator sdkModificator = sdk.getSdkModificator(); sdkModificator.setHomePath(sdkPath); sdkModificator.setVersionString(sdkType.getVersionString(sdkPath)); sdkModificator.commitChanges(); sdkType.setupSdkPaths(sdk); } } } } catch (Error e) { LOG.error(e); } } }
Example #9
Source File: OCamlSdkType.java From reasonml-idea-plugin with MIT License | 4 votes |
@Nullable @Override public AdditionalDataConfigurable createAdditionalDataConfigurable(@NotNull SdkModel sdkModel, @NotNull SdkModificator sdkModificator) { return new OCamlAdditionalDataConfigurable(); }
Example #10
Source File: OclProjectJdkWizardStep.java From reasonml-idea-plugin with MIT License | 4 votes |
@Override public void onWizardFinished() throws CommitStepException { Sdk odk = null; if (c_rdSelectExisting.isSelected()) { JdkComboBox.JdkComboBoxItem selectedItem = c_selExistingSdk.getSelectedItem(); odk = selectedItem == null ? null : selectedItem.getJdk(); } else if (c_rdDownloadSdk.isSelected()) { String selectedSdk = (String) c_selDownload.getSelectedItem(); String sdkHomeValue = PropertiesComponent.getInstance().getValue(SDK_HOME); if (sdkHomeValue != null) { VirtualFileSystem fileSystem = LocalFileSystem.getInstance(); VirtualFile sdkHome = fileSystem.findFileByPath(sdkHomeValue); if (selectedSdk != null && sdkHome != null) { int pos = selectedSdk.lastIndexOf('.'); String patch = selectedSdk.substring(pos + 1); String majorMinor = selectedSdk.substring(0, pos); pos = majorMinor.lastIndexOf('.'); String major = majorMinor.substring(0, pos); String minor = majorMinor.substring(pos + 1); // Download SDK from distribution site LOG.debug("Download SDK", selectedSdk); ProgressManager.getInstance().run(SdkDownloader.modalTask(major, minor, patch, sdkHome, m_context.getProject())); // Create SDK LOG.debug("Create SDK", selectedSdk); File targetSdkLocation = new File(sdkHome.getCanonicalPath(), "ocaml-" + selectedSdk); odk = SdkConfigurationUtil.createAndAddSDK(targetSdkLocation.getAbsolutePath(), new OCamlSdkType()); if (odk != null) { SdkModificator odkModificator = odk.getSdkModificator(); odkModificator.setVersionString(selectedSdk); // must be set after home path, otherwise setting home path clears the version string odkModificator.setName("OCaml (sources only) " + major); try { addSdkSources(odkModificator, targetSdkLocation); } catch (IOException e) { throw new CommitStepException(e.getMessage()); } odkModificator.commitChanges(); } } } } // update selected sdk in builder ProjectBuilder builder = m_context.getProjectBuilder(); if (odk != null && builder instanceof DuneProjectImportBuilder) { ((DuneProjectImportBuilder) builder).setModuleSdk(odk); } }
Example #11
Source File: MockSdkWrapper.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public SdkModificator getSdkModificator() { return null; }