use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class MvcProjectNode method getChildren.
@Override
@NotNull
public Collection<? extends AbstractTreeNode> getChildren() {
List<Module> modules = MvcModuleStructureUtil.getAllModulesWithSupport(myProject, myDescriptor.getFramework());
modules = myDescriptor.getFramework().reorderModulesForMvcView(modules);
final ArrayList<AbstractTreeNode> nodes = new ArrayList<>();
for (Module module : modules) {
nodes.add(new MvcModuleNode(module, getSettings(), myDescriptor));
}
return nodes;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class MvcProjectViewPane method getSelectPath.
@Nullable
private static List<Object> getSelectPath(@NotNull Project project, @NotNull MvcFramework framework, VirtualFile file) {
if (file == null) {
return null;
}
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module == null || !framework.hasSupport(module)) {
return null;
}
List<Object> result = new ArrayList<>();
final MvcProjectViewPane view = getView(project, framework);
if (view == null) {
return null;
}
final MvcProjectNode root = (MvcProjectNode) view.getTreeBuilder().getTreeStructure().getRootElement();
result.add(root);
for (AbstractTreeNode moduleNode : root.getChildren()) {
if (moduleNode.getValue() == module) {
result.add(moduleNode);
AbstractTreeNode<?> cur = moduleNode;
path: while (true) {
for (AbstractTreeNode descriptor : cur.getChildren()) {
if (descriptor instanceof AbstractFolderNode) {
final AbstractFolderNode folderNode = (AbstractFolderNode) descriptor;
final VirtualFile dir = folderNode.getVirtualFile();
if (dir != null && VfsUtilCore.isAncestor(dir, file, false)) {
cur = folderNode;
result.add(folderNode);
if (dir.equals(file)) {
return result;
}
continue path;
}
}
if (descriptor instanceof AbstractMvcPsiNodeDescriptor) {
if (file.equals(((AbstractMvcPsiNodeDescriptor) descriptor).getVirtualFile())) {
result.add(descriptor);
return result;
}
}
}
return null;
}
}
}
return null;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class AbstractFolderNode method getChildrenImpl.
@Override
@Nullable
protected Collection<AbstractTreeNode> getChildrenImpl() {
final PsiDirectory directory = getPsiDirectory();
if (!directory.isValid()) {
return Collections.emptyList();
}
// scan folder's children
final List<AbstractTreeNode> children = Arrays.stream(directory.getSubdirectories()).map(this::createFolderNode).collect(Collectors.toList());
for (PsiFile file : directory.getFiles()) {
processNotDirectoryFile(children, file);
}
return children;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class CCTaskDirectoryNode method modifyChildNode.
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
AbstractTreeNode node = super.modifyChildNode(childNode);
if (node != null) {
return node;
}
Object value = childNode.getValue();
if (value instanceof PsiElement) {
PsiElement psiElement = (PsiElement) value;
PsiFile psiFile = psiElement.getContainingFile();
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null) {
return null;
}
if (StudyUtils.isTaskDescriptionFile(virtualFile.getName())) {
return null;
}
Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course == null) {
return null;
}
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings);
}
if (!CCUtils.isTestsFile(myProject, virtualFile)) {
return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings);
}
if (!myTask.hasSubtasks()) {
return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings, getTestNodeName(manager, psiElement));
}
String testFileName = getTestNodeName(manager, psiElement);
return isActiveSubtaskTest(virtualFile) ? new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings, testFileName) : null;
}
return null;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class PackageUtil method createPackageViewChildrenOnFiles.
@NotNull
public static Collection<AbstractTreeNode> createPackageViewChildrenOnFiles(@NotNull List<VirtualFile> sourceRoots, @NotNull Project project, @NotNull ViewSettings settings, @Nullable Module module, final boolean inLibrary) {
final PsiManager psiManager = PsiManager.getInstance(project);
final List<AbstractTreeNode> children = new ArrayList<>();
final Set<PsiPackage> topLevelPackages = new HashSet<>();
for (final VirtualFile root : sourceRoots) {
final PsiDirectory directory = psiManager.findDirectory(root);
if (directory == null) {
continue;
}
final PsiPackage directoryPackage = JavaDirectoryService.getInstance().getPackage(directory);
if (directoryPackage == null || isPackageDefault(directoryPackage)) {
// add subpackages
final PsiDirectory[] subdirectories = directory.getSubdirectories();
for (PsiDirectory subdirectory : subdirectories) {
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(subdirectory);
if (aPackage != null && !isPackageDefault(aPackage)) {
topLevelPackages.add(aPackage);
}
}
// add non-dir items
children.addAll(ProjectViewDirectoryHelper.getInstance(project).getDirectoryChildren(directory, settings, false));
} else {
topLevelPackages.add(directoryPackage);
}
}
for (final PsiPackage topLevelPackage : topLevelPackages) {
addPackageAsChild(children, topLevelPackage, module, settings, inLibrary);
}
return children;
}
Aggregations