Skip to content

Conversation

@Ziad-Mid
Copy link
Contributor

@Ziad-Mid Ziad-Mid commented Nov 12, 2025

When a subtree is moved in a TreeTableView , the visuals don’t update until a resize or expand/collapse. The TreeTableViewSkin only rebuilds cells when the expanded row count changes.
This PR makes the skin to detect structural changes on childrenModificationEvent using new variable treeStructureDirty, and in updateItemCount() call requestRebuildCells() to refresh the visuals.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8356770: TreeTableView not updated after removing a TreeItem with children and adding it to another parent (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1971/head:pull/1971
$ git checkout pull/1971

Update a local copy of the PR:
$ git checkout pull/1971
$ git pull https://git.openjdk.org/jfx.git pull/1971/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1971

View PR using the GUI difftool:
$ git pr show -t 1971

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1971.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 12, 2025

👋 Welcome back zelmidaoui! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 12, 2025

@Ziad-Mid This change is no longer ready for integration - check the PR body for details.

@Ziad-Mid Ziad-Mid marked this pull request as ready for review November 12, 2025 15:47
@openjdk openjdk bot added the rfr Ready for review label Nov 12, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 12, 2025

Webrevs

@andy-goryachev-oracle
Copy link
Contributor

/reviewers 2

@openjdk
Copy link

openjdk bot commented Nov 12, 2025

@andy-goryachev-oracle
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@andy-goryachev-oracle
Copy link
Contributor

andy-goryachev-oracle commented Nov 12, 2025

@Ziad-Mid can we add a unit test which fails in master and passes with the fix?

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no ill effects with the reproducer and the monkey tester (which was updated to add data manipulation context menus, see https://github.com/andy-goryachev-oracle/MonkeyTest ).

I suppose adding a flag in the skin (as opposed to similar flag in VirtualContainerBase) is ok since it deals with tree-table-specific functionality.

@Ziad-Mid
Copy link
Contributor Author

can we add a unit test which fails in master and passes with the fix?

I have added test as suggested

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding the test! Verified it fails in master and passes with the fix.

@Ziad-Mid Ziad-Mid requested a review from Maran23 November 13, 2025 19:09
Copy link
Member

@Maran23 Maran23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix should be good, commented some improvements for the test

}

@Test
void test_jdk_8356770_reparentingItem() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend a test name that reflects what exactly we want to test here. You can reference the JDK Ticket in a javadoc comment.
Example:

/**
* The content display should also be taken into consideration when measuring the width.
* See also: <a href="https://bugs.openjdk.org/browse/JDK-8186188">JDK-8186188</a>
*/
@Test
public void testResizeColumnToFitContentWithGraphicAlignment() {

table.setShowRoot(true);

stageLoader = new StageLoader(table);
Toolkit.getToolkit().firePulse();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this call really needed? Just asking because most of the time, it is not needed right after the StageLoader

Toolkit.getToolkit().firePulse();

// Find "item B" row and record its disclosure node indent
TreeTableRow<String> rowBefore = findRow(table, "item B");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using VirtualFlowTestUtils.getVirtualFlow(table).getVisibleCell(index);
The index should be easy to find out, since we always know where the TreeItem should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exact, I usually prefer not to hardcode things, but sure in this case I will modify it.

}

private static double disclosureX(TreeTableRow<String> row) {
Node disclosureNode = row.lookup(".tree-disclosure-node");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just call: row.getDisclosureNode() ?

return null;
}

private static double disclosureX(TreeTableRow<String> row) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know IntelliJ makes methods static by default (when extracting), but I don't think it makes sense here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's perfectly fine to have a static method here (and in tests in general).

control.requestLayout();
break;
}
else if (eventType.equals(TreeItem.<T>childrenModificationEvent())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: else if should be in the previous line to follow the Java Code Convention: } else if (..)

Toolkit.getToolkit().firePulse();

TreeTableRow<String> rowAfter = findRow(table, "item B");
assertNotNull(rowAfter, "item B row should not be null");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Null check is not needed, since we do test the disclosure node position instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null check is just for safety that the item exist, not that much important.

@Ziad-Mid
Copy link
Contributor Author

I have updated the test, thanks for comments could you check.

Copy link
Member

@Maran23 Maran23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor comments. Will reapprove once they are fixed.
Test looks good, and gives helpful insights to us in case it fails in the future. Good job!

@openjdk openjdk bot added the ready Ready to be integrated label Nov 14, 2025
@openjdk openjdk bot removed the ready Ready to be integrated label Nov 15, 2025
@Ziad-Mid
Copy link
Contributor Author

Changes added thank you for review, I will integrate by tomorrow if no more suggestions.

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

Labels

rfr Ready for review

Development

Successfully merging this pull request may close these issues.

3 participants