JDK-8170080 : TreeTableView: Selection is not restored correctly for nodes with a depth greater one
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8,9
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2016-11-19
  • Updated: 2020-06-26
  • Resolved: 2020-06-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 10 x64

A DESCRIPTION OF THE PROBLEM :
When using a TreeTableView with default selection model, the selection is not restored reliably after sorting. The bug maybe related to JDK-8169642.

REGRESSION.  Last worked in version 8u112

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Execute the sample app (see sourcecode)
2) Select node "1" and switch the sort order by clicking the column header
-> The selection remains on node "1" -> OK
3) Select node "1.1" and switch the sort order by clicking the column header
-> The selection switches to "1.4" -> NOT OK

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect the same node to be selected before and after sorting.
ACTUAL -
The selection is not restored correctly for nodes with a depth greater than one.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Scene;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableView;
import javafx.stage.Stage;

public class TreeTableViewSelectionRestoreAfterSortBug extends Application{
	
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		final TreeItem<String> rootItem = new TreeItem<>("root");
		
		final TreeItem<String> firstChild = new TreeItem<>("1");
		firstChild.getChildren().add(new TreeItem<>("1.1"));
		firstChild.getChildren().add(new TreeItem<>("1.2"));
		firstChild.getChildren().add(new TreeItem<>("1.3"));
		firstChild.getChildren().add(new TreeItem<>("1.4"));
		
		final TreeItem<String> secondChild = new TreeItem<>("2");
		secondChild.getChildren().add(new TreeItem<>("2.1"));
		secondChild.getChildren().add(new TreeItem<>("2.2"));
		secondChild.getChildren().add(new TreeItem<>("2.3"));
		secondChild.getChildren().add(new TreeItem<>("2.4"));
		
		rootItem.getChildren().addAll(firstChild, secondChild);

		final TreeTableView<String> tree = new TreeTableView<>(rootItem);
		final TreeTableColumn<String, String> column = new TreeTableColumn<>("first column");
		column.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getValue()));
		tree.getColumns().add(column);
		
		final Scene scene = new Scene(tree);
		primaryStage.setScene(scene);
		primaryStage.sizeToScene();
		primaryStage.show();
	}
}

---------- END SOURCE ----------


Comments
This is same as JDK-8193800, that selection is not updated correctly after sorting
26-06-2020

Verified this issue against 8,8u112,8u122ea,9ea on Windows 7 and could confirm the issue as reported by the bug submitter. Steps to reproduce: ************************* - Run the attached test application(TreeTableViewSelectionRestoreAfterSortBug .java) with JDK. - Select node "1" and switch the sort order by clicking the column "first column" => [getting the proper behavior] - Select node "1.1" and switch the sort order by clicking the column "first column" => [It should restore the column at the first click] Result: ********* OS : windows 7 64 bit JDK: 8 b32 : Fail 8u112 b14: Fail 8u122ea b02: Fail 9ea+144 : Fail ================================================================================================================
21-11-2016