Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8170080

TreeTableView: Selection is not restored correctly for nodes with a depth greater one

    XMLWordPrintable

Details

    • x86_64
    • windows_7

    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 ----------

      Attachments

        Issue Links

          Activity

            People

              arapte Ambarish Rapte
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: