Project View: sort directories by type as well (e.g. OS X bundles .app, .framework)

This commit is contained in:
Anton Makeev
2014-10-22 15:48:31 +02:00
parent a3b5205ae4
commit 16ab0a8322
2 changed files with 13 additions and 5 deletions
@@ -132,11 +132,11 @@ public class ProjectTreeSortingTest extends BaseProjectViewTestCase {
((ProjectViewImpl)myProjectView).setFoldersAlwaysOnTop(false);
assertTree("-foldersOnTop\n" +
" a.java\n" +
" +b.java\n" +
" c.java\n" +
" a.txt\n" +
" c.txt\n" +
" +b.java\n" +
" +b.txt\n");
" +b.txt\n"+
" c.txt\n");
}
public void testSortByTypeBetweenFilesAndFolders() throws Exception {
@@ -156,11 +156,11 @@ public class ProjectTreeSortingTest extends BaseProjectViewTestCase {
assertTree("-sortByTypeBetweenFilesAndFolders\n" +
" a.java\n" +
" b.java\n" +
" +a.java_folder\n" +
" +b.java_folder\n" +
" a.txt\n" +
" b.txt\n" +
" +a.java_folder\n" +
" +a_folder\n" +
" +b.java_folder\n" +
" +b_folder\n");
}
@@ -318,6 +318,14 @@ public class PsiDirectoryNode extends BasePsiNode<PsiDirectory> implements Navig
return null;
}
@Override
public Comparable getTypeSortKey() {
VirtualFile file = getVirtualFile();
if (file == null) return null;
String extension = file.getExtension();
return extension == null ? null : new PsiFileNode.ExtensionSortKey(extension);
}
@Override
public String getQualifiedNameSortKey() {
final PsiDirectoryFactory factory = PsiDirectoryFactory.getInstance(getProject());