use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class ResourceBundleNode method getChildren.
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
List<PropertiesFile> propertiesFiles = ObjectUtils.notNull(getValue()).getPropertiesFiles();
Collection<AbstractTreeNode> children = new ArrayList<>();
for (PropertiesFile propertiesFile : propertiesFiles) {
AbstractTreeNode node = new PsiFileNode(myProject, propertiesFile.getContainingFile(), getSettings());
children.add(node);
}
return children;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class XsltTreeStructureProvider method modify.
@NotNull
@SuppressWarnings({ "RawUseOfParameterizedType", "unchecked" })
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
Collection<AbstractTreeNode> l = children;
int i = 0;
for (AbstractTreeNode o : children) {
if (o instanceof ProjectViewNode) {
final ProjectViewNode node = (ProjectViewNode) o;
final Object element = node.getValue();
if (element instanceof PsiFile) {
if (XsltSupport.isXsltFile((PsiFile) element)) {
if (l == children && l.getClass() != ArrayList.class) {
l = new ArrayList<>(children);
}
final XsltFileNode fileNode = new XsltFileNode(myProject, (PsiFile) element, settings);
((List<AbstractTreeNode>) l).set(i, fileNode);
}
}
}
i++;
}
return l;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class StudyTreeStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
Project project = parent.getProject();
if (project == null || !shouldModify(project)) {
return children;
}
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return children;
}
Collection<AbstractTreeNode> modifiedNodes = new ArrayList<>();
for (AbstractTreeNode node : children) {
if (parent instanceof ProjectViewProjectNode && node instanceof PsiDirectoryNode) {
modifiedNodes.add(createCourseNode(project, node, settings, course));
continue;
}
if (parent instanceof StudyDirectoryNode) {
AbstractTreeNode modifiedNode = ((StudyDirectoryNode) parent).modifyChildNode(node);
if (modifiedNode != null) {
modifiedNodes.add(modifiedNode);
}
}
}
return modifiedNodes;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class FormMergerTreeStructureProvider method findFormsIn.
private static Collection<BasePsiNode<? extends PsiElement>> findFormsIn(Collection<AbstractTreeNode> children, List<PsiFile> forms) {
if (children.isEmpty() || forms.isEmpty())
return Collections.emptyList();
ArrayList<BasePsiNode<? extends PsiElement>> result = new ArrayList<>();
HashSet<PsiFile> psiFiles = new HashSet<>(forms);
for (final AbstractTreeNode child : children) {
if (child instanceof BasePsiNode) {
//noinspection unchecked
BasePsiNode<? extends PsiElement> treeNode = (BasePsiNode<? extends PsiElement>) child;
//noinspection SuspiciousMethodCalls
if (psiFiles.contains(treeNode.getValue()))
result.add(treeNode);
}
}
return result;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class FormMergerTreeStructureProvider method modify.
@NotNull
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
if (parent.getValue() instanceof Form)
return children;
// Optimization. Check if there are any forms at all.
boolean formsFound = false;
for (AbstractTreeNode node : children) {
if (node.getValue() instanceof PsiFile) {
PsiFile file = (PsiFile) node.getValue();
if (file.getFileType() == StdFileTypes.GUI_DESIGNER_FORM) {
formsFound = true;
break;
}
}
}
if (!formsFound)
return children;
Collection<AbstractTreeNode> result = new LinkedHashSet<>(children);
ProjectViewNode[] copy = children.toArray(new ProjectViewNode[children.size()]);
for (ProjectViewNode element : copy) {
PsiClass psiClass = null;
if (element.getValue() instanceof PsiClass) {
psiClass = (PsiClass) element.getValue();
} else if (element.getValue() instanceof PsiClassOwner) {
final PsiClass[] psiClasses = ((PsiClassOwner) element.getValue()).getClasses();
if (psiClasses.length == 1) {
psiClass = psiClasses[0];
}
}
if (psiClass == null)
continue;
String qName = psiClass.getQualifiedName();
if (qName == null)
continue;
List<PsiFile> forms;
try {
forms = FormClassIndex.findFormsBoundToClass(myProject, qName);
} catch (ProcessCanceledException e) {
continue;
}
Collection<BasePsiNode<? extends PsiElement>> formNodes = findFormsIn(children, forms);
if (!formNodes.isEmpty()) {
Collection<PsiFile> formFiles = convertToFiles(formNodes);
Collection<BasePsiNode<? extends PsiElement>> subNodes = new ArrayList<>();
//noinspection unchecked
subNodes.add((BasePsiNode<? extends PsiElement>) element);
subNodes.addAll(formNodes);
result.add(new FormNode(myProject, new Form(psiClass, formFiles), settings, subNodes));
result.remove(element);
result.removeAll(formNodes);
}
}
return result;
}
Aggregations