Skip to content

fix: restore JTreeTable expand/collapse broken by #7703 - #7709

Merged
Vest merged 2 commits into
PCGen:masterfrom
Vest:fix/jtreetable-expand-regression
Aug 18, 2026
Merged

fix: restore JTreeTable expand/collapse broken by #7703#7709
Vest merged 2 commits into
PCGen:masterfrom
Vest:fix/jtreetable-expand-regression

Conversation

@Vest

@Vest Vest commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

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 MouseEvent to the embedded JTree so it can toggle the expand/collapse handle. #7703 replaced the deprecated getModifiers() with getModifiersEx() to clear a deprecation warning, but kept the 8-arg MouseEvent constructor — whose modifiers parameter takes legacy InputEvent bits, not extended ones.

Feeding extended bits (e.g. BUTTON1_DOWN_MASK = 0x400) into that legacy slot yields an event BasicTreeUI no longer recognises as a plain button-1 click, so the disclosure triangles stop responding.

Fix

Switch to the 9-arg MouseEvent constructor, whose modifiers parameter is documented to accept extended modifiers (paired with getModifiersEx()), and pass me.getButton() through. This preserves #7703's deprecation cleanup and forwards a faithful event.

-MouseEvent newME = new MouseEvent(tree, me.getID(), me.getWhen(), me.getModifiersEx(), me.getX(),
-    me.getY(), me.getClickCount(), me.isPopupTrigger());
+MouseEvent newME = new MouseEvent(tree, me.getID(), me.getWhen(), me.getModifiersEx(), me.getX(),
+    me.getY(), me.getClickCount(), me.isPopupTrigger(), me.getButton());

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.

  • Fails on the old 8-arg form (button ... expected: <1> but was: <0> — the 8-arg constructor has no button parameter, so it collapses to NOBUTTON).
  • Passes on the 9-arg form.

Runs headlessly, consistent with the project's test configuration.

Verification

  • Confirmed the regression live in the Select Sources dialog and confirmed the fix restores mouse + keyboard expansion.
  • New test verified fail-on-bug / pass-on-fix; existing JTreeTableEditingRowTest still passes.

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.
@Vest Vest self-assigned this Aug 18, 2026
@Vest Vest added the bug label Aug 18, 2026
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.
@Vest
Vest merged commit 71eb0e8 into PCGen:master Aug 18, 2026
4 checks passed
@Vest
Vest deleted the fix/jtreetable-expand-regression branch August 18, 2026 21:53
@github-actions

Copy link
Copy Markdown
Contributor

🚧 PCGen Code Coverage

Overall Project 25.93%
Files changed 100% 🍏

File Coverage
JTreeTable.java 41.81% 🍏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant