本文整理汇总了Java中com.intellij.openapi.roots.ModifiableRootModel.commit方法的典型用法代码示例。如果您正苦于以下问题:Java ModifiableRootModel.commit方法的具体用法?Java ModifiableRootModel.commit怎么用?Java ModifiableRootModel.commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ModifiableRootModel
的用法示例。
在下文中一共展示了ModifiableRootModel.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static Module createModule(
ProjectDescriptor projectDescriptor,
final ModuleDescriptor descriptor,
final Map<LibraryDescriptor, Library> projectLibs,
final ModifiableModuleModel moduleModel) {
logger.info("Starting createModule in ProjectFromSourcesBuilderImplModified");
final String moduleFilePath = descriptor.computeModuleFilePath();
ModuleBuilder.deleteModuleFile(moduleFilePath);
final Module module =
moduleModel.newModule(moduleFilePath, descriptor.getModuleType().getId());
final ModifiableRootModel modifiableModel =
ModuleRootManager.getInstance(module).getModifiableModel();
setupRootModel(projectDescriptor, descriptor, modifiableModel, projectLibs);
descriptor.updateModuleConfiguration(module, modifiableModel);
modifiableModel.commit();
logger.info("ending createModule in ProjectFromSourcesBuilderImplModified");
return module;
}
示例2: addLibrary
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private void addLibrary() {
final LibrariesContainer.LibraryLevel level = myNameAndLevelPanel.getLibraryLevel();
AccessToken token = WriteAction.start();
try {
final Module module = myModulesComboBox.getSelectedModule();
final String libraryName = myNameAndLevelPanel.getLibraryName();
if (level == LibrariesContainer.LibraryLevel.MODULE) {
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
LibrariesContainerFactory.createContainer(modifiableModel).createLibrary(libraryName, level, myRoots);
modifiableModel.commit();
}
else {
final Library library = LibrariesContainerFactory.createContainer(myProject).createLibrary(libraryName, level, myRoots);
if (module != null) {
ModuleRootModificationUtil.addDependency(module, library);
}
}
}
finally {
token.finish();
}
}
示例3: cleanUpAndroidModuleWithoutVariants
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static void cleanUpAndroidModuleWithoutVariants(@NotNull Module module) {
// Remove Android facet, otherwise the IDE will try to build the module, and fail. The facet may have been added in a previous
// successful commit.
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
ModifiableFacetModel facetModel = FacetManager.getInstance(module).createModifiableModel();
facetModel.removeFacet(facet);
facetModel.commit();
}
// Clear all source and exclude folders.
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
for (ContentEntry contentEntry : rootModel.getContentEntries()) {
contentEntry.clearSourceFolders();
contentEntry.clearExcludeFolders();
}
rootModel.commit();
}
示例4: doLoadModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static Module doLoadModule(@NotNull String path, @NotNull Project project) throws IOException, JDOMException, InvalidDataException {
Module module;
AccessToken token = WriteAction.start();
try {
module = ModuleManager.getInstance(project).newModule(path + '/' + EclipseProjectFinder.findProjectName(path) + IdeaXml.IML_EXT, StdModuleTypes.JAVA.getId());
}
finally {
token.finish();
}
replaceRoot(path, EclipseXml.DOT_CLASSPATH_EXT, project);
ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
new EclipseClasspathConverter(module).readClasspath(rootModel);
token = WriteAction.start();
try {
rootModel.commit();
}
finally {
token.finish();
}
return module;
}
示例5: run
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void run() {
if (module.isDisposed() || module.getProject().isDisposed()) {
logger.warn("Either the module '" + module.getName() + "' or project '" + module.getProject().getName() + " has been disposed." +
" Cannot add root '" + jarDirectory.getPath() + " as a project and module dependency.");
return;
}
LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(module.getProject());
LibraryTable.ModifiableModel projectLibraryModel = projectLibraryTable.getModifiableModel();
logger.debug("Adding '" + jarDirectory + "' as a dependency of the project '" + module.getProject().getName() + "'.");
// Create library and add it as a project level dependency.
Library processingLibrary = createProcessingCoreDependencyLibrary(projectLibraryModel);
projectLibraryModel.commit();
logger.debug("Change committed to the project library table.");
logger.debug("Adding '" + jarDirectory + "' as a dependency of the module '" + module.getProject().getName() + "'.");
// Add library as the module level dependency.
ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
rootModel.addLibraryEntry(processingLibrary);
rootModel.commit();
logger.debug("Change committed to the module library table.");
}
示例6: applyFix
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull CommonProblemDescriptor descriptor) {
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
for (OrderEntry entry : model.getOrderEntries()) {
if (entry instanceof ModuleOrderEntry) {
final Module mDependency = ((ModuleOrderEntry)entry).getModule();
if (Comparing.equal(mDependency, myDependency)) {
model.removeOrderEntry(entry);
break;
}
}
}
model.commit();
}
示例7: fixModuleName
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private void fixModuleName(Module module) {
List<RunConfiguration> configurations = RunManager.getInstance(module.getProject()).getAllConfigurationsList();
for (RunConfiguration configuration : configurations) {
if (configuration instanceof ModuleBasedConfiguration) {
((ModuleBasedConfiguration)configuration).getConfigurationModule().setModule(module);
}
}
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
for (WizardInputField field : myAdditionalFields) {
ProjectTemplateParameterFactory factory = WizardInputField.getFactoryById(field.getId());
factory.applyResult(field.getValue(), model);
}
model.commit();
}
示例8: initModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
protected void initModule(Module module) {
final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
final ModifiableRootModel rootModel = rootManager.getModifiableModel();
for (String contentRoot : myContentRoots) {
final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(contentRoot);
Assert.assertNotNull("cannot find content root: " + contentRoot, virtualFile);
final ContentEntry contentEntry = rootModel.addContentEntry(virtualFile);
for (String sourceRoot: mySourceRoots) {
String s = contentRoot + "/" + sourceRoot;
VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByPath(s);
if (vf == null) {
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(sourceRoot);
if (file != null && VfsUtilCore.isAncestor(virtualFile, file, false)) vf = file;
}
// assert vf != null : "cannot find source root: " + sourceRoot;
if (vf != null) {
contentEntry.addSourceFolder(vf, false);
}
else {
// files are not created yet
contentEntry.addSourceFolder(VfsUtilCore.pathToUrl(s), false);
}
}
}
setupRootModel(rootModel);
rootModel.commit();
}
示例9: setupModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
protected void setupModule(Module module) throws ConfigurationException {
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
setupRootModel(modifiableModel);
for (ModuleConfigurationUpdater updater : myUpdaters) {
updater.update(module, modifiableModel);
}
modifiableModel.commit();
setProjectType(module);
}
示例10: setUpModuleDependencies
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private void setUpModuleDependencies() {
// Make module depend on myLibModule.
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(myModule);
ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
try {
rootModel.addModuleOrderEntry(myLibModule);
}
finally {
rootModel.commit();
}
}
示例11: 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();
}
}
示例12: tryToSetUpGroovyFacetOnTheFly
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public static boolean tryToSetUpGroovyFacetOnTheFly(final Module module) {
final Project project = module.getProject();
GroovyConfigUtils utils = GroovyConfigUtils.getInstance();
final Library[] libraries = utils.getAllSDKLibraries(project);
if (libraries.length > 0) {
final Library library = libraries[0];
int result = Messages
.showOkCancelDialog(
GroovyBundle.message("groovy.like.library.found.text", module.getName(), library.getName(), utils.getSDKLibVersion(library)),
GroovyBundle.message("groovy.like.library.found"), JetgroovyIcons.Groovy.Groovy_32x32);
if (result == Messages.OK) {
AccessToken accessToken = WriteAction.start();
try {
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
LibraryOrderEntry entry = model.addLibraryEntry(libraries[0]);
LibrariesUtil.placeEntryToCorrectPlace(model, entry);
model.commit();
return true;
}
finally {
accessToken.finish();
}
}
}
return false;
}
示例13: addGrapeDependencies
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private void addGrapeDependencies(List<VirtualFile> jars) {
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
final LibraryTable.ModifiableModel tableModel = model.getModuleLibraryTable().getModifiableModel();
for (VirtualFile jar : jars) {
final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(jar);
if (jarRoot != null) {
OrderRootType rootType = OrderRootType.CLASSES;
String libName = "Grab:" + jar.getName();
for (String classifier : ContainerUtil.ar("sources", "source", "src")) {
if (libName.endsWith("-" + classifier + ".jar")) {
rootType = OrderRootType.SOURCES;
libName = StringUtil.trimEnd(libName, "-" + classifier + ".jar") + ".jar";
}
}
Library library = tableModel.getLibraryByName(libName);
if (library == null) {
library = tableModel.createLibrary(libName);
}
final Library.ModifiableModel libModel = library.getModifiableModel();
for (String url : libModel.getUrls(rootType)) {
libModel.removeRoot(url, rootType);
}
libModel.addRoot(jarRoot, rootType);
libModel.commit();
}
}
tableModel.commit();
model.commit();
}
示例14: configureModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
model.inheritSdk();
model.commit();
}
示例15: doCommitModel
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
protected void doCommitModel(@NotNull ModifiableRootModel rootModel) {
rootModel.commit();
}