-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
6972078: Can not select single directory with GTKLookAndFeel #10866
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
|
pt.y + getSelectedFilesButton.getHeight() / 2); | ||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); | ||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); | ||
robot.delay(100); |
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.
robot.mouseMove(pt.x + getSelectedFilesButton.getWidth() / 2,
pt.y + getSelectedFilesButton.getHeight() / 2);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(100);
ClickMouse
method can be reused instead.
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.
There is an offset added in x-position. That's why ClickMouse
is not reused.
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.
Yeah, compute the offset in main method and just pass the point. So that whole method can be reused.
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.
Can you also please test it works ok (or atleast not regress) for other selection mode FILES_ONLY, DIRECTORIES_ONLY in the test?
Can you then please enhance the test to iterate for all installed L&Fs? |
Also, please see if JDK-4912623 is related and fixed by this? |
Verified for file selection mode of In case of selection mode of
Updated for all installed LAFs. |
Ok, I will check. |
I guess you can see in folders where you have only files...Testwise, maybe use File.createTempFile for creating files and see.. |
I have checked manually, it is possible to select single or multiple file when selection mode is I will try to update test file. |
I tried modifying the test case for different selection mode for all LAFs. However If I test manually for each selection mode, the behavior is same for all LAFs.
|
@prsadhuk As discussed, created the sub-test for all file selection mode. Checked with all LAFs and in CI pipeline, link is added in JBS. |
Point frameLocation = fileChooser.getLocationOnScreen(); | ||
int frameWidth = frame.getWidth(); | ||
int frameHeight = frame.getHeight(); | ||
|
||
Point btnLocation = getSelectedFilesButton.getLocationOnScreen(); | ||
int btnWidth = getSelectedFilesButton.getWidth(); | ||
int btnHeight = getSelectedFilesButton.getHeight(); | ||
clickMouse(frameLocation, 0, frameHeight, 230); | ||
clickMouse(btnLocation, btnWidth, btnHeight, 0); | ||
checkResult(laf); |
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 you can optimise by a helper method for this repeated code passing the offset value as paramter.
Also, did you check JDK-4912623 as mentioned?
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 helper method for the repeated code.
I tried to reproduce the JDK-4912623 bug. SwingSet2 JFileChooser demo behaves as it is mentioned in the bug description but in Gedit I didn't find separate folder and files list.
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 bug says
2) Go to FileChooser Demo.
3) Tab to Folder List
4) Press CTRL+A. It will select all the items in the list.
5) Now Tab to file list and press ctrl+A, it will not select all the items.
6) Now Open Gedit.
7) Click Open.
8) Repeat the steps 3 to 5. Behaviour for the native will be opposite to its Java counterpart.
so you can create manually folder with only files and a folder with only folders and then try with Gedit to open those folders and trey the steps...
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 bug says 2) Go to FileChooser Demo. 3) Tab to Folder List 4) Press CTRL+A. It will select all the items in the list. 5) Now Tab to file list and press ctrl+A, it will not select all the items. 6) Now Open Gedit. 7) Click Open. 8) Repeat the steps 3 to 5. Behaviour for the native will be opposite to its Java counterpart.
so you can create manually folder with only files and a folder with only folders and then try with Gedit to open those folders and trey the steps...
I tried these steps, I am able to select all directories and all files in respective folder on press of Ctrl+A in Gedit.
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 GTK Filechooser not behaving the same as gedit?
ie is GTK FileChooser not allowing to select all folders in folder list and all files in files list by CTRL+A with your fix too?
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.
So, it is same without the fix too as is mentioned in that bug.
Yeah, it behaves same without the fix also.
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.
Can you please see why that is so as it should be exercising the same code path as this fix?
Ok, I will check.
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.
Can you please see why that is so as it should be exercising the same code path as this fix?
GTK FileChooser allows to select all folders in folder list but in files list it allows only single file selection. The reason behind this is while creating the GTKFileChooserUI, filelist selection model is set to
SINGLE_SELECTION
if multiselection is disabled. Code snippet is attached fromprotected JScrollPane createFilesList()
method.
if (getFileChooser().isMultiSelectionEnabled()) {
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else {
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
But for directory list there is no such condition is present and due to that it allows to select multiple folders in directory list with ctrl+A.
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.
@prsadhuk As discussed I have checked with the condition modified to chooser.getFileSelectionMode() != JFileChooser.FILES_ONLY
, but this leads to failure for current test in FILES_AND_DIRECTORIES
and DIRECTORIES_ONLY
selection mode.
And for JDK-4912623, still not able to select all files in JFileChooser on press of ctrl+A.
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
} | ||
|
||
private static void checkDirectoriesOnlyTest(UIManager.LookAndFeelInfo laf) | ||
throws Exception { |
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.
throws Exception { | |
throws Exception { |
} | ||
|
||
private static void checkFilesAndDirectoriesTest(UIManager.LookAndFeelInfo laf) | ||
throws Exception { |
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.
throws Exception { | |
throws Exception { |
@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 163 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 (@prsadhuk, @TejeshR13) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@kumarabhi006 |
/sponsor |
Going to push as commit 4a68210.
Your commit was automatically rebased without conflicts. |
@TejeshR13 @kumarabhi006 Pushed as commit 4a68210. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
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.
lgtm
While using a JFileChooser with the file selection mode FILES_AND_DIRECTORIES and multiSelection enabled, it is impossible to select a single directory in GTK LAF.
The condition check has been modified when multiselection is enabled and user has selected single directory.
After the fix the behavior of JFileChooser is similar to other LAFs.
An automatic test case
test/jdk/com/sun/java/swing/plaf/gtk/TestFileChooserSingleDirectorySelection.java
is implemented and checked in CI pipeline. Link is attached in JBS.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10866/head:pull/10866
$ git checkout pull/10866
Update a local copy of the PR:
$ git checkout pull/10866
$ git pull https://git.openjdk.org/jdk pull/10866/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10866
View PR using the GUI difftool:
$ git pr show -t 10866
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10866.diff