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

ListCell Item not updated when ListView items change

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0
    • Component/s: javafx
    • Labels:
      None

      Description

      It appears that we do not currently bind the ListCell to the ListView.items, such that when the items changes the cells are updated. For example, the following code has a ListCell who's range is beyond that of the ListView.items. The items is updated however, and it should then be in range such that the cell.getItem() method should return an actual item, but it doesn't.

          @Before public void setup() {
              cell = new ListCell<String>();
              model = FXCollections.observableArrayList("Apples", "Oranges", "Pears");
              list = new ListView<String>(model);
          }

          @Test public void itemIsUpdatedWhenItWasOutOfRangeButUpdatesToListViewItemsMakesItInRange() {
              cell.updateIndex(4);
              cell.updateListView(list);
              model.addAll("Pumpkin", "Lemon");
              assertSame(model.get(4), cell.getItem());
          }


      Now in the real code, the ListViewSkin is probably listening to the TableView and managing this update, for performance reasons (one listener vs. thousands of listeners). However this creates something of an odd situation where the API and implementation of ListCell, in isolation of an "intelligent" skin, doesn't work. Now, it does keep track of the selection model and focus model, leading one to think it ought to also keep track of the ListView's items.

        Attachments

          Activity

            People

            • Assignee:
              rbair Richard Bair
              Reporter:
              rbair Richard Bair
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: