use of com.android.tools.idea.navigator.AndroidProjectTreeBuilder in project android by JetBrains.
the class AndroidResFolderNode method getChildren.
/**
* Returns the children of the res folder. Rather than showing the existing directory hierarchy, this merges together
* all the folders by their {@link com.android.resources.ResourceFolderType}.
*/
@NotNull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
// collect all res folders from all source providers
List<PsiDirectory> resFolders = Lists.newArrayList();
for (PsiDirectory directory : getSourceDirectories()) {
resFolders.addAll(Lists.newArrayList(directory.getSubdirectories()));
}
// group all the res folders by their folder type
HashMultimap<ResourceFolderType, PsiDirectory> foldersByResourceType = HashMultimap.create();
for (PsiDirectory resFolder : resFolders) {
ResourceFolderType type = ResourceFolderType.getFolderType(resFolder.getName());
if (type == null) {
// skip unknown folder types inside res
continue;
}
foldersByResourceType.put(type, resFolder);
}
// create a node for each res folder type that actually has some resources
AndroidProjectTreeBuilder treeBuilder = (AndroidProjectTreeBuilder) myProjectViewPane.getTreeBuilder();
List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(foldersByResourceType.size());
for (ResourceFolderType type : foldersByResourceType.keySet()) {
Set<PsiDirectory> folders = foldersByResourceType.get(type);
final AndroidResFolderTypeNode androidResFolderTypeNode = new AndroidResFolderTypeNode(myProject, getValue(), Lists.newArrayList(folders), getSettings(), type, myProjectViewPane);
children.add(androidResFolderTypeNode);
// Inform the tree builder of the node that this particular virtual file maps to
for (PsiDirectory folder : folders) {
treeBuilder.createMapping(folder.getVirtualFile(), androidResFolderTypeNode);
}
}
return children;
}
use of com.android.tools.idea.navigator.AndroidProjectTreeBuilder 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;
}
Aggregations