-
Notifications
You must be signed in to change notification settings - Fork 840
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
Integrate NB Favorites with the FileChooser shortcuts panel #7164
Conversation
if (useNBShortcutsPanel()) { | ||
FlatShortcutsPanel shortcuts = new FlatShortcutsPanel(fileChooser); | ||
JScrollPane sp = new JScrollPane(shortcuts, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | ||
sp.setPreferredSize(new Dimension(100, 300)); | ||
return sp; | ||
} |
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.
@DevCharly do you think it would make sense for FlatLaf to wrap the FlatShortcutsPanel
in a JScrollPane like here? (see second screenshot)
NB uses two file choosers, one is customized (DirectoryChooserUI
) and used for opening projects etc, the other one is the standard JDK file chooser. Now when the shortcuts panel has lots of items the standard JDK file chooser will get very tall.
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 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.
Great idea! But I'd like to see it done without additional dependencies or look-and-feel specific checks being added. UIManager keys should be the way to centralise this in my opinion.
ide/o.n.swing.dirchooser/src/org/netbeans/swing/dirchooser/DirectoryChooserUI.java
Outdated
Show resolved
Hide resolved
} | ||
return list.toArray(File[]::new); | ||
}; | ||
UIManager.put("FileChooser.shortcuts.filesFunction", fun); |
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.
Adopt this as a provided NetBeans key and provide from the Favorites module directly?
Could also consider if Favorites should prepopulate favorites from the shell folders on Windows, and then allow all OS to use Favorites to customise links in file chooser panels for consistency?
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 a NetBeans Key?
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 just meant a UI key that's added and documented in https://github.com/apache/netbeans/blob/master/platform/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java Although it would be kind of operating in reverse to most UI keys, in the sense that it's set outside and read by the 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.
Could also consider if Favorites should prepopulate favorites from the shell folders on Windows, and then allow all OS to use Favorites to customise links in file chooser panels for consistency?
the way it works right now on windows is that the NB favorites are appended to the windows specific shortcuts:
the win ShellFolder reflection code is essentially not needed in dir file folder if FlatLaf is used since the shortcuts panel is doing this already. actually: I believe this isn't quite correct, some of the code is probably still active.
d9e8dff
to
99e6f7a
Compare
this can be now enabled via FlatLaf options (no restart required), see added screenshot |
99e6f7a
to
71d4d2a
Compare
71d4d2a
to
80d65f9
Compare
80d65f9
to
10b3c5b
Compare
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.
Changes look good to me. I guess you could remove the dependency changes entirely by using String literals, but pros and cons to that.
/** | ||
* FileChooser | ||
*/ | ||
public static final String FILECHOOSER_SHORTCUTS_FILESFUNCTION = "FileChooser.shortcuts.filesFunction"; | ||
public static final String FILECHOOSER_SHORTCUTS_PANEL_FACTORY = "FileChooser.shortcuts.panel.factory"; | ||
public static final String FILECHOOSER_FAVORITES_ENABLED = "FileChooser.favorites.enabled"; |
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.
@neilcsmith-net btw the _FILESFUNCTION
key value (FileChooser.shortcuts.filesFunction
) is taken right from FlatLaf. Not sure if this is elegant or a horrible idea. I just thought that mapping one key to another would create more problems than its worth the trouble since it can get out of sync easily.
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.
Yes, I knew that when I suggested adopting it. Don't see a reason to use something different and have the problems of syncing. Whether it's elegant or horrible ... 🤷
- added ctrl+space to the trigger list - increased popup size from 4 to 6 lines - filter out hidden files
- file chooser shortcuts panel can optionally append the tree roots of the favorites view - can be toggled in the FlatLaf options This requires to open com.formdev.flatlaf.ui as friend dependency, which is as mentioned in project.properties not part of the stable API.
10b3c5b
to
ce3cca2
Compare
fixed a typo, going to merge once green again. Thanks for reviewing. |
Link the Favorites view with FlatLaf's
FileChooser
shortcuts panel.screenshots:
![favs-in-file-chooser](https://private-user-images.githubusercontent.com/114367/313385937-e992f733-12a7-40e4-a5bd-558a6f3a967c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM0MDg5ODcsIm5iZiI6MTcyMzQwODY4NywicGF0aCI6Ii8xMTQzNjcvMzEzMzg1OTM3LWU5OTJmNzMzLTEyYTctNDBlNC1hNWJkLTU1OGE2ZjNhOTY3Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxMVQyMDM4MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00ODAwNjc4ZjFhOTExZTAzMDg5MjAyYjM4YWJkYjFjM2FiNzA1OTA1MTI5MmVkYTQzNjNkNTlkNWZiNDhhZGM3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.RCMRwadD3dXIFSa6cDZQMsmd-RVxj2WBr2aTm8No8SU)
JDK's
FileChooser
with favorites:NB's custom
![favs-in-file-chooser_scroll](https://private-user-images.githubusercontent.com/114367/313386109-99bbc245-a834-418f-98cd-b7a59531a8d2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM0MDg5ODcsIm5iZiI6MTcyMzQwODY4NywicGF0aCI6Ii8xMTQzNjcvMzEzMzg2MTA5LTk5YmJjMjQ1LWE4MzQtNDE4Zi05OGNkLWI3YTU5NTMxYThkMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxMVQyMDM4MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jMGM1NGM5YjExNWYwNTI1OGU1ZWZiNDc2OTYxNzk2YzE4NzFmNzYzODUwYmU0ZWY3YTUyNjNhMzM0ZmM1ZWQ5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.7TSa98_-gOb60SYGn8TzdFAfyvPYo4BTwzkGnWxW5tw)
DirectoryChooser
displaying lots of favorites in aJScrollPane
.can be enabled via FlatLaf options (last checkbox):
![image](https://private-user-images.githubusercontent.com/114367/316350488-eb5f5263-2894-4891-bedc-7e569e005597.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM0MDg5ODcsIm5iZiI6MTcyMzQwODY4NywicGF0aCI6Ii8xMTQzNjcvMzE2MzUwNDg4LWViNWY1MjYzLTI4OTQtNDg5MS1iZWRjLTdlNTY5ZTAwNTU5Ny5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxMVQyMDM4MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kN2Y1OTk2YTE4OGUxYmI5NTZiZTY3YmUzOTA4MTYzYzU4NDliYTQyYWEzZGU5NWQyNjZlMTEzOWMyMzQ0Y2MzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.99GAGUra6D8J3QP2efXpVISPQ4qnnbREgZ-PVwJS-EQ)