-
Enhancement
-
Resolution: Unresolved
-
P4
-
8u40
-
8u40b12
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());
}
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());
}
- relates to
-
JDK-8087910 [TableView] TableView: selection state lost on filtering
- Open