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


Java ModifiableRootModel.addContentEntry方法代码示例

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


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

示例1: setupRootModel

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
    super.setupRootModel(rootModel);

    addListener(new ModuleBuilderListener() {
        @Override
        public void moduleCreated(@NotNull Module module) {
            setMuleFramework(module);
        }
    });

    setMuleFacet(rootModel.getModule());

    final Project project = rootModel.getProject();
    final VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);

    //Check if this is a module and has parent
    final MavenId parentId = (this.getParentProject() != null ? this.getParentProject().getMavenId() : null);

    MavenUtil.runWhenInitialized(project, (DumbAwareRunnable) () -> {
        new MuleMavenProjectBuilderHelper().configure(project, getProjectId(), muleVersion, root, parentId);
    });
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:25,代码来源:MuleMavenModuleBuilder.java

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

示例3: configure

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void configure(
    @NotNull final ModifiableRootModel modifiableRootModel,
    @NotNull final HybrisModuleDescriptor moduleDescriptor
) {
    Validate.notNull(modifiableRootModel);
    Validate.notNull(moduleDescriptor);

    final ContentEntry contentEntry = modifiableRootModel.addContentEntry(VfsUtil.pathToUrl(
        moduleDescriptor.getRootDirectory().getAbsolutePath()
    ));


    this.configureCommonRoots(moduleDescriptor, contentEntry);
    if (moduleDescriptor.getRequiredExtensionNames().contains(HybrisConstants.HMC_EXTENSION_NAME)) {
        this.configureAdditionalRoots(
            moduleDescriptor,
            HMC_MODULE_DIRECTORY,
            contentEntry,
            moduleDescriptor.getRootDirectory()
        );
    }
    this.configureAdditionalRoots(
        moduleDescriptor,
        HAC_MODULE_DIRECTORY,
        contentEntry,
        moduleDescriptor.getRootDirectory()
    );
    this.configureWebRoots(moduleDescriptor, contentEntry, moduleDescriptor.getRootDirectory());
    this.configureCommonWebRoots(moduleDescriptor, contentEntry);
    this.configureAcceleratorAddonRoots(moduleDescriptor, contentEntry);
    this.configureBackOfficeRoots(moduleDescriptor, contentEntry);
    this.configurePlatformRoots(moduleDescriptor, contentEntry);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:35,代码来源:RegularContentRootConfigurator.java

示例4: setupRootModel

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void setupRootModel(final ModifiableRootModel modifiableRootModel) throws ConfigurationException {
    super.setupRootModel(modifiableRootModel);

    String contentEntryPath = getContentEntryPath();
    if (StringUtil.isEmpty(contentEntryPath)) {
        throw new ConfigurationException("There is no valid content entry path associated with the module. Unable to generate template directory structure.");
    }

    LocalFileSystem fileSystem = getInstance();
    VirtualFile modelContentRootDir = fileSystem.refreshAndFindFileByIoFile(new File(contentEntryPath));

    if (modelContentRootDir == null) {
        throw new ConfigurationException("Model content root directory '" + contentEntryPath + "' could not be found. Unable to generate template directory structure.");
    }

    ContentEntry content = modifiableRootModel.addContentEntry(modelContentRootDir);

    try {
        VirtualFile sourceCodeDir = VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/java");
        VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/java/com/processing/sketch");

        VirtualFile resources = VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/resources");

        content.addSourceFolder(sourceCodeDir, false);
        content.addSourceFolder(resources, JavaResourceRootType.RESOURCE, JavaResourceRootType.RESOURCE.createDefaultProperties());
    } catch (IOException io) {
        logger.error("Unable to generate template directory structure:", io);
        throw new ConfigurationException("Unable to generate template directory structure.");
    }

    VirtualFile sketchPackagePointer = getInstance().refreshAndFindFileByPath(getContentEntryPath() + "/src/main/java/com/processing/sketch");

    if (generateTemplateSketchClass) {
        ApplicationManager.getApplication().runWriteAction(new CreateSketchTemplateFile(sketchPackagePointer));
    }
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:38,代码来源:ProcessingModuleBuilder.java

示例5: setupRootModel

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
    super.setupRootModel(rootModel);

    setMuleFacet(rootModel.getModule());

    final Project project = rootModel.getProject();
    final VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);
    MavenUtil.runWhenInitialized(project, (DumbAwareRunnable) () -> new MuleDomainMavenProjectBuilderHelper().configure(project, getProjectId(), muleVersion, root));
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:12,代码来源:MuleDomainMavenModuleBuilder.java

示例6: findOrCreateContentRoot

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@NotNull
private static ContentEntry findOrCreateContentRoot(@NotNull ModifiableRootModel model, @NotNull String path) {
  ContentEntry[] entries = model.getContentEntries();

  for (ContentEntry entry : entries) {
    VirtualFile file = entry.getFile();
    if (file == null) {
      continue;
    }
    if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(path)) {
      return entry;
    }
  }
  return model.addContentEntry(toVfsUrl(path));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ContentRootDataService.java

示例7: 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

示例8: doAddContentEntry

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
protected @Nullable ContentEntry doAddContentEntry(ModifiableRootModel modifiableRootModel) {
  final String contentEntryPath = getContentEntryPath();
  if (contentEntryPath == null) return null;
  new File(contentEntryPath).mkdirs();
  final VirtualFile moduleContentRoot = LocalFileSystem.getInstance().refreshAndFindFileByPath(contentEntryPath.replace('\\', '/'));
  if (moduleContentRoot == null) return null;
  return modifiableRootModel.addContentEntry(moduleContentRoot);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ModuleBuilder.java

示例9: findOrCreateContentEntries

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
@NotNull
protected Collection<ContentEntry> findOrCreateContentEntries(@NotNull ModifiableRootModel model, @NotNull IdeaJavaProject javaProject) {
  List<ContentEntry> allEntries = Lists.newArrayList();
  for (JavaModuleContentRoot contentRoot : javaProject.getContentRoots()) {
    File rootDirPath = contentRoot.getRootDirPath();
    ContentEntry contentEntry = model.addContentEntry(pathToIdeaUrl(rootDirPath));
    allEntries.add(contentEntry);
  }
  return allEntries;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ContentRootModuleCustomizer.java

示例10: createProjectDataDirectoryModule

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
/**
 * Creates a module that includes the user's data directory.
 *
 * <p>This is useful to be able to edit the project view without IntelliJ complaining it's outside
 * the project.
 */
private void createProjectDataDirectoryModule(
    ModuleEditor moduleEditor, File projectDataDirectory, ModuleType moduleType) {
  Module module = moduleEditor.createModule(".project-data-dir", moduleType);
  ModifiableRootModel modifiableModel = moduleEditor.editModule(module);
  ContentEntry rootContentEntry =
      modifiableModel.addContentEntry(pathToUrl(projectDataDirectory));
  rootContentEntry.addExcludeFolder(pathToUrl(new File(projectDataDirectory, ".idea")));
  rootContentEntry.addExcludeFolder(
      pathToUrl(BlazeDataStorage.getProjectDataDir(importSettings)));
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:BlazeSyncTask.java

示例11: 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");
}
 
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:61,代码来源:ProjectFromSourcesBuilderImplModified.java

示例12: testRootsEditing

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public void testRootsEditing() {
  final MessageBusConnection connection = myProject.getMessageBus().connect();
  final ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  final MyModuleListener moduleListener = new MyModuleListener();
  connection.subscribe(ProjectTopics.MODULES, moduleListener);

  final Module moduleA;
  final Module moduleB;
  {
    final ModifiableModuleModel moduleModel = moduleManager.getModifiableModel();
    moduleA = moduleModel.newModule("a.iml", StdModuleTypes.JAVA.getId());
    moduleB = moduleModel.newModule("b.iml", StdModuleTypes.JAVA.getId());
    final ModifiableRootModel rootModelA = ModuleRootManager.getInstance(moduleA).getModifiableModel();
    final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
    rootModelB.addModuleOrderEntry(moduleA);

    final ContentEntry contentEntryA = rootModelA.addContentEntry(getVirtualFileInTestData("a"));
    contentEntryA.addSourceFolder(getVirtualFileInTestData("a/src"), false);
    final ContentEntry contentEntryB = rootModelB.addContentEntry(getVirtualFileInTestData("b"));
    contentEntryB.addSourceFolder(getVirtualFileInTestData("b/src"), false);

    ApplicationManager.getApplication().runWriteAction(() -> {
      ModifiableModelCommitter.multiCommit(new ModifiableRootModel[]{rootModelB, rootModelA}, moduleModel);
    });
  }

  final JavaPsiFacade psiManager = getJavaFacade();
  assertNull(psiManager.findClass("j.B", GlobalSearchScope.moduleWithDependenciesScope(moduleA)));
  assertNull(psiManager.findClass("q.A", GlobalSearchScope.moduleScope(moduleB)));

  assertNotNull(psiManager.findClass("q.A", GlobalSearchScope.moduleScope(moduleA)));
  assertNotNull(psiManager.findClass("q.A", GlobalSearchScope.moduleWithDependenciesScope(moduleB)));
  assertNotNull(psiManager.findClass("j.B", GlobalSearchScope.moduleScope(moduleB)));
  assertNotNull(psiManager.findClass("j.B", GlobalSearchScope.moduleWithDependenciesScope(moduleB)));

  moduleManager.disposeModule(moduleB);
  moduleManager.disposeModule(moduleA);
  moduleListener.assertCorrectEvents(new String[][]{{"+b", "+a"}, {"-b"}, {"-a"}});

  connection.disconnect();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:MultiModuleEditingTest.java

示例13: createTopLevelModule

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@VisibleForTesting
public static void createTopLevelModule(@NotNull Project project) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);

  File projectRootDir = getBaseDirPath(project);
  VirtualFile contentRoot = findFileByIoFile(projectRootDir, true);

  if (contentRoot != null) {
    File moduleFile = new File(projectRootDir, projectRootDir.getName() + ".iml");
    Module module = moduleManager.newModule(moduleFile.getPath(), JAVA.getId());

    // This prevents the balloon "Unsupported Modules detected".
    module.setOption(EXTERNAL_SYSTEM_ID_KEY, GRADLE_SYSTEM_ID.getId());

    ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
    model.addContentEntry(contentRoot);
    model.commit();

    FacetManager facetManager = FacetManager.getInstance(module);
    ModifiableFacetModel facetModel = facetManager.createModifiableModel();
    try {
      AndroidGradleFacet gradleFacet = AndroidGradleFacet.getInstance(module);
      if (gradleFacet == null) {
        // Add "gradle" facet, to avoid balloons about unsupported compilation of modules.
        gradleFacet = facetManager.createFacet(AndroidGradleFacet.getFacetType(), AndroidGradleFacet.NAME, null);
        facetModel.addFacet(gradleFacet);
      }
      gradleFacet.getConfiguration().GRADLE_PROJECT_PATH = GRADLE_PATH_SEPARATOR;

      // Add "android" facet to avoid the balloon "Android Framework detected".
      AndroidFacet androidFacet = AndroidFacet.getInstance(module);
      if (androidFacet == null) {
        androidFacet = facetManager.createFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null);
        facetModel.addFacet(androidFacet);
      }

      // This is what actually stops Studio from showing the balloon.
      androidFacet.getProperties().ALLOW_USER_CONFIGURATION = false;
    }
    finally {
      facetModel.commit();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:NewProjectImportGradleSyncListener.java

示例14: createContentEntries

import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public static void createContentEntries(
    Project project,
    WorkspaceRoot workspaceRoot,
    ProjectViewSet projectViewSet,
    BlazeProjectData blazeProjectData,
    DirectoryStructure rootDirectoryStructure,
    ModifiableRootModel modifiableRootModel) {
  ImportRoots importRoots =
      ImportRoots.builder(workspaceRoot, Blaze.getBuildSystem(project))
          .add(projectViewSet)
          .build();
  Collection<WorkspacePath> rootDirectories = importRoots.rootDirectories();
  Collection<WorkspacePath> excludeDirectories = importRoots.excludeDirectories();
  Multimap<WorkspacePath, WorkspacePath> excludesByRootDirectory =
      sortExcludesByRootDirectory(rootDirectories, excludeDirectories);

  SourceTestConfig testConfig = new SourceTestConfig(projectViewSet);
  SourceFolderProvider provider = SourceFolderProvider.getSourceFolderProvider(blazeProjectData);

  List<ContentEntry> contentEntries = Lists.newArrayList();
  for (WorkspacePath rootDirectory : rootDirectories) {
    File rootFile = workspaceRoot.fileForPath(rootDirectory);
    ContentEntry contentEntry =
        modifiableRootModel.addContentEntry(UrlUtil.pathToUrl(rootFile.getPath()));
    contentEntries.add(contentEntry);

    for (WorkspacePath exclude : excludesByRootDirectory.get(rootDirectory)) {
      File excludeFolder = workspaceRoot.fileForPath(exclude);
      contentEntry.addExcludeFolder(UrlUtil.fileToIdeaUrl(excludeFolder));
    }

    ImmutableMap<File, SourceFolder> sourceFolders =
        provider.initializeSourceFolders(contentEntry);
    SourceFolder rootSource = sourceFolders.get(rootFile);
    walkFileSystem(
        workspaceRoot,
        testConfig,
        excludesByRootDirectory.get(rootDirectory),
        contentEntry,
        provider,
        sourceFolders,
        rootSource,
        rootDirectory,
        rootDirectoryStructure.directories.get(rootDirectory));
  }
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:47,代码来源:ContentEntryEditor.java


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