-
Notifications
You must be signed in to change notification settings - Fork 6.2k
6777156: GTK L&F: JFileChooser can jump beyond root directory in combobox and selection textarea. #10390
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
Conversation
|
👋 Welcome back kumarabhi006! A progress list of the required criteria for merging this PR into |
|
@kumarabhi006 The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
| if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { | ||
| int index = list.locationToIndex(e.getPoint()); | ||
| File currentDirectory = getFileChooser().getCurrentDirectory(); | ||
| if (currentDirectory.getParentFile() == null && index == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a Comment explaining the statement index == 1 would be better to understand that it signifies root directory index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment.
Basically, getParentFile method is used to check root directory and index == 1 is the index of ../ directory.
| if (prevDir == crntDir) { | ||
| passed = true; | ||
| break; | ||
| } else if (++i > 5) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retries will be 4 right......? Since you are starting with 2 till 5......?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the retries to be 5 and then break to avoid infinite loop.
|
Is there any possibility to check for current Directory to be |
Added the condition to check if the current directory is root. |
jayathirthrao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the behaviour in other LAF's?
Also lets change title of this bug to something like "GTK L&F: JFileChooser can jump beyond root directory in combobox and selection textarea"
| this.list = list; | ||
| } | ||
|
|
||
| public void mouseClicked(MouseEvent e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this issue reproducible only through mouse click event? Can we use key navigation and return button to see same issue? Is button press using keyboard navigation treated as mouseClick event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same issue has been observed in case of key navigation also. we need to handle those scenario where a user is navigating through keys. I will check and update accordingly as we discussed over call.
| }); | ||
|
|
||
| robot.waitForIdle(); | ||
| robot.delay(1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After robot.setAutoDelay() why we need such large delays in robot at many places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check this and update.
| } | ||
|
|
||
| private static void doubleClickMouse(Point p) { | ||
| robot.mouseMove(p.x+75, p.y+frame.getHeight()/2 - 90); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not use magic numbers to determine location on screen. Will these coordinates hold true at different uiScales?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test case has been changed to manual now. So, there is no need of getting location on screen now.
I have checked in Nimbus and Metal LAF, there is a separate button in both LAF to move to previous directory and it is disabled when current directory is root. |
|
@jayathirthrao @TejeshR13 As compared to previous fix where the condition was handled at listener level (mouse double click event), has been changed in current fix. Now as per the current fix the proposed solution is to remove the "../" from directory list if the current directory is root in GTK LAF. Test case has been updated to manual test as compared to previous fix. |
jayathirthrao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its good that now we are handling entries in directory list at appropriate place instead of modifying it at some event listeners. LGTM.
|
@kumarabhi006 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: 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 264 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@jayathirthrao, @prsadhuk) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
| */ | ||
| File crntDir = getFileChooser().getCurrentDirectory(); | ||
| if (crntDir != null && crntDir.getParentFile() == null && | ||
| files.contains(new File("/.."))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not possible to use "FileSystemView.isFileSystemRoot(File)" for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not checked this.
Do you mean to check FileSystemView.isFileSystemRoot(crntDir ) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's what you commented "if current directory is root"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok... I will check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not possible to use "FileSystemView.isFileSystemRoot(File)" for this?
Updated.
| * root file system. | ||
| * @run main/manual TestFileChooserDirectorySelection | ||
| */ | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to put the test in plaf/gtk folder as it fixed gtk issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test file moved to plaf/gtk folder.
|
Please confirm that along with ubuntu, you have tested on Oracle Linux too. |
|
Fix works fine and tested. |
I have checked in Oracle Linux, Fix is working fine. |
|
/integrate |
|
@kumarabhi006 |
|
/sponsor |
|
Going to push as commit 9d0009e.
Your commit was automatically rebased without conflicts. |
|
@jayathirthrao @kumarabhi006 Pushed as commit 9d0009e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
When a user selects ../ from directory list in GTK FileChooser continuosly, it leads to '../../../.....' in combobox and selection textarea even though it the current directory is at root level.
Fix for the issue is to remove "../" entry from JFileChooser directory list in GTK LAF if current directory is root.
Test case has been added and checked in CI pipeline. Link is attached in JBS.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10390/head:pull/10390$ git checkout pull/10390Update a local copy of the PR:
$ git checkout pull/10390$ git pull https://git.openjdk.org/jdk pull/10390/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10390View PR using the GUI difftool:
$ git pr show -t 10390Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10390.diff