use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class ModuleGroupNode method getChildren.
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
ModuleGrouper grouper = ModuleGrouper.instanceFor(getProject());
final Collection<ModuleGroup> childGroups = getValue().childGroups(grouper);
final List<AbstractTreeNode> result = new ArrayList<>();
for (final ModuleGroup childGroup : childGroups) {
result.add(createModuleGroupNode(childGroup));
}
Collection<Module> modules = getValue().modulesInGroup(grouper, false);
try {
for (Module module : modules) {
result.add(createModuleNode(module));
}
} catch (Exception e) {
LOG.error(e);
}
return result;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class ProjectViewDirectoryHelper method getDirectoryChildren.
@NotNull
public Collection<AbstractTreeNode> getDirectoryChildren(final PsiDirectory psiDirectory, final ViewSettings settings, final boolean withSubDirectories, @Nullable PsiFileSystemItemFilter filter) {
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, filter);
} else {
// source directory in "flatten packages" mode
final PsiDirectory parentDir = psiDirectory.getParentDirectory();
if (parentDir == null || skipDirectory(parentDir) && withSubDirectories) {
addAllSubpackages(children, psiDirectory, moduleFileIndex, settings, filter);
}
if (withSubDirectories) {
PsiDirectory[] subdirs = psiDirectory.getSubdirectories();
for (PsiDirectory subdir : subdirs) {
if (!skipDirectory(subdir) || filter != null && !filter.shouldShow(subdir)) {
continue;
}
VirtualFile directoryFile = subdir.getVirtualFile();
if (Registry.is("ide.hide.excluded.files")) {
if (fileIndex.isExcluded(directoryFile))
continue;
} else {
if (FileTypeRegistry.getInstance().isFileIgnored(directoryFile))
continue;
}
children.add(new PsiDirectoryNode(project, subdir, settings, filter));
}
}
processPsiDirectoryChildren(psiDirectory, psiDirectory.getFiles(), children, fileIndex, moduleFileIndex, settings, withSubDirectories, filter);
}
return children;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class PsiClassFavoriteNodeProvider method getFavoriteNodes.
@Override
public Collection<AbstractTreeNode> getFavoriteNodes(final DataContext context, final ViewSettings viewSettings) {
final Project project = CommonDataKeys.PROJECT.getData(context);
if (project == null)
return null;
PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(context);
if (elements == null) {
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
if (element != null) {
elements = new PsiElement[] { element };
}
}
if (elements != null) {
final Collection<AbstractTreeNode> result = new ArrayList<>();
for (PsiElement element : elements) {
if (element instanceof PsiClass && checkClassUnderSources(element, project)) {
result.add(new ClassSmartPointerNode(project, element, viewSettings));
}
}
return result.isEmpty() ? null : result;
}
return null;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class PsiFieldFavoriteNodeProvider method getFavoriteNodes.
@Override
public Collection<AbstractTreeNode> getFavoriteNodes(final DataContext context, final ViewSettings viewSettings) {
final Project project = CommonDataKeys.PROJECT.getData(context);
if (project == null)
return null;
PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(context);
if (elements == null) {
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
if (element != null) {
elements = new PsiElement[] { element };
}
}
if (elements != null) {
final Collection<AbstractTreeNode> result = new ArrayList<>();
for (PsiElement element : elements) {
if (element instanceof PsiField) {
result.add(new FieldSmartPointerNode(project, element, viewSettings));
}
}
return result.isEmpty() ? null : result;
}
return null;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class PsiPackageFavoriteNodeProvider method getFavoriteNodes.
@Override
public Collection<AbstractTreeNode> getFavoriteNodes(final DataContext context, final ViewSettings viewSettings) {
final Project project = CommonDataKeys.PROJECT.getData(context);
if (project == null)
return null;
PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(context);
if (elements == null) {
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
if (element != null) {
elements = new PsiElement[] { element };
}
}
final Collection<AbstractTreeNode> result = new ArrayList<>();
if (elements != null) {
for (PsiElement element : elements) {
if (element instanceof PsiPackage) {
final PsiPackage psiPackage = (PsiPackage) element;
final PsiDirectory[] directories = psiPackage.getDirectories();
if (directories.length > 0) {
final VirtualFile firstDir = directories[0].getVirtualFile();
final boolean isLibraryRoot = ProjectRootsUtil.isLibraryRoot(firstDir, project);
final PackageElement packageElement = new PackageElement(LangDataKeys.MODULE.getData(context), psiPackage, isLibraryRoot);
result.add(new PackageElementNode(project, packageElement, viewSettings));
}
}
}
return result.isEmpty() ? null : result;
}
final String currentViewId = ProjectView.getInstance(project).getCurrentViewId();
final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(context);
if (modules != null) {
for (Module module : modules) {
if (PackageViewPane.ID.equals(currentViewId)) {
result.add(new PackageViewModuleNode(project, module, viewSettings));
} else {
result.add(new ProjectViewModuleNode(project, module, viewSettings));
}
}
} else {
final ModuleGroup[] data = ModuleGroup.ARRAY_DATA_KEY.getData(context);
if (data != null) {
for (ModuleGroup moduleGroup : data) {
if (PackageViewPane.ID.equals(currentViewId)) {
result.add(new PackageViewModuleGroupNode(project, moduleGroup, viewSettings));
} else {
result.add(new ProjectViewModuleGroupNode(project, moduleGroup, viewSettings));
}
}
}
}
return null;
}
Aggregations