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

CheckBoxTreeItem: must update check state on modifications to children list

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u60
    • javafx
    • 8u60b5, win7

      title says it all ;-)

      Below is a test that exposes the misbehaviour for the case of removing a selected CheckBoxTreeItem, Too lazy to write the tests for other list modifications, but pretty sure that it's the same for adding/replacing items

          /**
           * CheckBoxTreeItem must update parent state when modifying the
           * children list.
           */
          @Test
          public void testCheckBoxTreeItemDataModification() {
              CheckBoxTreeItem checkBoxRoot = createCheckBoxSubTree("checked-root");
              checkBoxRoot.setExpanded(true);
              tree.setRoot(checkBoxRoot);
              CheckBoxTreeItem child = (CheckBoxTreeItem) checkBoxRoot.getChildren().get(2);
              child.setSelected(true);
              assertTrue(checkBoxRoot.isIndeterminate());
              root.getChildren().remove(child);
              assertFalse("root must update its check state on modifications to children list",
                      checkBoxRoot.isIndeterminate());
          }

          protected CheckBoxTreeItem createCheckBoxItem(Object item) {
              return new CheckBoxTreeItem(item);
          }

          protected ObservableList<CheckBoxTreeItem> createCheckBoxItems(ObservableList other) {
              ObservableList items = FXCollections.observableArrayList();
              other.stream().forEach(item -> items.add(createCheckBoxItem(item)));
              return items;
          }

          protected CheckBoxTreeItem createCheckBoxSubTree(Object item) {
              CheckBoxTreeItem child = createCheckBoxItem(item);
              child.getChildren().setAll(createCheckBoxItems(rawItems));
              return child;
          }



            aghaisas Ajit Ghaisas
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported: