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


Java ModuleRootManager.getModifiableModel方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.ModuleRootManager.getModifiableModel方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleRootManager.getModifiableModel方法的具体用法?Java ModuleRootManager.getModifiableModel怎么用?Java ModuleRootManager.getModifiableModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.ModuleRootManager的用法示例。


在下文中一共展示了ModuleRootManager.getModifiableModel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanUpAndroidModuleWithoutVariants

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的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

示例2: initModule

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的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

示例3: setUpModuleDependencies

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的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

示例4: configureJdk

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的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

示例5: excludeOutputFolders

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
private static void excludeOutputFolders(@NotNull AndroidFacet facet) {
  IdeaAndroidProject androidProject = facet.getIdeaAndroidProject();
  if (androidProject == null) {
    return;
  }
  File buildFolderPath = androidProject.getDelegate().getBuildFolder();
  if (!buildFolderPath.isDirectory()) {
    return;
  }

  Module module = facet.getModule();
  if (module.getProject().isDisposed()) {
    return;
  }

  ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
  ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();

  try {
    ContentEntry[] contentEntries = rootModel.getContentEntries();
    ContentEntry parent = findParentContentEntry(buildFolderPath, contentEntries);
    if (parent == null) {
      rootModel.dispose();
      return;
    }

    File[] outputFolderPaths = notNullize(buildFolderPath.listFiles());
    if (outputFolderPaths.length == 0) {
      rootModel.dispose();
      return;
    }

    for (File outputFolderPath : outputFolderPaths) {
      if (!androidProject.shouldManuallyExclude(outputFolderPath)) {
        continue;
      }
      boolean alreadyExcluded = false;
      for (VirtualFile excluded : parent.getExcludeFolderFiles()) {
        if (filesEqual(outputFolderPath, virtualToIoFile(excluded))) {
          alreadyExcluded = true;
          break;
        }
      }
      if (!alreadyExcluded) {
        parent.addExcludeFolder(pathToIdeaUrl(outputFolderPath));
      }
    }
  }
  finally {
    if (!rootModel.isDisposed()) {
      rootModel.commit();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:55,代码来源:PostProjectBuildTasksExecutor.java


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