Java Code Examples for com.intellij.openapi.roots.ContentEntry#addFolder()

The following examples show how to use com.intellij.openapi.roots.ContentEntry#addFolder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentEntryEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public ContentFolder addFolder(@Nonnull final VirtualFile file, ContentFolderTypeProvider contentFolderType) {
  final ContentEntry contentEntry = getContentEntry();
  if (contentEntry != null) {
    final ContentFolder contentFolder = contentEntry.addFolder(file, contentFolderType);
    try {
      return contentFolder;
    }
    finally {
      myEventDispatcher.getMulticaster().folderAdded(this, contentFolder);
      update();
    }
  }

  return null;
}
 
Example 2
Source File: ContentRootDataService.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void createSourceRootIfAbsent(@Nonnull ContentEntry entry,
                                             @Nonnull ContentRootData.SourceRoot root,
                                             @Nonnull String moduleName,
                                             @Nonnull ContentFolderTypeProvider folderTypeProvider,
                                             boolean generated,
                                             boolean createEmptyContentRootDirectories) {
  ContentFolder[] folders = entry.getFolders(ContentFolderScopes.of(folderTypeProvider));
  for (ContentFolder folder : folders) {
    VirtualFile file = folder.getFile();
    if (file == null) {
      continue;
    }
    if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(root.getPath())) {
      return;
    }
  }
  LOG.info(String.format("Importing %s for content root '%s' of module '%s'", root, entry.getUrl(), moduleName));
  ContentFolder contentFolder = entry.addFolder(toVfsUrl(root.getPath()), folderTypeProvider);
  /*if (!StringUtil.isEmpty(root.getPackagePrefix())) {
    sourceFolder.setPackagePrefix(root.getPackagePrefix());
  } */
  if (generated) {
    contentFolder.setPropertyValue(GeneratedContentFolderPropertyProvider.IS_GENERATED, Boolean.TRUE);
  }
  if (createEmptyContentRootDirectories) {
    try {
      VfsUtil.createDirectoryIfMissing(root.getPath());
    }
    catch (IOException e) {
      LOG.warn(String.format("Unable to create directory for the path: %s", root.getPath()), e);
    }
  }
}
 
Example 3
Source File: ContentRootDataService.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void createExcludedRootIfAbsent(@Nonnull ContentEntry entry,
                                               @Nonnull ContentRootData.SourceRoot root,
                                               @Nonnull String moduleName,
                                               @Nonnull Project project) {
  String rootPath = root.getPath();
  for (VirtualFile file : entry.getFolderFiles(ContentFolderScopes.excluded())) {
    if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(rootPath)) {
      return;
    }
  }
  LOG.info(String.format("Importing excluded root '%s' for content root '%s' of module '%s'", root, entry.getUrl(), moduleName));
  entry.addFolder(toVfsUrl(rootPath), ExcludedContentFolderTypeProvider.getInstance());
  ChangeListManager.getInstance(project).addDirectoryToIgnoreImplicitly(rootPath);
}