fix: restore JTreeTable expand/collapse broken by #7703 - #7709
Merged
Conversation
PR PCGen#7703 swapped the tree-column editor's forwarded MouseEvent from the deprecated getModifiers() to getModifiersEx(), but left it on the 8-arg MouseEvent constructor whose `modifiers` parameter takes LEGACY InputEvent bits. Feeding extended bits (e.g. BUTTON1_DOWN_MASK) into that legacy slot produces an event BasicTreeUI no longer recognises as a plain click, so the disclosure triangles in Select Sources (and other JTreeTables) stopped expanding via mouse and keyboard. Fix: use the 9-arg constructor, whose `modifiers` parameter is documented to accept extended modifiers (getModifiersEx), and pass me.getButton() through. This keeps PCGen#7703's deprecation cleanup and forwards a faithful event. Adds JTreeTableEditorEventForwardingTest, which captures the event the editor re-dispatches to the tree and asserts the extended modifiers and button survive the round-trip. It fails on the 8-arg form (button collapses to NOBUTTON) and passes on the 9-arg form.
Parameterize over clickCount {1, 2} and assert the forwarded event keeps
its button, extended modifiers and click count so BasicTreeUI can toggle
the node on both a single and a double click.
Contributor
🚧 PCGen Code Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After #7703, tree nodes in the Select Sources dialog (and every other
JTreeTable) can no longer be expanded or collapsed with the mouse or keyboard.Root cause
The tree-column editor forwards a synthetic
MouseEventto the embeddedJTreeso it can toggle the expand/collapse handle. #7703 replaced the deprecatedgetModifiers()withgetModifiersEx()to clear a deprecation warning, but kept the 8-argMouseEventconstructor — whosemodifiersparameter takes legacyInputEventbits, not extended ones.Feeding extended bits (e.g.
BUTTON1_DOWN_MASK = 0x400) into that legacy slot yields an eventBasicTreeUIno longer recognises as a plain button-1 click, so the disclosure triangles stop responding.Fix
Switch to the 9-arg
MouseEventconstructor, whosemodifiersparameter is documented to accept extended modifiers (paired withgetModifiersEx()), and passme.getButton()through. This preserves #7703's deprecation cleanup and forwards a faithful event.Test
Adds
JTreeTableEditorEventForwardingTest: it captures the event the editor re-dispatches to the tree and asserts the extended modifiers and button survive the round-trip.button ... expected: <1> but was: <0>— the 8-arg constructor has no button parameter, so it collapses toNOBUTTON).Runs headlessly, consistent with the project's test configuration.
Verification
JTreeTableEditingRowTeststill passes.