com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil Java Examples
The following examples show how to use
com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil.
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: SdkListConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void actionPerformed(final AnActionEvent e) { final Object o = getSelectedObject(); if (o instanceof SdkImpl) { final SdkImpl selected = (SdkImpl)o; String defaultNewName = SdkConfigurationUtil.createUniqueSdkName(selected.getName(), mySdksModel.getSdks()); final String newName = Messages.showInputDialog("Enter bundle name:", "Copy Bundle", null, defaultNewName, new NonEmptyInputValidator() { @Override public boolean checkInput(String inputString) { return super.checkInput(inputString) && mySdksModel.findSdk(inputString) == null; } }); if (newName == null) return; SdkImpl sdk = selected.clone(); sdk.setName(newName); sdk.setPredefined(false); mySdksModel.doAdd(sdk, sdk1 -> addSdkNode(sdk1, true)); } }
Example #2
Source File: SdkListConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void actionPerformed(final AnActionEvent e) { final Object o = getSelectedObject(); if (o instanceof SdkImpl) { final SdkImpl selected = (SdkImpl)o; String defaultNewName = SdkConfigurationUtil.createUniqueSdkName(selected.getName(), mySdksModel.getSdks()); final String newName = Messages.showInputDialog("Enter bundle name:", "Copy Bundle", null, defaultNewName, new NonEmptyInputValidator() { @Override public boolean checkInput(String inputString) { return super.checkInput(inputString) && mySdksModel.findSdk(inputString) == null; } }); if (newName == null) return; SdkImpl sdk = selected.clone(); sdk.setName(newName); sdk.setPredefined(false); mySdksModel.doAdd(sdk, sdk1 -> addSdkNode(sdk1, true)); } }
Example #3
Source File: GradleImportingTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { assumeThat(gradleVersion, versionMatcherRule.getMatcher()); myJdkHome = IdeaTestUtil.requireRealJdkHome(); super.setUp(); WriteAction.runAndWait(() -> { Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME); if (oldJdk != null) { ProjectJdkTable.getInstance().removeJdk(oldJdk); } VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome)); JavaSdk javaSdk = JavaSdk.getInstance(); SdkType javaSdkType = javaSdk == null ? SimpleJavaSdkType.getInstance() : javaSdk; Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, javaSdkType, true, null, GRADLE_JDK_NAME); assertNotNull("Cannot create JDK for " + myJdkHome, jdk); ProjectJdkTable.getInstance().addJdk(jdk); }); myProjectSettings = new GradleProjectSettings().withQualifiedModuleNames(); System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS)); PathAssembler.LocalDistribution distribution = configureWrapper(); List<String> allowedRoots = new ArrayList<>(); collectAllowedRoots(allowedRoots, distribution); if (!allowedRoots.isEmpty()) { VfsRootAccess.allowRootAccess(myTestFixture.getTestRootDisposable(), ArrayUtil.toStringArray(allowedRoots)); } }
Example #4
Source File: Jdks.java From intellij with Apache License 2.0 | 5 votes |
@Nullable private static Sdk createJdk(String jdkHomePath) { Sdk jdk = SdkConfigurationUtil.createAndAddSDK(jdkHomePath, JavaSdk.getInstance()); if (jdk == null) { logger.error(String.format("Unable to create JDK from path '%1$s'", jdkHomePath)); } return jdk; }
Example #5
Source File: BaseSdkCompat.java From intellij with Apache License 2.0 | 5 votes |
/** #api193: SdkConfigurationUtil changed in 2020.1. */ public static ProjectJdkImpl createSdk( Collection<? extends Sdk> allSdks, VirtualFile homeDir, SdkType sdkType, @Nullable SdkAdditionalData additionalData, @Nullable String customSdkSuggestedName) { return SdkConfigurationUtil.createSdk( allSdks.toArray(new Sdk[0]), homeDir, sdkType, additionalData, customSdkSuggestedName); }
Example #6
Source File: BaseSdkCompat.java From intellij with Apache License 2.0 | 5 votes |
/** #api193: SdkConfigurationUtil changed in 2020.1. */ public static ProjectJdkImpl createSdk( Collection<? extends Sdk> allSdks, VirtualFile homeDir, SdkType sdkType, @Nullable SdkAdditionalData additionalData, @Nullable String customSdkSuggestedName) { return SdkConfigurationUtil.createSdk( allSdks, homeDir, sdkType, additionalData, customSdkSuggestedName); }
Example #7
Source File: PySdkSuggester.java From intellij with Apache License 2.0 | 5 votes |
/** * Registered Python SDK to use for the given project and python version if this PySdkSuggester * can provide one. * * @param project the project to register an SDK for * @param version the python version to register an SDK for */ boolean createSdkIfNeeded(Project project, PythonVersion version) { String homePath = suggestPythonHomePath(project, version); if (homePath == null) { return false; } Sdk sdk = findPythonSdk(homePath); if (sdk != null) { return false; } return SdkConfigurationUtil.createAndAddSDK(homePath, PythonSdkType.getInstance()) != null; }
Example #8
Source File: PredefinedBundlesLoader.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public Sdk createSdkWithName(@Nonnull SdkType sdkType, @Nonnull String suggestName) { Sdk[] sdks = ArrayUtil.mergeArrayAndCollection(mySdkTable.getAllSdks(), myBundles, Sdk.ARRAY_FACTORY); String uniqueSdkName = SdkConfigurationUtil.createUniqueSdkName(suggestName + SdkConfigurationUtil.PREDEFINED_PREFIX, sdks); Sdk sdk = mySdkTable.createSdk(uniqueSdkName, sdkType); myBundles.add(sdk); return sdk; }
Example #9
Source File: BaseSdkEditor.java From consulo with Apache License 2.0 | 5 votes |
private void doSelectHomePath() { final SdkType sdkType = (SdkType)mySdk.getSdkType(); SdkConfigurationUtil.selectSdkHome(sdkType, new Consumer<String>() { @Override public void consume(final String path) { doSetHomePath(path, sdkType); } }); }
Example #10
Source File: DefaultSdksModel.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess public void doAdd(JComponent parent, final SdkType type, final Consumer<Sdk> callback) { myModified = true; if (type.supportsCustomCreateUI()) { type.showCustomCreateUI(this, parent, sdk -> setupSdk(sdk, callback)); } else { SdkConfigurationUtil.selectSdkHome(type, home -> { String newSdkName = SdkConfigurationUtil.createUniqueSdkName(type, home, getSdks()); final SdkImpl newSdk = new SdkImpl(mySdkTableProvider.get(), newSdkName, type); newSdk.setHomePath(home); setupSdk(newSdk, callback); }); } }
Example #11
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); } }