A DESCRIPTION OF THE PROBLEM :
In a TableView, with Multiple selection, we have a listener on the on the selectedItems() of the selection model.
In this listener we replicate the added and removed selection event on some third party list.
We have noticed that the event sometimes provides incorrect items in ListChangeEvent#getRemoved.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See source code. The clearAndSelect is intended to mimick the user clicking on a single item after selecting multiple items.
After calling a clearAndSelect to select s1 only, ListChangeEvent#getRemoved gives a list that incorrectly contains s1.
---------- BEGIN SOURCE ----------
TableView<String> view = new TableView<>();
TableView.TableViewSelectionModel<String> selectionModel = view.getSelectionModel();
selectionModel.setSelectionMode( SelectionMode.MULTIPLE );
String s0 = "s0";
String s1 = "s1";
String s2 = "s2";
String s3 = "s3";
view.getItems().add( s0 );
view.getItems().add( s1 );
view.getItems().add( s2 );
view.getItems().add( s3 );
selectionModel.getSelectedItems().addListener( ( ListChangeListener<String> ) aChange -> {
while(aChange.next()) {
System.out.println(aChange);
for ( String removedString : aChange.getRemoved() ) {
// Assertion fails: s1 is in the removed list but is still (correctly) in the items list.
assert( aChange.getList().contains( removedString ) == false );
}
}
} );
selectionModel.select( s0 );
selectionModel.select( s1 );
selectionModel.select( s2 );
selectionModel.select( s3 );
// Select only s1.
selectionModel.clearAndSelect( view.getItems().indexOf( s1 ) );
---------- END SOURCE ----------
FREQUENCY : always
In a TableView, with Multiple selection, we have a listener on the on the selectedItems() of the selection model.
In this listener we replicate the added and removed selection event on some third party list.
We have noticed that the event sometimes provides incorrect items in ListChangeEvent#getRemoved.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See source code. The clearAndSelect is intended to mimick the user clicking on a single item after selecting multiple items.
After calling a clearAndSelect to select s1 only, ListChangeEvent#getRemoved gives a list that incorrectly contains s1.
---------- BEGIN SOURCE ----------
TableView<String> view = new TableView<>();
TableView.TableViewSelectionModel<String> selectionModel = view.getSelectionModel();
selectionModel.setSelectionMode( SelectionMode.MULTIPLE );
String s0 = "s0";
String s1 = "s1";
String s2 = "s2";
String s3 = "s3";
view.getItems().add( s0 );
view.getItems().add( s1 );
view.getItems().add( s2 );
view.getItems().add( s3 );
selectionModel.getSelectedItems().addListener( ( ListChangeListener<String> ) aChange -> {
while(aChange.next()) {
System.out.println(aChange);
for ( String removedString : aChange.getRemoved() ) {
// Assertion fails: s1 is in the removed list but is still (correctly) in the items list.
assert( aChange.getList().contains( removedString ) == false );
}
}
} );
selectionModel.select( s0 );
selectionModel.select( s1 );
selectionModel.select( s2 );
selectionModel.select( s3 );
// Select only s1.
selectionModel.clearAndSelect( view.getItems().indexOf( s1 ) );
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8196065 ListChangeListener getRemoved() returns items that were not removed.
-
- Resolved
-
- relates to
-
JDK-8196065 ListChangeListener getRemoved() returns items that were not removed.
-
- Resolved
-