Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
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
8242489: ChoiceBox: initially toggle not sync'ed to selection #177
8242489: ChoiceBox: initially toggle not sync'ed to selection #177
Changes from all commits
017be22
0d3ce12
01aa790
File filter...
Jump to…
arapteApr 15, 2020
Member
I would recommend to prefix the method name with
test_.
It is not followed across, onlyTabPaneSkin
hastest_
prefixed method.kleopatraApr 16, 2020
Author
Collaborator
well, as TabPaneSkin is a singularity in controls (in graphics such a pattern seems to be wider-spread), I would prefer not to do it here - also because ChoiceBoxSkin has another test-only accessor (for label text) which doesn't. Might be a candidate for a general cleanup task - if we decide to really introduce such a naming convention (which I personally wouldn't like :)
arapteApr 15, 2020
Member
The
else
part here means that user programmatically has selected aSeparator
orSeparatorMenuItem
. The behavior in such scenario is not defined in doc but the methods,select()
,selectNext()
,selectPrevious()
ofChoiceBox.ChoiceBoxSelectionModel
imply that if index points to aSeparator
then a valid item should be selected. However these method do handle this correctly.If these methods are implemented such that no Separator is allowed to be selected then this
else
part would not be needed and we might be able to remove theinstanceof
checks.The fix in this PR looks good to me.
But we should also decide the behavior in above scenario and may be file a JBS.
If we decide that when a
Separator
is chosen for selection then the current selection should not be changed or a valid item should be selected, then the test related to Separator selection need to be changed. Or all of it can be handled in a follow on issue.kleopatraApr 16, 2020
Author
Collaborator
- do nothing for a (don't feel like filing yet another bug around selection ;) and b (the skin behaves correctly, I think)
- fix the test to be resistant against implementation changes of selectionModel
yeah, you are right:
a) the implementation of ChoiceBoxSelectionModel is broken when it comes to handling of unselectable items (such as Separator): next/previous try to move on, the others simply select. The implementation changed in fix of JDK-8088261 - before select(index) tried to handle it, after this was moved into next/previous. Arguably, the model can do what it wants without specification ;)
b) the skin is responsible to sync the selection state of its toggles with the state of model: if the selectedIndex/Item does not have a corresponding toggle (f.i. if it's a separator), all toggles must be unselected.
c) my test related to the Separator is broken - as you correctly noted, it will fail if a future implementation decides to select a really selectable item :)
My plan:
Thanks for the extensive review, very much appreciated :)
kleopatraApr 16, 2020
Author
Collaborator
btw: just noticed that there are methods in ChoiceBoxSkin testing the fix for next/prev
the name look like they want to point to the corresponding issue .. but the id is incorrect: that id doesn't exist, should be 8088261 (spelling error, I think) - is it okay to change them to the right id?
arapteApr 16, 2020
Member
I am good with this. Though I will file a JBS for the correction in ChoiceBoxSelectionModel.
seletPrevious()
,selectNext()
need one more checkvalue instanceof SeparatorMenuItem
.and similarly
selectFirst()
andselectLast()
should be overridden correctly.and I can't think of why
select()
was changed so may be rethink about it :).We can discuss it again whenever we start fixing it.
Thanks for link to JDK-8088261, As mentioned in this bug description, "Culprit is an incorrect override of select(int): it may reject the new index if that would select a separator, but it must not select an arbitrary index instead", So It is not sure to me what should
select()
do in such scenario.So I think the test can also go as is, in case we change the behavior then test can be changed with it.
arapteApr 16, 2020
Member
That will be good to change, but not sure if as part of this bug. It will be unrelated to fix.
kleopatraApr 16, 2020
Author
Collaborator
At the end and following your latest comments I did nothing Except adding code comments to the separator test and the else (toggle nulling) branch.