com.intellij.ide.projectView.ViewSettings Java Examples
The following examples show how to use
com.intellij.ide.projectView.ViewSettings.
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: PackageNodeUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void addPackageAsChild(@Nonnull Collection<AbstractTreeNode> children, @Nonnull PsiPackage aPackage, @Nullable Module module, @Nonnull ViewSettings settings, final boolean inLibrary) { final boolean shouldSkipPackage = settings.isHideEmptyMiddlePackages() && isPackageEmpty(aPackage, module, !settings.isFlattenPackages(), inLibrary); final Project project = aPackage.getProject(); if (!shouldSkipPackage) { children.add(new PackageElementNode(project, new PackageElement(module, aPackage, inLibrary), settings)); } if (settings.isFlattenPackages() || shouldSkipPackage) { final PsiPackage[] subpackages = getSubpackages(aPackage, module, project, inLibrary); for (PsiPackage subpackage : subpackages) { addPackageAsChild(children, subpackage, module, settings, inLibrary); } } }
Example #2
Source File: BlazeTreeStructureProvider.java From intellij with Apache License 2.0 | 6 votes |
@Override public Collection<AbstractTreeNode<?>> doModify( AbstractTreeNode<?> parent, Collection<AbstractTreeNode<?>> children, ViewSettings settings) { Project project = parent.getProject(); if (!Blaze.isBlazeProject(project)) { return children; } if (!(parent instanceof ProjectViewProjectNode)) { return children; } WorkspaceRootNode rootNode = createRootNode(project, settings); if (rootNode == null) { return children; } Collection<AbstractTreeNode<?>> result = Lists.newArrayList(); result.add(rootNode); for (AbstractTreeNode treeNode : children) { if (keepOriginalNode(treeNode)) { result.add(treeNode); } } return result; }
Example #3
Source File: BaseProjectViewDirectoryHelper.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction public static void addAllSubpackages(List<AbstractTreeNode> container, PsiDirectory dir, ModuleFileIndex moduleFileIndex, ViewSettings viewSettings) { final Project project = dir.getProject(); PsiDirectory[] subdirs = dir.getSubdirectories(); for (PsiDirectory subdir : subdirs) { if (skipDirectory(subdir)) { continue; } if (moduleFileIndex != null) { if (!moduleFileIndex.isInContent(subdir.getVirtualFile())) { container.add(new PsiDirectoryNode(project, subdir, viewSettings)); continue; } } if (viewSettings.isHideEmptyMiddlePackages()) { if (!isEmptyMiddleDirectory(subdir, false)) { container.add(new PsiDirectoryNode(project, subdir, viewSettings)); } } else { container.add(new PsiDirectoryNode(project, subdir, viewSettings)); } addAllSubpackages(container, subdir, moduleFileIndex, viewSettings); } }
Example #4
Source File: AddToFavoritesAction.java From consulo with Apache License 2.0 | 6 votes |
public static Collection<AbstractTreeNode> getNodesToAdd(final DataContext dataContext, final boolean inProjectView) { Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project == null) return Collections.emptyList(); Module moduleContext = dataContext.getData(LangDataKeys.MODULE_CONTEXT); Collection<AbstractTreeNode> nodesToAdd = null; for (FavoriteNodeProvider provider : Extensions.getExtensions(FavoriteNodeProvider.EP_NAME, project)) { nodesToAdd = provider.getFavoriteNodes(dataContext, ViewSettings.DEFAULT); if (nodesToAdd != null) { break; } } if (nodesToAdd == null) { Object elements = collectSelectedElements(dataContext); if (elements != null) { nodesToAdd = createNodes(project, moduleContext, elements, inProjectView, ViewSettings.DEFAULT); } } return nodesToAdd; }
Example #5
Source File: AddToFavoritesAction.java From consulo with Apache License 2.0 | 6 votes |
private static void addPsiElementNode(PsiElement psiElement, final Project project, final ArrayList<AbstractTreeNode> result, final ViewSettings favoritesConfig) { Class<? extends AbstractTreeNode> klass = getPsiElementNodeClass(psiElement); if (klass == null) { psiElement = PsiTreeUtil.getParentOfType(psiElement, PsiFile.class); if (psiElement != null) { klass = PsiFileNode.class; } } final Object value = psiElement; try { if (klass != null && value != null) { result.add(ProjectViewNode.createTreeNode(klass, project, value, favoritesConfig)); } } catch (Exception e) { LOG.error(e); } }
Example #6
Source File: ImagesProjectViewPane.java From intellij-sdk-docs with Apache License 2.0 | 6 votes |
@NotNull @Override protected ProjectAbstractTreeStructureBase createStructure() { return new ProjectTreeStructure(myProject, ID) { @Override protected AbstractTreeNode createRoot(@NotNull Project project, @NotNull ViewSettings settings) { return new ImagesProjectNode(project); } @NotNull @Override public Object[] getChildElements(@NotNull Object element) { return super.getChildElements(element); } }; }
Example #7
Source File: UsageFavoriteNodeProvider.java From consulo with Apache License 2.0 | 6 votes |
@Override public AbstractTreeNode createNode(Project project, Object element, ViewSettings viewSettings) { if (element instanceof UsageInfo) { return new UsageProjectTreeNode(project, (UsageInfo)element, viewSettings); } else if (element instanceof InvalidUsageNoteNode) { return new InvalidUsageNoteProjectNode(project, (InvalidUsageNoteNode)element, viewSettings); } else if (element instanceof NoteNode) { return new NoteProjectNode(project, (NoteNode)element, viewSettings); } else if (element instanceof File) { return new FileGroupingProjectNode(project, (File)element, viewSettings); } return super.createNode(project, element, viewSettings); }
Example #8
Source File: HideIgnoredFilesTreeStructureProvider.java From idea-gitignore with MIT License | 6 votes |
/** * If {@link IgnoreSettings#hideIgnoredFiles} is set to <code>true</code>, checks if specific * nodes are ignored and filters them out. * * @param parent the parent node * @param children the list of child nodes according to the default project structure * @param settings the current project view settings * @return the modified collection of child nodes */ @NotNull @Override public Collection<AbstractTreeNode<?>> modify(@NotNull AbstractTreeNode<?> parent, @NotNull Collection<AbstractTreeNode<?>> children, @Nullable ViewSettings settings) { if (!ignoreSettings.isHideIgnoredFiles() || children.isEmpty()) { return children; } return ContainerUtil.filter(children, node -> { if (node instanceof BasePsiNode) { final VirtualFile file = ((BasePsiNode) node).getVirtualFile(); return file != null && (!changeListManager.isIgnoredFile(file) && !ignoreManager.isFileIgnored(file) || ignoreManager.isFileTracked(file)); } return true; }); }
Example #9
Source File: PantsTreeStructureProvider.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@NotNull @Override public Collection<AbstractTreeNode<?>> modify( @NotNull final AbstractTreeNode<?> node, @NotNull Collection<AbstractTreeNode<?>> collection, ViewSettings settings ) { Project project = node.getProject(); if (project == null || !(node instanceof PsiDirectoryNode)) return collection; PsiDirectoryNode directory = (PsiDirectoryNode) node; List<PsiFileNode> newNodes = Optional.ofNullable(getModuleOf(directory)) .filter(module -> isModuleRoot(directory, module)) .flatMap(PantsUtil::findModuleAddress) .flatMap(buildPAth -> PantsUtil.findFileRelativeToBuildRoot(project, buildPAth)) .filter(buildFile -> !alreadyExists(collection, buildFile)) .map(buildFile -> createNode(settings, project, buildFile)) .orElseGet(Collections::emptyList); if (newNodes.isEmpty()) return collection; return Stream.concat(collection.stream(), newNodes.stream()).collect(Collectors.toList()); }
Example #10
Source File: CSharpElementTreeNode.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Nullable @Override @RequiredUIAccess protected Collection<AbstractTreeNode> getChildrenImpl() { final ViewSettings settings = getSettings(); if(!settings.isShowMembers() && !BitUtil.isSet(myFlags, FORCE_EXPAND)) { return Collections.emptyList(); } DotNetNamedElement[] members = filterNamespaces(getValue()); if(members.length == 0) { return Collections.emptyList(); } List<AbstractTreeNode> list = new ArrayList<>(members.length); for(DotNetNamedElement dotNetElement : members) { list.add(new CSharpElementTreeNode(dotNetElement, settings, 0)); } return list; }
Example #11
Source File: ModuleStructurePane.java From consulo with Apache License 2.0 | 5 votes |
@Override public ProjectAbstractTreeStructureBase createStructure() { return new ProjectTreeStructure(myProject, ID){ @Override protected AbstractTreeNode createRoot(final Project project, ViewSettings settings) { return new StructureViewModuleNode(project, myModule, settings); } @Override public boolean isToBuildChildrenInBackground(Object element) { return false; } }; }
Example #12
Source File: PackageNodeUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Collection<AbstractTreeNode> createPackageViewChildrenOnFiles(@Nonnull List<VirtualFile> sourceRoots, @Nonnull Project project, @Nonnull ViewSettings settings, @Nullable Module module, final boolean inLibrary) { final PsiManager psiManager = PsiManager.getInstance(project); final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>(); final Set<PsiPackage> topLevelPackages = new HashSet<PsiPackage>(); for (final VirtualFile root : sourceRoots) { final PsiDirectory directory = psiManager.findDirectory(root); if (directory == null) { continue; } final PsiPackage directoryPackage = PsiPackageManager.getInstance(project).findAnyPackage(directory); if (directoryPackage == null || isPackageDefault(directoryPackage)) { // add subpackages final PsiDirectory[] subdirectories = directory.getSubdirectories(); for (PsiDirectory subdirectory : subdirectories) { final PsiPackage aPackage = PsiPackageManager.getInstance(project).findAnyPackage(subdirectory); if (aPackage != null && !isPackageDefault(aPackage)) { topLevelPackages.add(aPackage); } } // add non-dir items children.addAll(BaseProjectViewDirectoryHelper.getDirectoryChildren(directory, settings, false)); } else { topLevelPackages.add(directoryPackage); } } for (final PsiPackage topLevelPackage : topLevelPackages) { addPackageAsChild(children, topLevelPackage, module, settings, inLibrary); } return children; }
Example #13
Source File: BackgroundTaskByVfsProjectViewProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) { if (parent instanceof BackgroundTaskPsiFileTreeNode) { return children; } List<VirtualFile> allGeneratedFiles = new ArrayList<VirtualFile>(); BackgroundTaskByVfsChangeManager vfsChangeManager = BackgroundTaskByVfsChangeManager.getInstance(myProject); for (BackgroundTaskByVfsChangeTask o : vfsChangeManager.getTasks()) { Collections.addAll(allGeneratedFiles, o.getGeneratedFiles()); } List<AbstractTreeNode> list = new ArrayList<AbstractTreeNode>(children); for (ListIterator<AbstractTreeNode> iterator = list.listIterator(); iterator.hasNext(); ) { AbstractTreeNode next = iterator.next(); Object value = next.getValue(); if (value instanceof PsiFile) { VirtualFile virtualFile = ((PsiFile)value).getVirtualFile(); if (virtualFile == null) { continue; } if (allGeneratedFiles.contains(virtualFile)) { iterator.remove(); } else if (!vfsChangeManager.findTasks(virtualFile).isEmpty()) { iterator.set(new BackgroundTaskPsiFileTreeNode(myProject, (PsiFile)value, settings)); } } } return list; }
Example #14
Source File: FileGroupingProjectNode.java From consulo with Apache License 2.0 | 5 votes |
public FileGroupingProjectNode(Project project, File file, ViewSettings viewSettings) { super(project, file, viewSettings); final LocalFileSystem lfs = LocalFileSystem.getInstance(); myVirtualFile = lfs.findFileByIoFile(file); if (myVirtualFile == null) { myVirtualFile = lfs.refreshAndFindFileByIoFile(file); } }
Example #15
Source File: ImportUsagesAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { final DataContext dc = e.getDataContext(); final boolean enabled = isEnabled(dc); if (!enabled) return; final Project project = dc.getData(CommonDataKeys.PROJECT); final Collection<AbstractTreeNode> nodes = new UsageFavoriteNodeProvider().getFavoriteNodes(dc, ViewSettings.DEFAULT); final FavoritesManager favoritesManager = FavoritesManager.getInstance(project); if (nodes != null && !nodes.isEmpty()) { favoritesManager.addRoots(TaskDefaultFavoriteListProvider.CURRENT_TASK, nodes); } }
Example #16
Source File: PantsTreeStructureProvider.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@NotNull private List<PsiFileNode> createNode(ViewSettings settings, Project project, VirtualFile buildFile) { final PsiFile buildPsiFile = PsiManager.getInstance(project).findFile(buildFile); if(buildPsiFile == null) return Collections.emptyList(); PsiFileNode node = new PsiFileNode(project, buildPsiFile, settings) { @Override protected void updateImpl(@NotNull PresentationData data) { super.updateImpl(data); data.setIcon(PantsIcons.Icon); } }; return Collections.singletonList(node); }
Example #17
Source File: VirtualFileTreeNode.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
private boolean shouldIncludeDirectory(VirtualFile dir) { final ViewSettings viewSettings = getSettings(); if (viewSettings instanceof PantsViewSettings && ((PantsViewSettings)viewSettings).isShowOnlyLoadedFiles()) { final PantsProjectCache projectCache = PantsProjectCache.getInstance(getProject()); return projectCache.folderContainsSourceRoot(dir); } return true; }
Example #18
Source File: VirtualFileTreeNode.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
public VirtualFileTreeNode( @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull ViewSettings viewSettings ) { super(project, virtualFile, viewSettings); }
Example #19
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 5 votes |
@SuppressWarnings("rawtypes") @NotNull public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) { //ProjectViewNode[] copy = children.toArray(new ProjectViewNode[children.size()]); AbstractTreeNode[] arr2 = children.toArray(new AbstractTreeNode[children.size()]); //noinspection unchecked Collection<AbstractTreeNode<?>> r = RTMergerTreeStructureProviderK2.INSTANCE.modify22(project, parent, arr2, settings); return new LinkedHashSet<AbstractTreeNode>(r); }
Example #20
Source File: BaseProjectViewDirectoryHelper.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction public static boolean isShowFQName(Project project, ViewSettings settings, Object parentValue, PsiDirectory value) { PsiPackage aPackage; return value != null && !(parentValue instanceof Project) && settings.isFlattenPackages() && (aPackage = PsiPackageManager.getInstance(project).findAnyPackage(value)) != null && !aPackage.getQualifiedName().isEmpty(); }
Example #21
Source File: BaseProjectViewDirectoryHelper.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @RequiredReadAction public static String getNodeName(ViewSettings settings, Object parentValue, @Nonnull PsiDirectory directory) { Project project = directory.getProject(); PsiPackage aPackage = PsiPackageManager.getInstance(project).findAnyPackage(directory); String name = directory.getName(); VirtualFile dirFile = directory.getVirtualFile(); if (dirFile.getFileSystem() instanceof ArchiveFileSystem && dirFile.getParent() == null) { VirtualFile virtualFileForArchive = ArchiveVfsUtil.getVirtualFileForArchive(dirFile); if (virtualFileForArchive != null) { name = virtualFileForArchive.getName(); } } PsiPackage parentPackage; if (!ProjectRootsUtil.isSourceRoot(directory) && aPackage != null && !aPackage.getQualifiedName().isEmpty() && parentValue instanceof PsiDirectory) { parentPackage = PsiPackageManager.getInstance(project).findAnyPackage(((PsiDirectory)parentValue)); } else if (ProjectRootsUtil.isSourceRoot(directory) && aPackage != null) { //package prefix aPackage = null; parentPackage = null; } else { parentPackage = null; } return TreeViewUtil.getNodeName(settings, aPackage, parentPackage, name, isShowFQName(project, settings, parentValue, directory)); }
Example #22
Source File: BaseProjectViewDirectoryHelper.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction public static Collection<AbstractTreeNode> doGetDirectoryChildren(final PsiDirectory psiDirectory, final ViewSettings settings, final boolean withSubDirectories) { final List<AbstractTreeNode> children = new ArrayList<>(); final Project project = psiDirectory.getProject(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final Module module = fileIndex.getModuleForFile(psiDirectory.getVirtualFile()); final ModuleFileIndex moduleFileIndex = module == null ? null : ModuleRootManager.getInstance(module).getFileIndex(); if (!settings.isFlattenPackages() || skipDirectory(psiDirectory)) { processPsiDirectoryChildren(psiDirectory, directoryChildrenInProject(psiDirectory, settings), children, fileIndex, null, settings, withSubDirectories); } else { // source directory in "flatten packages" mode final PsiDirectory parentDir = psiDirectory.getParentDirectory(); if (parentDir == null || skipDirectory(parentDir) /*|| !rootDirectoryFound(parentDir)*/ && withSubDirectories) { addAllSubpackages(children, psiDirectory, moduleFileIndex, settings); } PsiDirectory[] subdirs = psiDirectory.getSubdirectories(); for (PsiDirectory subdir : subdirs) { if (!skipDirectory(subdir)) { continue; } VirtualFile directoryFile = subdir.getVirtualFile(); if (FileTypeRegistry.getInstance().isFileIgnored(directoryFile)) continue; if (withSubDirectories) { children.add(new PsiDirectoryNode(project, subdir, settings)); } } processPsiDirectoryChildren(psiDirectory, psiDirectory.getFiles(), children, fileIndex, moduleFileIndex, settings, withSubDirectories); } return children; }
Example #23
Source File: BaseProjectViewDirectoryHelper.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction private static PsiElement[] directoryChildrenInProject(PsiDirectory psiDirectory, final ViewSettings settings) { DirectoryIndex directoryIndex = DirectoryIndex.getInstance(psiDirectory.getProject()); VirtualFile dir = psiDirectory.getVirtualFile(); if (shouldBeShown(directoryIndex, dir, settings)) { final List<PsiElement> children = new ArrayList<>(); psiDirectory.processChildren(element -> { if (shouldBeShown(directoryIndex, element.getVirtualFile(), settings)) { children.add(element); } return true; }); return PsiUtilCore.toPsiElementArray(children); } PsiManager manager = psiDirectory.getManager(); Set<PsiElement> directoriesOnTheWayToContentRoots = new THashSet<>(); for (VirtualFile root : getTopLevelRoots(psiDirectory.getProject())) { VirtualFile current = root; while (current != null) { VirtualFile parent = current.getParent(); if (Comparing.equal(parent, dir)) { final PsiDirectory psi = manager.findDirectory(current); if (psi != null) { directoriesOnTheWayToContentRoots.add(psi); } } current = parent; } } return PsiUtilBase.toPsiElementArray(directoriesOnTheWayToContentRoots); }
Example #24
Source File: TodoPackageNode.java From consulo with Apache License 2.0 | 5 votes |
public TodoPackageNode(@Nonnull Project project, PackageElement element, TodoTreeBuilder builder, @Nullable String name) { super(project, element, ViewSettings.DEFAULT); myBuilder = builder; myHighlightedRegions = new ArrayList<HighlightedRegion>(2); if (element != null && name == null){ final PsiPackage aPackage = element.getPackage(); myPresentationName = aPackage.getName(); } else { myPresentationName = name; } }
Example #25
Source File: BaseProjectViewDirectoryHelper.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction public static void processPsiDirectoryChildren(final PsiDirectory psiDir, PsiElement[] children, List<AbstractTreeNode> container, ProjectFileIndex projectFileIndex, ModuleFileIndex moduleFileIndex, ViewSettings viewSettings, boolean withSubDirectories) { Project project = psiDir.getProject(); for (PsiElement child : children) { if (!(child instanceof PsiFileSystemItem)) { LOGGER.error("Either PsiFile or PsiDirectory expected as a child of " + child.getParent() + ", but was " + child); continue; } final VirtualFile vFile = ((PsiFileSystemItem)child).getVirtualFile(); if (vFile == null) { continue; } if (moduleFileIndex != null && !moduleFileIndex.isInContent(vFile)) { continue; } if (child instanceof PsiFile) { container.add(new PsiFileNode(project, (PsiFile)child, viewSettings)); } else if (child instanceof PsiDirectory) { if (withSubDirectories) { PsiDirectory dir = (PsiDirectory)child; if (!vFile.equals(projectFileIndex.getSourceRootForFile(vFile))) { // if is not a source root if (viewSettings.isHideEmptyMiddlePackages() && !skipDirectory(psiDir) && isEmptyMiddleDirectory(dir, true)) { processPsiDirectoryChildren(dir, directoryChildrenInProject(dir, viewSettings), container, projectFileIndex, moduleFileIndex, viewSettings, withSubDirectories); // expand it recursively continue; } } container.add(new PsiDirectoryNode(project, dir, viewSettings)); } } } }
Example #26
Source File: PackageViewPane.java From consulo with Apache License 2.0 | 5 votes |
@Override public ProjectAbstractTreeStructureBase createStructure() { return new ProjectTreeStructure(myProject, ID) { @Override protected AbstractTreeNode createRoot(final Project project, ViewSettings settings) { return new PackageViewProjectNode(project, settings); } }; }
Example #27
Source File: StructureViewModuleNode.java From consulo with Apache License 2.0 | 4 votes |
public StructureViewModuleNode(Project project, Module value, ViewSettings viewSettings) { super(project, value, viewSettings); }
Example #28
Source File: PackageElementNode.java From consulo with Apache License 2.0 | 4 votes |
public PackageElementNode(@Nonnull Project project, final PackageElement value, final ViewSettings viewSettings) { super(project, value, viewSettings); }
Example #29
Source File: PackageViewModuleNode.java From consulo with Apache License 2.0 | 4 votes |
public PackageViewModuleNode(Project project, Object value, ViewSettings viewSettings) { this(project, (Module)value, viewSettings); }
Example #30
Source File: AbstractProjectTreeStructure.java From consulo with Apache License 2.0 | 4 votes |
protected AbstractTreeNode createRoot(final Project project, ViewSettings settings) { return new ProjectViewProjectNode(myProject, this); }