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

TableView.getSelectionModel().getSelectedItems() fires bad events on sort

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      C:\Users\hwaite>ver

      Microsoft Windows [Version 10.0.16299.547]

      C:\Users\hwaite>"%JAVA_HOME%"\bin\java -version
      java version "1.8.0_181"
      Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      TableView.getSelectionModel().getSelectedItems() returns an ObservableList to which ListChangeListeners can be added. When TableView is backed by a SortedList, item mutation may trigger a change in sort order. In this case, the resultant ListChangeListener.Change event will consist of a single 'add' change.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create ObservableList with an extractor
      2. Populate list with sample objects
      3. Decorate base list with SortedList
      4. Call TableView.setItems(sortedList)
      5. Call sortedList.comparatorProperty().bind(tableView.comparatorProperty())
      6. Add listener: tableView.getSelectionModel().getSelectedItems().addListener(listChangeListener)
      7. Sort table on mutable property
      8. Modify table item such that sort order is changed
      9. listChangeListener receives invalid events


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect a list change event with single 'permutation' sub-event.
      ACTUAL -
      List change event with 'add' sub-event

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              aghaisas Ajit Ghaisas
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: