本文整理汇总了Java中com.intellij.openapi.roots.ModifiableRootModel.inheritSdk方法的典型用法代码示例。如果您正苦于以下问题:Java ModifiableRootModel.inheritSdk方法的具体用法?Java ModifiableRootModel.inheritSdk怎么用?Java ModifiableRootModel.inheritSdk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ModifiableRootModel
的用法示例。
在下文中一共展示了ModifiableRootModel.inheritSdk方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupRootModel
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void setupRootModel(@NotNull final ModifiableRootModel rootModel) throws ConfigurationException {
if (mySdk == null) {
rootModel.inheritSdk();
} else {
rootModel.setSdk(mySdk);
}
// Make the entire module directory a source root.
ContentEntry contentEntry = doAddContentEntry(rootModel);
if (contentEntry != null) {
final VirtualFile file = contentEntry.getFile();
if (file != null && file.isDirectory())
contentEntry.addSourceFolder(file, false);
}
}
示例2: setupRootModel
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
final Project project = rootModel.getProject();
final VirtualFile root = createAndGetContentEntry();
rootModel.addContentEntry(root);
// todo this should be moved to generic ModuleBuilder
if (myJdk != null){
rootModel.setSdk(myJdk);
} else {
rootModel.inheritSdk();
}
MavenUtil.runWhenInitialized(project, new DumbAwareRunnable() {
public void run() {
if (myEnvironmentForm != null) {
myEnvironmentForm.setData(MavenProjectsManager.getInstance(project).getGeneralSettings());
}
new MavenModuleBuilderHelper(myProjectId, myAggregatorProject, myParentProject, myInheritGroupId,
myInheritVersion, myArchetype, myPropertiesToCreateByArtifact, "Create new Maven module").configure(project, root, false);
}
});
}
示例3: createModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public Module createModule(String moduleName, ModuleType moduleType) {
Module module = moduleModel.findModuleByName(moduleName);
if (module == null) {
File imlFile = new File(imlDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
removeImlFile(imlFile);
module = moduleModel.newModule(imlFile.getPath(), moduleType.getId());
module.setOption(EXTERNAL_SYSTEM_ID_KEY, EXTERNAL_SYSTEM_ID_VALUE);
}
module.setOption(Module.ELEMENT_TYPE, moduleType.getId());
ModifiableRootModel modifiableModel =
ModuleRootManager.getInstance(module).getModifiableModel();
modules.put(module.getName(), modifiableModel);
modifiableModel.clear();
modifiableModel.inheritSdk();
CompilerModuleExtension compilerSettings =
modifiableModel.getModuleExtension(CompilerModuleExtension.class);
if (compilerSettings != null) {
compilerSettings.inheritCompilerOutputPath(false);
}
return module;
}
示例4: setSdk
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public void setSdk(final Sdk newJDK) {
final ModifiableRootModel model = getModel();
if (newJDK != null) {
model.setSdk(newJDK);
}
else {
model.inheritSdk();
}
if (myPanel != null) {
myPanel.forceInitFromModel();
}
}
示例5: setupRootModel
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public void setupRootModel(final ModifiableRootModel rootModel) throws ConfigurationException {
// false for the module automatically created in a new project
if (myJdk != null) {
rootModel.setSdk(myJdk);
}
else {
rootModel.inheritSdk();
}
doAddContentEntry(rootModel);
}
示例6: setupRootModel
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void setupRootModel(final @NotNull ModifiableRootModel rootModel) throws ConfigurationException {
final Project project = rootModel.getProject();
// in IntelliJ wizard user is able to choose SDK (i.e. for "java library" module), so set it
if (myJdk != null){
rootModel.setSdk(myJdk);
} else {
rootModel.inheritSdk();
}
if (myProject == null) {
project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);
}
StartupManager.getInstance(project).runWhenProjectIsInitialized(new DumbAwareRunnable() {
@Override
public void run() {
DumbService.getInstance(project).smartInvokeLater(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
if (myProject == null) {
myWizardState.putSdkDependentParams();
myWizardState.put(ATTR_PROJECT_LOCATION, project.getBasePath());
AssetStudioAssetGenerator assetGenerator = new AssetStudioAssetGenerator(myWizardState);
NewProjectWizard.createProject(myWizardState, project, assetGenerator);
}
else {
myWizardState.put(ATTR_MODULE_NAME, getName());
createModule();
}
}
});
}
});
}
});
}
示例7: configureJdk
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static void configureJdk(Element cfg, @NotNull Module module) {
String jdkName = cfg.getChildTextTrim("jdkName");
if (StringUtil.isEmptyOrSpaces(jdkName)) return;
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
String currentSdkName = null;
Sdk sdk = rootManager.getSdk();
if (sdk != null) {
currentSdkName = sdk.getName();
}
if (!jdkName.equals(currentSdkName)) {
ModifiableRootModel model = rootManager.getModifiableModel();
if (jdkName.equals(ProjectRootManager.getInstance(model.getProject()).getProjectSdkName())) {
model.inheritSdk();
}
else {
Sdk jdk = ProjectJdkTable.getInstance().findJdk(jdkName);
if (jdk != null) {
model.setSdk(jdk);
}
else {
model.setInvalidSdk(jdkName, JavaSdk.getInstance().getName());
}
}
model.commit();
}
}
示例8: configureModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
model.inheritSdk();
model.commit();
}
示例9: setupRootModel
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static void setupRootModel(
ProjectDescriptor projectDescriptor,
final ModuleDescriptor descriptor,
final ModifiableRootModel rootModel,
final Map<LibraryDescriptor, Library> projectLibs) {
final CompilerModuleExtension compilerModuleExtension =
rootModel.getModuleExtension(CompilerModuleExtension.class);
compilerModuleExtension.setExcludeOutput(true);
rootModel.inheritSdk();
//Module root model seems to store .iml files root dependencies. (src, test, lib)
logger.info("Starting setupRootModel in ProjectFromSourcesBuilderImplModified");
final Set<File> contentRoots = descriptor.getContentRoots();
for (File contentRoot : contentRoots) {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile moduleContentRoot =
lfs.refreshAndFindFileByPath(
FileUtil.toSystemIndependentName(contentRoot.getPath()));
if (moduleContentRoot != null) {
final ContentEntry contentEntry = rootModel.addContentEntry(moduleContentRoot);
final Collection<DetectedSourceRoot> sourceRoots =
descriptor.getSourceRoots(contentRoot);
for (DetectedSourceRoot srcRoot : sourceRoots) {
final String srcpath =
FileUtil.toSystemIndependentName(srcRoot.getDirectory().getPath());
final VirtualFile sourceRoot = lfs.refreshAndFindFileByPath(srcpath);
if (sourceRoot != null) {
contentEntry.addSourceFolder(
sourceRoot,
shouldBeTestRoot(srcRoot.getDirectory()),
getPackagePrefix(srcRoot));
}
}
}
}
logger.info("Inherits compiler output path from project");
compilerModuleExtension.inheritCompilerOutputPath(true);
logger.info("Starting to create module level libraries");
final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
for (LibraryDescriptor libDescriptor :
ModuleInsight.getLibraryDependencies(
descriptor, projectDescriptor.getLibraries())) {
final Library projectLib = projectLibs.get(libDescriptor);
if (projectLib != null) {
rootModel.addLibraryEntry(projectLib);
} else {
// add as module library
final Collection<File> jars = libDescriptor.getJars();
for (File file : jars) {
Library library = moduleLibraryTable.createLibrary();
Library.ModifiableModel modifiableModel = library.getModifiableModel();
modifiableModel.addRoot(
VfsUtil.getUrlForLibraryRoot(file), OrderRootType.CLASSES);
modifiableModel.commit();
}
}
}
logger.info("Ending setupRootModel in ProjectFromSourcesBuilderImplModified");
}