本文整理汇总了Java中com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil类的典型用法代码示例。如果您正苦于以下问题:Java SdkConfigurationUtil类的具体用法?Java SdkConfigurationUtil怎么用?Java SdkConfigurationUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SdkConfigurationUtil类属于com.intellij.openapi.projectRoots.impl包,在下文中一共展示了SdkConfigurationUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addDetectedSdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的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: doAdd
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
public void doAdd(JComponent parent, final SdkType type, final Consumer<Sdk> callback) {
myModified = true;
if (type.supportsCustomCreateUI()) {
type.showCustomCreateUI(this, parent, new Consumer<Sdk>() {
@Override
public void consume(Sdk sdk) {
setupSdk(sdk, callback);
}
});
}
else {
SdkConfigurationUtil.selectSdkHome(type, new Consumer<String>() {
@Override
public void consume(final String home) {
String newSdkName = SdkConfigurationUtil.createUniqueSdkName(type, home, myProjectSdks.values());
final ProjectJdkImpl newJdk = new ProjectJdkImpl(newSdkName, type);
newJdk.setHomePath(home);
setupSdk(newJdk, callback);
}
});
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ProjectSdksModel.java
示例3: addDetectedSdks
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
private void addDetectedSdks(@NotNull final List<Sdk> result) {
final PySdkService sdkService = PySdkService.getInstance();
final List<String> sdkHomes = new ArrayList<String>();
sdkHomes.addAll(VirtualEnvSdkFlavor.INSTANCE.suggestHomePaths());
for (PythonSdkFlavor flavor : PythonSdkFlavor.getApplicableFlavors()) {
if (flavor instanceof VirtualEnvSdkFlavor) continue;
sdkHomes.addAll(flavor.suggestHomePaths());
}
Collections.sort(sdkHomes);
sdkHomes.addAll(sdkService.getAddedSdks());
for (String sdkHome : SdkConfigurationUtil.filterExistingPaths(PythonSdkType.getInstance(), sdkHomes, getModel().getSdks())) {
result.add(new PyDetectedSdk(sdkHome));
}
Iterables.removeIf(result, new Predicate<Sdk>() {
@Override
public boolean apply(@Nullable Sdk input) {
return input != null && sdkService.isRemoved(input);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyConfigurableInterpreterList.java
示例4: createAndSetJdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
@NotNull
public static Sdk createAndSetJdk(@NotNull final Project project) {
String[] names = {"JAVA6_HOME", "JAVA_HOME"};
String jdkHomePath = AndroidTestCaseHelper.getSystemPropertyOrEnvironmentVariable(names);
assertNotNull("Please set one of the following env vars (or system properties) to point to the JDK: " + Joiner.on(",").join(names),
jdkHomePath);
final Sdk jdk = SdkConfigurationUtil.createAndAddSDK(jdkHomePath, JavaSdk.getInstance());
assertNotNull(jdk);
ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
@Override
public void execute() {
NewProjectUtil.applyJdkToProject(project, jdk);
}
});
return jdk;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AndroidTestCaseHelper.java
示例5: setUp
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
myJdkHome = IdeaTestUtil.requireRealJdkHome();
super.setUp();
assumeThat(gradleVersion, versionMatcherRule.getMatcher());
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME);
if (oldJdk != null) {
ProjectJdkTable.getInstance().removeJdk(oldJdk);
}
VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome));
Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME);
assertNotNull("Cannot create JDK for " + myJdkHome, jdk);
ProjectJdkTable.getInstance().addJdk(jdk);
}
}.execute();
myProjectSettings = new GradleProjectSettings();
GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx64m -XX:MaxPermSize=64m");
System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS));
configureWrapper();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GradleImportingTestCase.java
示例6: tearDown
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
@Override
public void tearDown() throws Exception {
if (myJdkHome == null) {
//super.setUp() wasn't called
return;
}
try {
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
Sdk old = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME);
if (old != null) {
SdkConfigurationUtil.removeSdk(old);
}
}
}.execute();
Messages.setTestDialog(TestDialog.DEFAULT);
FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory());
}
finally {
super.tearDown();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GradleImportingTestCase.java
示例7: doAdd
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
public void doAdd(JComponent parent, final SdkType type, final Consumer<Sdk> callback) {
myModified = true;
if (type.supportsCustomCreateUI()) {
type.showCustomCreateUI(this, parent, new Consumer<Sdk>() {
@Override
public void consume(Sdk sdk) {
setupSdk(sdk, callback);
}
});
}
else {
SdkConfigurationUtil.selectSdkHome(type, new Consumer<String>() {
@Override
public void consume(final String home) {
String newSdkName = SdkConfigurationUtil.createUniqueSdkName(type, home, getSdks());
final SdkImpl newSdk = new SdkImpl(newSdkName, type);
newSdk.setHomePath(home);
setupSdk(newSdk, callback);
}
});
}
}
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:ProjectSdksModel.java
示例8: afterProjectGenerated
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
@Override
public void afterProjectGenerated(@NotNull Project project) {
Sdk sdk = mySettings.getSdk();
if (sdk == PLACEHOLDER_SDK) {
createAndAddVirtualEnv(project, mySettings);
sdk = mySettings.getSdk();
}
if (sdk instanceof PyDetectedSdk) {
sdk = addDetectedSdk(sdk, project);
}
SdkConfigurationUtil.setDirectoryProjectSdk(project, sdk);
}
开发者ID:medvector,项目名称:educational-plugin,代码行数:14,代码来源:PyStudyDirectoryProjectGenerator.java
示例9: doSelectHomePath
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
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);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:SdkEditor.java
示例10: setupVirtualEnvSdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
protected static void setupVirtualEnvSdk(final String path,
boolean associateWithProject,
VirtualEnvCallback callback) {
final VirtualFile sdkHome =
ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
@Nullable
public VirtualFile compute() {
return LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
}
});
if (sdkHome != null) {
final Sdk sdk = SdkConfigurationUtil.createAndAddSDK(FileUtil.toSystemDependentName(sdkHome.getPath()), PythonSdkType.getInstance());
callback.virtualEnvCreated(sdk, associateWithProject);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:AbstractCreateVirtualEnvDialog.java
示例11: createLocalSdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
private void createLocalSdk() {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
SdkConfigurationUtil.createSdk(myProject, myExistingSdks, mySdkAddedCallback, false, PythonSdkType.getInstance());
}
}, ModalityState.any());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PythonSdkDetailsStep.java
示例12: removeSdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
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);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PythonSdkDetailsDialog.java
示例13: createAndroidSdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
private static void createAndroidSdk(@NotNull String androidHomePath, @NotNull String targetHashString, @NotNull Sdk javaSdk) {
Sdk sdk = SdkConfigurationUtil.createAndAddSDK(androidHomePath, AndroidSdkType.getInstance());
assertNotNull(sdk);
AndroidSdkData sdkData = AndroidSdkData.getSdkData(androidHomePath);
assertNotNull(sdkData);
IAndroidTarget target = sdkData.findTargetByHashString(targetHashString);
assertNotNull(target);
AndroidSdkUtils.setUpSdk(sdk, target.getName(), new Sdk[]{javaSdk}, target, javaSdk, true);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AndroidSdkUtilsTest.java
示例14: createJdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
@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;
}
开发者ID:bazelbuild,项目名称:intellij,代码行数:9,代码来源:Jdks.java
示例15: getOrCreatePythonSdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
@Nullable
private static Sdk getOrCreatePythonSdk() {
List<Sdk> sdk = PythonSdkType.getAllSdks();
if (!sdk.isEmpty()) {
return sdk.get(0);
}
return SdkConfigurationUtil.createAndAddSDK("/usr/bin/python2.7", PythonSdkType.getInstance());
}
开发者ID:bazelbuild,项目名称:intellij,代码行数:9,代码来源:BlazePythonSyncPlugin.java
示例16: setupSdk
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
public static void setupSdk(@NotNull final Sdk defracSdk,
@NotNull final String sdkName,
@NotNull final Sdk[] allSdks,
@NotNull final DefracVersion defracVersion,
@Nullable final Sdk javaSdk,
final boolean addRoots) {
final DefracSdkAdditionalData data = new DefracSdkAdditionalData(defracSdk, javaSdk);
final String name = SdkConfigurationUtil.createUniqueSdkName(sdkName, Arrays.asList(allSdks));
final SdkModificator sdkModificator = defracSdk.getSdkModificator();
data.setDefracVersion(defracVersion);
sdkModificator.setName(name);
if(javaSdk != null) {
sdkModificator.setVersionString(javaSdk.getVersionString());
}
sdkModificator.setSdkAdditionalData(data);
if(addRoots) {
sdkModificator.removeAllRoots();
attachLibraries(defracVersion, sdkModificator);
attachAnnotations(defracVersion, sdkModificator);
}
sdkModificator.commitChanges();
}
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:29,代码来源:DefracSdkUtil.java
示例17: doSelectHomePath
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
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);
}
});
}
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:BaseSdkEditor.java
示例18: configureProject
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, Ref<Module> moduleRef) {
// it it a virtualenv?
final PythonSdkType sdkType = PythonSdkType.getInstance();
//find virtualEnv in project directory
final List<String> candidates = new ArrayList<String>();
if (project == null) return;
final VirtualFile rootDir = project.getBaseDir();
if (rootDir != null)
candidates.addAll(VirtualEnvSdkFlavor.findInDirectory(rootDir));
if (!candidates.isEmpty()) {
String filePath = candidates.get(0);
if (StringUtil.startsWithChar(filePath, '~')) {
final String home = SystemProperties.getUserHome();
filePath = home + filePath.substring(1);
}
final Sdk virtualEnvSdk = SdkConfigurationUtil.createAndAddSDK(filePath, sdkType);
if (virtualEnvSdk != null) {
SdkConfigurationUtil.setDirectoryProjectSdk(project, virtualEnvSdk);
SdkAdditionalData additionalData = virtualEnvSdk.getSdkAdditionalData();
if (additionalData == null) {
additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(virtualEnvSdk.getHomePath()));
((ProjectJdkImpl)virtualEnvSdk).setSdkAdditionalData(additionalData);
}
((PythonSdkAdditionalData) additionalData).associateWithProject(project);
return;
}
return;
}
final Sdk existingSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (existingSdk != null && existingSdk.getSdkType() == sdkType) return; // SdkConfigurationUtil does the same
final File executableFile = PythonSdkType.findExecutableFile(new File(project.getBasePath(), "bin"), "python");
if (executableFile != null) {
final File virtualEnvRoot = PythonSdkType.getVirtualEnvRoot(executableFile.getPath());
if (virtualEnvRoot != null) {
// yes, an unknown virtualenv; set it up as SDK
final Sdk sdk = SdkConfigurationUtil.createAndAddSDK(executableFile.getPath(), sdkType);
if (sdk != null) {
SdkConfigurationUtil.setDirectoryProjectSdk(project, sdk);
return;
}
}
}
// default
SdkConfigurationUtil.configureDirectoryProjectSdk(project, new PreferredSdkComparator(), sdkType);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:PythonSdkConfigurator.java
示例19: consume
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的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
示例20: showCustomCreateUI
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; //导入依赖的package包/类
@Override
public void showCustomCreateUI(final SdkModel sdkModel,
final JComponent parentComponent,
final Consumer<Sdk> sdkCreatedCallback) {
customImpl: {
final Collection<String> homePaths = suggestHomePaths();
if(homePaths.isEmpty()) {
break customImpl;
}
final String home = homePaths.iterator().next();
final File homePath = new File(home);
if(!homePath.isDirectory()) {
break customImpl;
}
if(!checkDependency(sdkModel)) {
if(Messages.showOkCancelDialog(parentComponent,
getUnsatisfiedDependencyMessage(), "Cannot Create SDK",
Messages.getWarningIcon()) != Messages.OK) {
return;
}
if(fixDependency(sdkModel, sdkCreatedCallback) == null) {
return;
}
}
final String newSdkName = SdkConfigurationUtil.createUniqueSdkName(this, home, Arrays.asList(sdkModel.getSdks()));
final ProjectJdkImpl newJdk = new ProjectJdkImpl(newSdkName, this);
newJdk.setHomePath(home);
sdkCreatedCallback.consume(newJdk);
return;
}
super.showCustomCreateUI(sdkModel, parentComponent, sdkCreatedCallback);
}
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:42,代码来源:DefracSdkType.java
注:本文中的com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论