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

ListChangeListenter for multiple selection TreeView gets excessive calls and misleading information

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 7u21
    • javafx
    • None
    • Java 7 update 21 on Windows and Mac OS.

    Description

      I'm seeing similar symptoms to RT-25038 . But taking it a step further, if I establish a ListChangeListener via TreeView.getSelectionModel().getSelectedItems().addListener(listChangeListener), then inside the onChanged method, the ListChangeListener.Change parameter shows strange behavior as well.

      1) If I select a contiguous range of three, collapsed, non-leaf nodes, then expand the top node in the range, I end up with 4 selected nodes showing on the screen, plus 4 elements in ListChangeListener.Change.getList(), one of the elements null.

      2) If I click a node to select it, then click it again, onChange gets called with wasAdded()==true and getAddedSize()=1 for both clicks, even though the second click didn't add any selected elements. There is no corresponding wasRemoved() event for the second click, nor do I think there should be; to me, selecting an already selected node should not generate any event.

      3) Continuing with the previous bullet, if I click another node to select it instead, I get a wasAdded() event, but still no wasRemoved(), even though the former selection is gone. No surprisingly, MultipleSelectionModel.clearAndSelect(int) yields the same result.

      4) If I select a node, then shift-click two nodes down to select a range of three nodes, I get three calls to onChange with the following values for the parameter:
        * wasRemoved()==true, getRemovedSize()==1, getList().size()==0
        * wasAdded()==true, getAddedSize()==1, getList().size()==3 (Note: added only 1, but list size is 3, so those two numbers are out of synch)
        * wasAdded()==true, getAddedSize()==2, getList().size()==3 (Now it catches up).

      5) If I select a collapsed node, then expand it, the expansion click generates an onChange event with wasPermutated()==true even though the return from getList() is unchanged.

      My app wants to do a database query based on changes to selected nodes, so excessive calls to onChange will be costly. Ideally, there should be one call to onChange for any click that generates a change to the list, and zero calls if the click did not result in any net change to the list.
       
      I'm open to supplying more detail or sample code if it helps.

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            djansenjfx Dave Jansen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: