To reproduce:
- add items "a","b","c","d"
- select item "b"
- remove items "b","c" using removeAll method
expected:
- getSelectedItem() returns "a", getSelectedIndex() returns 0
- getSelectedItems().get(0) returns "a", getSelectedIndices().get(0) returns 0
actual:
- getSelectedItem() returns "b", getSelectedIndex() returns 1
- getSelectedItems().get(0) returns null, getSelectedIndices().get(0) returns -1
Test case to reproduce:
@Test
public void testListViewSelectionChanges() throws Exception {
new JFXPanel();
ListView<String> stringListView = new ListView<>();
stringListView.getItems().addAll("a","b","c","d");
stringListView.getSelectionModel().select("b");
stringListView.getItems().removeAll("b","c");
Assert.assertEquals(0, stringListView.getSelectionModel().getSelectedIndex());
Assert.assertEquals(Integer.valueOf(0), stringListView.getSelectionModel().getSelectedIndices().get(0));
Assert.assertEquals("a", stringListView.getSelectionModel().getSelectedItem());
Assert.assertEquals("a", stringListView.getSelectionModel().getSelectedItems().get(0));
}
- add items "a","b","c","d"
- select item "b"
- remove items "b","c" using removeAll method
expected:
- getSelectedItem() returns "a", getSelectedIndex() returns 0
- getSelectedItems().get(0) returns "a", getSelectedIndices().get(0) returns 0
actual:
- getSelectedItem() returns "b", getSelectedIndex() returns 1
- getSelectedItems().get(0) returns null, getSelectedIndices().get(0) returns -1
Test case to reproduce:
@Test
public void testListViewSelectionChanges() throws Exception {
new JFXPanel();
ListView<String> stringListView = new ListView<>();
stringListView.getItems().addAll("a","b","c","d");
stringListView.getSelectionModel().select("b");
stringListView.getItems().removeAll("b","c");
Assert.assertEquals(0, stringListView.getSelectionModel().getSelectedIndex());
Assert.assertEquals(Integer.valueOf(0), stringListView.getSelectionModel().getSelectedIndices().get(0));
Assert.assertEquals("a", stringListView.getSelectionModel().getSelectedItem());
Assert.assertEquals("a", stringListView.getSelectionModel().getSelectedItems().get(0));
}
- relates to
-
JDK-8094602 [TreeItem] Incompatible API change to TreeItem$TreeModificationEvent constructor
- Resolved
-
JDK-8097697 Review API for 8u40
- Resolved
-
JDK-8090563 Tree/Item/ModificationEvent: must fully support list changes
- Open