use of com.intellij.ide.util.treeView.AbstractTreeNode in project android by JetBrains.
the class AndroidResFolderTypeNode method getChildren.
@NotNull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
// all resource folders of a given folder type
List<PsiDirectory> folders = getValue();
Multimap<String, PsiFile> multimap = HashMultimap.create();
for (PsiDirectory res : folders) {
for (PsiFile file : res.getFiles()) {
String resName = file.getName();
multimap.put(resName, file);
}
}
List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(multimap.size());
for (String resName : multimap.keySet()) {
List<PsiFile> files = Lists.newArrayList(multimap.get(resName));
if (files.size() > 1) {
children.add(new AndroidResGroupNode(myProject, myFacet, files, resName, getSettings()));
} else {
children.add(new AndroidResFileNode(myProject, files.get(0), getSettings(), myFacet));
}
}
return children;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project android by JetBrains.
the class AndroidSourceTypeNode method annotateWithSourceProvider.
private Collection<AbstractTreeNode> annotateWithSourceProvider(Collection<AbstractTreeNode> directoryChildren) {
List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(directoryChildren.size());
for (AbstractTreeNode child : directoryChildren) {
if (child instanceof PsiDirectoryNode) {
PsiDirectory directory = ((PsiDirectoryNode) child).getValue();
children.add(new AndroidPsiDirectoryNode(myProject, directory, getSettings(), findSourceProvider(directory.getVirtualFile())));
} else if (child instanceof PsiFileNode) {
PsiFile file = ((PsiFileNode) child).getValue();
children.add(new AndroidPsiFileNode(myProject, file, getSettings(), findSourceProvider(file.getVirtualFile())));
} else {
children.add(child);
}
}
return children;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project android by JetBrains.
the class AndroidSourceTypeNode method getChildren.
@NotNull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
List<AbstractTreeNode> children = Lists.newArrayList();
ProjectViewDirectoryHelper projectViewDirectoryHelper = ProjectViewDirectoryHelper.getInstance(myProject);
AndroidProjectTreeBuilder treeBuilder = (AndroidProjectTreeBuilder) myProjectViewPane.getTreeBuilder();
for (PsiDirectory directory : getSourceDirectories()) {
Collection<AbstractTreeNode> directoryChildren = projectViewDirectoryHelper.getDirectoryChildren(directory, getSettings(), true);
children.addAll(annotateWithSourceProvider(directoryChildren));
// Inform the tree builder of the node that this particular virtual file maps to
treeBuilder.createMapping(directory.getVirtualFile(), this);
}
return children;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project folding-plugin by dmytrodanylyk.
the class DirectoryNode method getChildren.
@NotNull
@Override
public List<AbstractTreeNode> getChildren() {
if (PropertiesComponent.getInstance().getBoolean(SettingConfigurable.PREFIX_HIDE, false)) {
final ArrayList<AbstractTreeNode> abstractTreeNodes = new ArrayList<>();
for (AbstractTreeNode fileNode : mChildNodeList) {
PsiFile psiFile = (PsiFile) fileNode.getValue();
final ViewSettings settings = ((PsiFileNode) fileNode).getSettings();
String shortName = psiFile.getName().substring(mName.length());
final int beginIndex = shortName.indexOf(ProjectStructureProvider.COMPOSE_BY_CHAR);
if (beginIndex != -1) {
shortName = shortName.substring(beginIndex + 1);
}
abstractTreeNodes.add(new FoldingNode(fileNode.getProject(), psiFile, settings, shortName));
}
return abstractTreeNodes;
} else {
return mChildNodeList;
}
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project folding-plugin by dmytrodanylyk.
the class ProjectStructureProvider method filterByDirName.
@NotNull
private List<AbstractTreeNode> filterByDirName(Collection<AbstractTreeNode> fileNodes, String token) {
List<AbstractTreeNode> resultList = new ArrayList<>();
final boolean customPrefix = PropertiesComponent.getInstance().getBoolean(SettingConfigurable.PREFIX_CUSTOM_USE, false);
Pattern pattern = customPrefix ? Pattern.compile(PropertiesComponent.getInstance().getValue(SettingConfigurable.PREFIX_PATTERN, SettingConfigurable.DEFAULT_PATTERN)) : null;
for (AbstractTreeNode fileNode : fileNodes) {
if (fileNode.getValue() instanceof PsiFile) {
PsiFile psiFile = (PsiFile) fileNode.getValue();
String fileName = psiFile.getName();
if (customPrefix) {
Matcher m = pattern.matcher(fileName);
if (m.find()) {
String composedDirName = m.group(0);
if (composedDirName.equals(token)) {
resultList.add(fileNode);
}
}
} else {
int endIndex = fileName.indexOf(COMPOSE_BY_CHAR);
if (endIndex != -1) {
String composedDirName = fileName.substring(0, endIndex);
if (composedDirName.equals(token)) {
resultList.add(fileNode);
}
}
}
}
}
return resultList;
}
Aggregations