use of com.intellij.ide.projectView.ProjectViewNode in project intellij-community by JetBrains.
the class ProjectViewTestUtil method collect.
public static void collect(AbstractTreeNode node, MultiValuesMap<VirtualFile, AbstractTreeNode> map, final AbstractTreeStructure structure, Function<AbstractTreeNode, VirtualFile[]> converterFunction) {
Object[] kids = structure.getChildElements(node);
for (Object kid1 : kids) {
ProjectViewNode kid = (ProjectViewNode) kid1;
final VirtualFile[] files = getFiles(kid, converterFunction);
for (VirtualFile vFile : files) {
map.put(vFile, kid);
ProjectViewNode eachParent = (ProjectViewNode) kid.getParent();
while (eachParent != null) {
map.put(vFile, eachParent);
eachParent = (ProjectViewNode) eachParent.getParent();
}
}
collect(kid, map, structure, converterFunction);
}
}
use of com.intellij.ide.projectView.ProjectViewNode in project intellij-community by JetBrains.
the class ProjectTreeBuilder method updateNodesContaining.
private void updateNodesContaining(@NotNull Collection<VirtualFile> filesToRefresh, @NotNull DefaultMutableTreeNode rootNode) {
if (!(rootNode.getUserObject() instanceof ProjectViewNode))
return;
ProjectViewNode node = (ProjectViewNode) rootNode.getUserObject();
Collection<VirtualFile> containingFiles = null;
for (VirtualFile virtualFile : filesToRefresh) {
if (!virtualFile.isValid()) {
// file must be deleted
addSubtreeToUpdate(rootNode);
return;
}
if (node.contains(virtualFile)) {
if (containingFiles == null)
containingFiles = new SmartList<>();
containingFiles.add(virtualFile);
}
}
if (containingFiles != null) {
updateNode(rootNode);
Enumeration children = rootNode.children();
while (children.hasMoreElements()) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
updateNodesContaining(containingFiles, child);
}
}
}
use of com.intellij.ide.projectView.ProjectViewNode in project intellij-community by JetBrains.
the class ClassNameConvertor method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
ArrayList<AbstractTreeNode> result = new ArrayList<>();
for (final AbstractTreeNode aChildren : children) {
ProjectViewNode treeNode = (ProjectViewNode) aChildren;
Object o = treeNode.getValue();
if (o instanceof PsiFile && ((PsiFile) o).getVirtualFile().getExtension().equals("java")) {
final String name = ((PsiFile) o).getName();
ProjectViewNode viewNode = new ProjectViewNode<PsiFile>(myProject, (PsiFile) o, settings) {
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
return Collections.emptyList();
}
@Override
public String toTestString(Queryable.PrintInfo printInfo) {
return super.toTestString(printInfo) + " converted";
}
@Override
public String getTestPresentation() {
return name + " converted";
}
@Override
public boolean contains(@NotNull VirtualFile file) {
return false;
}
@Override
public void update(PresentationData presentation) {
}
};
result.add(viewNode);
} else {
result.add(treeNode);
}
}
return result;
}
use of com.intellij.ide.projectView.ProjectViewNode in project intellij-community by JetBrains.
the class TreeFileChooserDialog method calcSelectedClass.
private PsiFile calcSelectedClass() {
if (myTabbedPane.getSelectedIndex() == 1) {
return (PsiFile) myGotoByNamePanel.getChosenElement();
} else {
final TreePath path = myTree.getSelectionPath();
if (path == null)
return null;
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
final Object userObject = node.getUserObject();
if (!(userObject instanceof ProjectViewNode))
return null;
ProjectViewNode pvNode = (ProjectViewNode) userObject;
VirtualFile vFile = pvNode.getVirtualFile();
if (vFile != null && !vFile.isDirectory()) {
return PsiManager.getInstance(myProject).findFile(vFile);
}
return null;
}
}
use of com.intellij.ide.projectView.ProjectViewNode in project intellij-community by JetBrains.
the class ModuleGroupNode method getRoots.
@NotNull
@Override
public Collection<VirtualFile> getRoots() {
Collection<AbstractTreeNode> children = getChildren();
Set<VirtualFile> result = new HashSet<>();
for (AbstractTreeNode each : children) {
if (each instanceof ProjectViewNode) {
result.addAll(((ProjectViewNode) each).getRoots());
}
}
return result;
}
Aggregations