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

MultipleSelectionModel provides incorrect 'removed' sub-list in change events

      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


          Loading...
          Uploaded image for project: 'JDK'
          1. JDK
          2. JDK-8255935

          MultipleSelectionModel provides incorrect 'removed' sub-list in change events

              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


                    mstrauss Michael Strauß
                    webbuggrp Webbug Group
                    Votes:
                    0 Vote for this issue
                    Watchers:
                    4 Start watching this issue

                      Created:
                      Updated:
                      Resolved:

                        mstrauss Michael Strauß
                        webbuggrp Webbug Group
                        Votes:
                        0 Vote for this issue
                        Watchers:
                        4 Start watching this issue

                          Created:
                          Updated:
                          Resolved: