Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
/ jfx11u Public archive

Commit

Permalink
8284676: TreeTableView loses sort ordering when applied on empty table
Browse files Browse the repository at this point in the history
Backport-of: 0132ac89033334ec9d9ec6149d116e8c352f89ec
  • Loading branch information
arapte committed Aug 17, 2022
1 parent 19268eb commit 190dddf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,13 @@ public static int getNodeLevel(TreeItem<?> node) {
@Override public Boolean call(TreeTableView table) {
try {
TreeItem rootItem = table.getRoot();
if (rootItem == null || rootItem.getChildren().isEmpty()) return false;
if (rootItem == null) return false;

TreeSortMode sortMode = table.getSortMode();
if (sortMode == null) return false;

if (rootItem.getChildren().isEmpty()) return true;

rootItem.lastSortMode = sortMode;
rootItem.lastComparator = table.getComparator();
rootItem.sort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,18 @@ private void verifySelectionAfterPermutation() {
});
}

@Test public void testSetSortOrderRetainsWhenRootHasNoChildren() {
TreeTableView<String> ttv = new TreeTableView<>();
TreeItem<String> root = new TreeItem<>("root");
root.setExpanded(true);
ttv.setRoot(root);
assertEquals(0, ttv.getSortOrder().size());

TreeTableColumn<String, String> ttc = new TreeTableColumn<>("Column");
ttv.getSortOrder().add(ttc);
assertEquals(1, ttv.getSortOrder().size());
}

@Test public void testNPEWhenRootItemIsNull() {
TreeTableView<String> ttv = new TreeTableView<>();
ControlTestUtils.runWithExceptionHandler(() -> {
Expand Down

1 comment on commit 190dddf

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.