本文整理汇总了Java中com.intellij.openapi.projectRoots.Sdk类的典型用法代码示例。如果您正苦于以下问题:Java Sdk类的具体用法?Java Sdk怎么用?Java Sdk使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sdk类属于com.intellij.openapi.projectRoots包,在下文中一共展示了Sdk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAndroidSdkPath
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
public static String getAndroidSdkPath(Project project) {
ModuleManager manager = ModuleManager.getInstance(project);
String androidSdkPath = null;
for (Module module : manager.getModules()) {
if (androidSdkPath != null) {
break;
}
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && sdk.getHomePath() != null) {
File file = new File(sdk.getHomePath());
String[] contents = file.list();
if (contents != null) {
for (String path : contents) {
if (path.equals("build-tools")) {
androidSdkPath = sdk.getHomePath();
break;
}
}
}
}
}
return androidSdkPath;
}
示例2: selectSdk
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
private void selectSdk(@NotNull final Project project) {
Validate.notNull(project);
final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
final Sdk projectSdk = projectRootManager.getProjectSdk();
if (null == projectSdk) {
return;
}
if (StringUtils.isNotBlank(projectSdk.getVersionString())) {
final JavaSdkVersion sdkVersion = JdkVersionUtil.getVersion(projectSdk.getVersionString());
final LanguageLevelProjectExtension languageLevelExt = LanguageLevelProjectExtension.getInstance(project);
if (sdkVersion.getMaxLanguageLevel() != languageLevelExt.getLanguageLevel()) {
languageLevelExt.setLanguageLevel(sdkVersion.getMaxLanguageLevel());
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:ImportProjectProgressModalWindow.java
示例3: getWizard
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
private AddModuleWizard getWizard(final Project project) throws ConfigurationException {
final HybrisProjectImportProvider provider = getHybrisProjectImportProvider();
final String basePath = project.getBasePath();
final String projectName = project.getName();
final Sdk jdk = ProjectRootManager.getInstance(project).getProjectSdk();
final String compilerOutputUrl = CompilerProjectExtension.getInstance(project).getCompilerOutputUrl();
final HybrisProjectSettings settings = HybrisProjectSettingsComponent.getInstance(project).getState();
final AddModuleWizard wizard = new AddModuleWizard(null, basePath, provider) {
protected void init() {
// non GUI mode
}
};
final WizardContext wizardContext = wizard.getWizardContext();
wizardContext.setProjectJdk(jdk);
wizardContext.setProjectName(projectName);
wizardContext.setCompilerOutputDirectory(compilerOutputUrl);
final StepSequence stepSequence = wizard.getSequence();
for (ModuleWizardStep step : stepSequence.getAllSteps()) {
if (step instanceof NonGuiSupport) {
((NonGuiSupport) step).nonGuiModeImport(settings);
}
}
return wizard;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:ProjectRefreshAction.java
示例4: addDetectedSdk
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的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;
}
示例5: beforeProjectGenerated
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
@Nullable
@Override
public BooleanFunction<PythonProjectGenerator> beforeProjectGenerated(@Nullable Sdk sdk) {
return generator -> {
final List<Integer> enrolledCoursesIds = myGenerator.getEnrolledCoursesIds();
final Course course = myGenerator.getSelectedCourse();
if (course == null || !(course instanceof RemoteCourse)) return true;
if (((RemoteCourse)course).getId() > 0 && !enrolledCoursesIds.contains(((RemoteCourse)course).getId())) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
return StudyUtils.execCancelable(() -> EduStepicConnector.enrollToCourse(((RemoteCourse)course).getId(),
StudySettings.getInstance().getUser()));
}, "Creating Course", true, ProjectManager.getInstance().getDefaultProject());
}
return true;
};
}
示例6: update
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
e.getPresentation().setVisible(false);
e.getPresentation().setEnabled(false);
Project project = e.getData(LangDataKeys.PROJECT);
if (project != null) {
for (Module module : ModuleManager.getInstance(project).getModules()) {
e.getPresentation().setVisible(true);
Sdk luaSdk = LuaSdkType.findLuaSdk(module);
if (luaSdk == null) continue;
final String homePath = luaSdk.getHomePath();
if (homePath == null) continue;
if (LuaSdkType.getByteCodeCompilerExecutable(homePath).exists()) {
e.getPresentation().setEnabled(true);
break;
}
}
}
}
示例7: actionPerformed
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final File projectDir = new File(ProjectUtil.getBaseDir(), INTRODUCTION_FOLDER);
if (projectDir.exists()) {
ProjectUtil.openProject(projectDir.getPath(), null, false);
}
else {
final PyStudyDirectoryProjectGenerator generator = new PyStudyDirectoryProjectGenerator();
CourseInfo introCourse = getIntroCourseInfo(generator.getCourses());
if (introCourse == null) {
return;
}
final GenerateProjectCallback callback = new GenerateProjectCallback();
final ProjectSpecificSettingsStep step = new ProjectSpecificSettingsStep(generator, callback);
step.createPanel(); // initialize panel to set location
step.setLocation(projectDir.toString());
generator.setSelectedCourse(introCourse);
final Project project = ProjectManager.getInstance().getDefaultProject();
final List<Sdk> sdks = PyConfigurableInterpreterList.getInstance(project).getAllPythonSdks();
Sdk sdk = sdks.isEmpty() ? null : sdks.iterator().next();
step.setSdk(sdk);
callback.consume(step);
}
}
示例8: jdkNameChanged
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的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();
}
}
示例9: doStartRemoteProcess
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
protected PyRemoteProcessHandlerBase doStartRemoteProcess(@NotNull Sdk sdk,
@NotNull final GeneralCommandLine commandLine,
@NotNull final PythonRemoteInterpreterManager manager,
@Nullable final Project project,
@Nullable PyRemotePathMapper pathMapper)
throws ExecutionException {
SdkAdditionalData data = sdk.getSdkAdditionalData();
assert data instanceof PyRemoteSdkAdditionalDataBase;
final PyRemoteSdkAdditionalDataBase pyRemoteSdkAdditionalDataBase = (PyRemoteSdkAdditionalDataBase)data;
final PyRemotePathMapper extendedPathMapper = manager.setupMappings(project, pyRemoteSdkAdditionalDataBase, pathMapper);
try {
return PyRemoteProcessStarterManagerUtil
.getManager(pyRemoteSdkAdditionalDataBase).startRemoteProcess(project, commandLine, manager, pyRemoteSdkAdditionalDataBase,
extendedPathMapper);
}
catch (InterruptedException e) {
throw new ExecutionException(e);
}
}
示例10: initArtifacts
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
@Override
public void initArtifacts(Project project, GenerationOptions genOptions, CompositeGenerator generator) {
final Collection<? extends Artifact> artifacts =
ArtifactManager.getInstance(project).getArtifactsByType(JavaFxApplicationArtifactType.getInstance());
if (artifacts.isEmpty()) return;
final Sdk[] jdks = BuildProperties.getUsedJdks(project);
Sdk javaSdk = null;
for (Sdk jdk : jdks) {
if (jdk.getSdkType() instanceof JavaSdkType) {
javaSdk = jdk;
break;
}
}
if (javaSdk != null) {
final Tag taskdef = new Tag("taskdef",
Couple.of("resource", "com/sun/javafx/tools/ant/antlib.xml"),
Couple.of("uri", "javafx:com.sun.javafx.tools.ant"),
Couple.of("classpath",
BuildProperties
.propertyRef(BuildProperties.getJdkHomeProperty(javaSdk.getName())) +
"/lib/ant-javafx.jar"));
generator.add(taskdef);
}
}
示例11: updateActiveSdks
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
public static void updateActiveSdks(@NotNull final Project project, final int delay) {
final Set<Sdk> sdksToUpdate = new HashSet<Sdk>();
for (Module module : ModuleManager.getInstance(project).getModules()) {
final Sdk sdk = PythonSdkType.findPythonSdk(module);
if (sdk != null) {
final SdkTypeId sdkType = sdk.getSdkType();
if (sdkType instanceof PythonSdkType) {
sdksToUpdate.add(sdk);
}
}
}
// NOTE: everything is run later on the AWT thread
if (!sdksToUpdate.isEmpty()) {
updateSdks(project, delay, sdksToUpdate);
}
}
示例12: createContentEntry
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
protected void createContentEntry(@NotNull final Module module, @NotNull final VirtualFile srcRoot) {
updateModel(module, new Consumer<ModifiableRootModel>() {
@Override
public void consume(ModifiableRootModel model) {
Sdk sdk = getSdk();
if (sdk != null) {
model.setSdk(sdk);
}
ContentEntry contentEntry = model.addContentEntry(srcRoot);
contentEntry.addSourceFolder(srcRoot, false);
configureModule(module, model, contentEntry);
}
});
}
示例13: testEditLibraryForModuleLoadFromXml
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的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);
}
示例14: SphinxDirectiveCompletionContributor
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
public SphinxDirectiveCompletionContributor() {
extend(CompletionType.BASIC, DIRECTIVE_PATTERN,
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
Sdk sdk = ProjectRootManager.getInstance(parameters.getPosition().getProject()).getProjectSdk();
if (sdk != null) {
for (String tag : RestUtil.SPHINX_DIRECTIVES) {
result.addElement(LookupElementBuilder.create(tag));
}
}
}
}
);
}
示例15: renameLibrary
import com.intellij.openapi.projectRoots.Sdk; //导入依赖的package包/类
private static void renameLibrary(final Sdk sdk, final String previousName) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
final LibraryTable.ModifiableModel libraryTableModel =
ModifiableModelsProvider.SERVICE.getInstance().getLibraryTableModifiableModel();
final Library library = libraryTableModel.getLibraryByName(PythonFacet.getFacetLibraryName(previousName));
if (library != null) {
final Library.ModifiableModel model = library.getModifiableModel();
model.setName(PythonFacet.getFacetLibraryName(sdk.getName()));
model.commit();
}
libraryTableModel.commit();
}
});
}
}, ModalityState.NON_MODAL);
}