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

[TreeTableView, TreeTableColumn] Fix incomplete API documentation and TODOs

XMLWordPrintable

      Aurelio wrote the following:

      I was playing around with the EA for JDK 8 and scene builder 2.0 EA and tried to use a treetableview control.

      The documentation that I found:
      http://download.java.net/jdk8/jfxdocs/javafx/scene/control/TreeTableView.html

      Has a few "interesting" comments on the samples. eg:

      TODO update to a relevant example
      ..

      // TODO update - this is not correct for TreeTableView
      ...
      // TODO this is not valid TreeTableView code
      ...
          

      In two cases I figured out what I think is the correct code.

      Where we have:

      TreeItem<File> root = new TreeItem<File>(new File("/"));
      treeTable.setRoot(root);

      // TODO this is not valid TreeTableView code
      TreeTableColumns<Person,String> firstNameCol = new TreeTableColumns<Person,String>("First Name");
      firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
      TreeTableColumns<Person,String> lastNameCol = new TreeTableColumns<Person,String>("Last Name");
      lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));

      We should have:

      TreeItem<File> root = new TreeItem<File>(new File("/"));
      treeTable.setRoot(root);

      TreeTableColumns<Person,String> firstNameCol = new TreeTableColumns<Person,String>("First Name");
      firstNameCol.setCellValueFactory(new TreeItemPropertyValueFactory("firstName"));
      TreeTableColumns<Person,String> lastNameCol = new TreeTableColumns<Person,String>("Last Name");
      lastNameCol.setCellValueFactory(new TreeItemPropertyValueFactory("lastName"));

      and instead of

      firstNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
          public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
              // p.getValue() returns the Person instance for a particular TreeTableView row
              return p.getValue().firstNameProperty();
          }
      });

      We should have:

      firstNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
          public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
              // p.getValue() returns the TreeItem instance for a particular
              // TreeTableView row, and the second getValue() call returns the
              // Person instance contained within the TreeItem.
              return p.getValue().getValue().firstNameProperty();
          }
      });

      I am sure there are other changes required but if these two had been there it would have made my life much simpler

      Can you check my "solutions" with the right technical person and if correct task the right person with updating the docs?

            jgiles Jonathan Giles
            kcr Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: