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

FilteredList: support fine-grained change notification on filtering

XMLWordPrintable

      FilteredList fires a replaced on filtering without trying for a finer-grained notification (see below). That's unfortunate for listeners that must keep some state "sticky" to filtered indices (f.i. selection state in TableView, see RT-39289 ).

      As it goes to great length (fortunately!) on adapting changes to the backing list properly, it should be similarly supportive in refilter.

          @Test
          public void testFilteredListOneFiltered() {
              ObservableList<String> list = createObservableList(true);
              FilteredList filtered = list.filtered(p -> true);
              ListChangeReport report = new ListChangeReport(filtered);
              // keep all except the third, equivalent to removing one item
              filtered.setPredicate(p-> p != list.get(2));
              Change c = report.getLastListChange();
              c.next();
              assertTrue("expected: single remove but was: " + c, c.wasRemoved() && !c.wasAdded());
          }

            Unassigned Unassigned
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Imported: