-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8193800: TreeTableView selection changes on sorting #244
Conversation
👋 Welcome back arapte! A progress list of the required criteria for merging this PR into |
Webrevs
|
/reviewers 2 |
@kevinrushforth |
@aghaisas can you also review this? |
modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableView.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The algorithm looks correct to me for sorting. How much regression testing have you done for cases where rows or columns are inserted?
I left a few comments, and will complete my testing in parallel.
modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableView.java
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableView.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/TreeTablePosition.java
Outdated
Show resolved
Hide resolved
I have tested with a small TreeTableView of 15 rows of 3 levels and 3 columns. Update: I am testing with 7 level of nested rows, with 10, 9, 7, 6, 5, 4, 3 number of children in each level respectively. The fix works fine till level 3. But can observe issue with level 4 and further. Shall debug this more and update. |
hmm .. TreeModificationEvent seems to have a different interpretation (than a list change) of permutated: its wasPermutated may return true even on a replace - that's probably why some tests are throwing a IllegalStateException before the fix. The other way round: do we really want to introduce a singularity in selection handling after replace? The other selectionModels for virtualized controls try to keep the selectedItem/Index only. |
need a break ;) Will come back later with an example comparing the behavior of multiple selection state across virtualized controls - preliminary results Sort:
Replace with same items in different sequence
Published an example to play with. |
OK, thanks. In addition to making sure that insertion, deletion, and sorting work, are you also checking that the events being sent are as expected? |
Unrelated to this fix I see two pain points (which were not introduced here :) A. replaced vs. permutatedThese are types of change as decided by the list (aka: model) - treeModificationEvent (aka: view) must follow the lead (vs. spreading its own interpretation). Doing so is a bug, IMO. B. treeTableView.sort changing internals of the selectionModelthat's a no-no-no-go, always. Instead let the selectionModel handle the permutated state correctly (didn't dig why it was deemed necessary to do so in sort - though it has the side-effect of leaving out selectionModels that are not of the expected type) |
In the above case, The selection updates correctly but the received change event on SelectedItems is incorrect. As of now it looks like the selection is updated correctly with this fix, but the event generated from sort() method is always incorrect. Looking in to fix the change event.... |
Keeping the selection after sort/permutation seems more correct from a user's perspective. I did not look into how other controls handle this. Looking at your observation seems like we need to fix this in other controls too, preferably each control in a separate issue :) |
well, I don't think so (except for tree which is doing the-wrong-thingy-always): they do keep all state on sort, but not on replace-in-different-sequence - which is correct, I think: it's the semantic of the change notification that must rule, not some assumption of the view. If a replace-in-different-sequence is required to be interpretated as a permutation in a particular use-case, the place to implement it would be a custom list that checks for that corner case and sends a notification of type wasPermutated (instead of a wasReplaced). |
Hi @ebresie, thanks for making a comment in an OpenJDK project! All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user ebresie for the summary. If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.
Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use. |
Please take a look at the updated changes. The |
modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableView.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good now with one suggested cleanup.
The tests will catch the bug (including the most recently fixed problem), but I noted a couple of issues with the test inline below.
modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableView.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java
Show resolved
Hide resolved
Pending a second reviewer. @aghaisas or @kleopatra can one of you review it? |
modules/javafx.controls/src/main/java/javafx/scene/control/TreeTablePosition.java
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableView.java
Outdated
Show resolved
Hide resolved
confirmed test failures before and passing after the fix - impressive :) While digging a bit (mainly around my earlier concerns - which still hold but could be discussed in a follow-up issue :) I came up with a NPE thrown by the newly added code block ins sort (the one walking up the parent hierarchy).
(before the fix it throws an IOOB, plus the behavior completely rotten in a visual test) Did nothing to go to the bottom of this - looks like somehow the state of the selection is (still?) broken after setAll. Which might bring us back to the replace != permutation (can't resist to try :) actually there's no reason to special case a replace with all same items against a replace with only some same items (doing so introduces a discontinuity in behavior) - we should either try to keep selected items or not. |
Yes, We need to address these issues. How should we treat permutation vs replace, which may involve answering few more small questions. Like, What should be the selected item when we remove the current selected item? What should the contents of an event be in such cases? Regarding the scenario in your test, In In the test that you provided, one
I have added a null check for now, with a reasoning comment. We will have to remove that check once we fix the other issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to the fix itself look fine. I have a question and minor comment on the test changes.
As for the questions raised by @kleopatra as long as you plan to address them in the follow-up issue(s), that seems fine, since you aren't regressing any behavior.
modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java
Outdated
Show resolved
Hide resolved
agreed - plus it's not only not regressing, but considerably improving the behavior :) |
@arapte This change now passes all automated pre-integration checks. When the change also fulfills all project specific requirements, type
Since the source branch of this PR was last updated there have been 14 commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge ➡️ To integrate this PR with the above commit message to the |
/integrate |
@arapte The following commits have been pushed to master since your change was applied:
Your commit was automatically rebased without conflicts. Pushed as commit 2ca509a. |
Issue:
In TreeTableView, in case of Multiple selection mode, if nested items are selected, then TreeTableView does not retain/update the selection correctly when the tree items are permuted(either by
sort()
or by reordering usingsetAll()
).Cause:
TreeModificationEvent
to update the selection.TreeTablePosition
constructor to create intermediateTreeItem
positions, this constructor results in another unexpected TreeModificationEvent while one for sorting is already being processed.All these issues combine in wrong update of the selection.
Fix:
shiftSelection()
should not be called in case of permutation i.e. callif (shift != 0)
Verification:
The change is very limited to updating of selection of TreeTableView items when the TreeItems are permuted, so the change should not cause any other failures.
Added unit tests which fail before and pass after the fix.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jfx pull/244/head:pull/244
$ git checkout pull/244