當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。