Integrate NB Favorites with the FileChooser shortcuts panel#7164
Integrate NB Favorites with the FileChooser shortcuts panel#7164mbien merged 3 commits intoapache:masterfrom
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.
@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.
neilcsmith-net
left a comment
There was a problem hiding this comment.
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.
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.
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.
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
neilcsmith-net
left a comment
There was a problem hiding this comment.
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.
@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.
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
FileChoosershortcuts panel.screenshots:

JDK's
FileChooserwith favorites:NB's custom

DirectoryChooserdisplaying lots of favorites in aJScrollPane.can be enabled via FlatLaf options (last checkbox):
