mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ProjectView: 'sort by type' mixes up folders and files
This commit is contained in:
@@ -44,7 +44,7 @@ public class ProjectTreeSortingTest extends BaseProjectViewTestCase {
|
||||
myOriginalSortByType = myProjectView.isSortByType(myPane.getId());
|
||||
myOriginalFoldersAlwaysOnTop = ((ProjectViewImpl)myProjectView).isFoldersAlwaysOnTop();
|
||||
|
||||
TreeUtil.expandAll(myPane.getTree());
|
||||
TreeUtil.expand(myPane.getTree(), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,10 +78,8 @@ public class ProjectTreeSortingTest extends BaseProjectViewTestCase {
|
||||
|
||||
((ProjectViewImpl)myProjectView).setFoldersAlwaysOnTop(true);
|
||||
assertTree("-foldersOnTop\n" +
|
||||
" -b.java\n" +
|
||||
" dummy.txt\n" +
|
||||
" -b.txt\n" +
|
||||
" dummy.txt\n" +
|
||||
" +b.java\n" +
|
||||
" +b.txt\n" +
|
||||
" a.java\n" +
|
||||
" a.txt\n" +
|
||||
" c.java\n" +
|
||||
@@ -91,10 +89,8 @@ public class ProjectTreeSortingTest extends BaseProjectViewTestCase {
|
||||
assertTree("-foldersOnTop\n" +
|
||||
" a.java\n" +
|
||||
" a.txt\n" +
|
||||
" -b.java\n" +
|
||||
" dummy.txt\n" +
|
||||
" -b.txt\n" +
|
||||
" dummy.txt\n" +
|
||||
" +b.java\n" +
|
||||
" +b.txt\n" +
|
||||
" c.java\n" +
|
||||
" c.txt\n");
|
||||
|
||||
@@ -103,26 +99,46 @@ public class ProjectTreeSortingTest extends BaseProjectViewTestCase {
|
||||
|
||||
((ProjectViewImpl)myProjectView).setFoldersAlwaysOnTop(true);
|
||||
assertTree("-foldersOnTop\n" +
|
||||
" -b.java\n" +
|
||||
" dummy.txt\n" +
|
||||
" -b.txt\n" +
|
||||
" dummy.txt\n" +
|
||||
" +b.java\n" +
|
||||
" +b.txt\n" +
|
||||
" a.java\n" +
|
||||
" c.java\n" +
|
||||
" a.txt\n" +
|
||||
" c.txt\n");
|
||||
|
||||
((ProjectViewImpl)myProjectView).setFoldersAlwaysOnTop(false);
|
||||
// extension of the folder is not taken into account, fallback to name sorting here
|
||||
assertTree("-foldersOnTop\n" +
|
||||
" a.java\n" +
|
||||
" -b.java\n" +
|
||||
" dummy.txt\n" +
|
||||
" -b.txt\n" +
|
||||
" dummy.txt\n" +
|
||||
" c.java\n" +
|
||||
" a.txt\n" +
|
||||
" c.txt\n");
|
||||
" c.txt\n" +
|
||||
" +b.java\n" +
|
||||
" +b.txt\n");
|
||||
}
|
||||
|
||||
public void testSortByTypeBetweenFilesAndFolders() throws Exception {
|
||||
((ProjectViewImpl)myProjectView).setFoldersAlwaysOnTop(false);
|
||||
myProjectView.setSortByType(myPane.getId(), false);
|
||||
assertTree("-sortByTypeBetweenFilesAndFolders\n" +
|
||||
" a.java\n" +
|
||||
" +a.java_folder\n" +
|
||||
" a.txt\n" +
|
||||
" +a_folder\n" +
|
||||
" b.java\n" +
|
||||
" +b.java_folder\n" +
|
||||
" b.txt\n" +
|
||||
" +b_folder\n");
|
||||
|
||||
myProjectView.setSortByType(myPane.getId(), true);
|
||||
assertTree("-sortByTypeBetweenFilesAndFolders\n" +
|
||||
" a.java\n" +
|
||||
" b.java\n" +
|
||||
" a.txt\n" +
|
||||
" b.txt\n" +
|
||||
" +a.java_folder\n" +
|
||||
" +a_folder\n" +
|
||||
" +b.java_folder\n" +
|
||||
" +b_folder\n");
|
||||
}
|
||||
|
||||
private void assertTree(String expected) {
|
||||
|
||||
@@ -85,7 +85,9 @@ public class GroupByTypeComparator implements Comparator<NodeDescriptor> {
|
||||
if (isSortByType()) {
|
||||
final Comparable typeSortKey1 = node1.getTypeSortKey();
|
||||
final Comparable typeSortKey2 = node2.getTypeSortKey();
|
||||
if (typeSortKey1 != null && typeSortKey2 != null) {
|
||||
if (!(typeSortKey1 == null && typeSortKey2 == null)) {
|
||||
if (typeSortKey1 == null) return 1;
|
||||
if (typeSortKey2 == null) return -1;
|
||||
//noinspection unchecked
|
||||
final int result = typeSortKey1.compareTo(typeSortKey2);
|
||||
if (result != 0) return result;
|
||||
|
||||
Reference in New Issue
Block a user