Skip to content
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

8187309: TreeCell must not change tree's data #724

Closed
wants to merge 1 commit into from

Conversation

kleopatra
Copy link
Collaborator

@kleopatra kleopatra commented Feb 2, 2022

Issue was TreeView commit editing implementation violated the spec'ed mechanism:

  • no default commit handler on TreeView
  • TreeCell modifying the data directly

Fix is to move the saving of the edited value from cell into a default commit handler in tree and set that handler in the constructor.

Added tests that failed/passed before/after the fix (along with a sanity test for default commit that passed also before). Also fixed a test bug (incorrect registration of custom commit handler, see JDK-8280951) in TreeViewTest.test_rt_29650 to keep it passing.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/724/head:pull/724
$ git checkout pull/724

Update a local copy of the PR:
$ git checkout pull/724
$ git pull https://git.openjdk.java.net/jfx pull/724/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 724

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/724.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 2, 2022

👋 Welcome back fastegal! 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 openjdk bot added the rfr Ready for review label Feb 2, 2022
@mlbridge
Copy link

mlbridge bot commented Feb 2, 2022

Webrevs

Copy link
Collaborator

@mstr2 mstr2 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

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.

Looks good to me too. The commitEdit(..) method of TreeCell is now in sync with the other cells.
Just left two minor comments.

assertEquals("cell text must not have changed", oldValue, cell.getText());
}


Copy link
Member

Choose a reason for hiding this comment

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

Very minor: Empty line

}

/**
* Test test setup.
Copy link
Member

Choose a reason for hiding this comment

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

Minor: I would rephrase that a bit. Something like:
Tests the cell editing setup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops .. forgot to change this (and the other comment) before integration - sry

@@ -337,6 +337,8 @@ public TreeView(TreeItem<T> root) {
MultipleSelectionModel<TreeItem<T>> sm = new TreeViewBitSetSelectionModel<T>(this);
setSelectionModel(sm);
setFocusModel(new TreeViewFocusModel<T>(this));

setOnEditCommit(DEFAULT_EDIT_COMMIT_HANDLER);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You are adding the default edit commit handler to TreeView. Although it seems to be correct, this default handler is likely to be overwritten if the user code already has a setOnEditCommit() call. This is shown by the test_rt_29650() failure in TreeviewTest.java which you have corrected.

The changes done in this PR makes TreeView similar to ListView and TableView in terms of having the default edit commit handler.

Unfortunately, I do not see how can we avoid user code accidentally overwriting the default edit commit handler. Documenting this possibility seems to be the only way ahead.
Any other idea?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the change might break application code, though that code would be buggy. Actually, the behavior as implemented now, already is documented :)

It is very important to note that if you call setOnEditCommit(javafx.event.EventHandler) with your own EventHandler, then you will be removing the default handler. Unless you then handle the writeback to the property (or the relevant data source), nothing will happen.

so: if they have a custom handler that doesn't save the data, they were violating the specification (though were getting away with it due to the bug).

Personally, I think that we cannot keep backward compatibility to bugs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the explanation. I see that it is already well documented.

@openjdk
Copy link

openjdk bot commented Feb 10, 2022

@kleopatra This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8187309: TreeCell must not change tree's data

Reviewed-by: mstrauss, mhanl, aghaisas

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 4 new commits pushed to the master branch:

  • 590033f: 8273336: Clicking a selected cell from a group of selected cells in a TableView clears the selected items list but remains selected
  • f326e78: 8277572: ImageStorage should correctly handle MIME types for images encoded in data URIs
  • 6f28d91: 8278980: Update WebKit to 613.1
  • 929e7c9: 8280951: Testbug: fix commented asserts in XXViewTest.test_rt_29650

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Feb 10, 2022
@kleopatra
Copy link
Collaborator Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 10, 2022

Going to push as commit 4cf66d9.
Since your change was applied there have been 4 commits pushed to the master branch:

  • 590033f: 8273336: Clicking a selected cell from a group of selected cells in a TableView clears the selected items list but remains selected
  • f326e78: 8277572: ImageStorage should correctly handle MIME types for images encoded in data URIs
  • 6f28d91: 8278980: Update WebKit to 613.1
  • 929e7c9: 8280951: Testbug: fix commented asserts in XXViewTest.test_rt_29650

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 10, 2022
@openjdk openjdk bot closed this Feb 10, 2022
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review labels Feb 10, 2022
@openjdk
Copy link

openjdk bot commented Feb 10, 2022

@kleopatra Pushed as commit 4cf66d9.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kleopatra kleopatra deleted the bug-fix-8187309 branch February 10, 2022 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
4 participants