当前位置: 首页>>代码示例>>Java>>正文


Java ModifiableRootModel.commit方法代码示例

本文整理汇总了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;
}
 
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:21,代码来源:ProjectFromSourcesBuilderImplModified.java

示例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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CreateLibraryFromFilesDialog.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaProjectDataService.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:EclipseEmlTest.java

示例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.");
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:29,代码来源:AddDependenciesToProject.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:UnnecessaryModuleDependencyInspection.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:TemplateModuleBuilder.java

示例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();
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ModuleFixtureBuilderImpl.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ModuleBuilder.java

示例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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ConflictSetTest.java

示例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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:MavenIdeaPluginConfigurer.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:GroovyFacetUtil.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:GrabDependencies.java

示例14: configureModule

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
    model.inheritSdk();
    model.commit();
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:6,代码来源:LuaLightProjectDescriptor.java

示例15: doCommitModel

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
protected void doCommitModel(@NotNull ModifiableRootModel rootModel) {
  rootModel.commit();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CodeInsightTestCase.java


注:本文中的com.intellij.openapi.roots.ModifiableRootModel.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。