mbien commented on code in PR #7164:
URL: https://github.com/apache/netbeans/pull/7164#discussion_r1530694479
##########
ide/o.n.swing.dirchooser/src/org/netbeans/swing/dirchooser/Module.java:
##########
@@ -96,17 +94,27 @@ private static void install() {
uid.put(val, impl);
}
// #61147: prevent NB from switching to a different UI later (under
GTK):
- uid.addPropertyChangeListener(pcl = new PropertyChangeListener() {
- public @Override void propertyChange(PropertyChangeEvent evt) {
- String name = evt.getPropertyName();
- Object className = uid.get(KEY);
- if ((name.equals(KEY) || name.equals("UIDefaults")) &&
!val.equals(className)
- && !isQuickFileChooser(className)) {
- originalImpl = (Class<?>) uid.getUIClass(KEY);
- uid.put(KEY, val);
- }
+ uid.addPropertyChangeListener(pcl = (evt) -> {
+ String name = evt.getPropertyName();
+ Object className = uid.get(KEY);
+ if ((name.equals(KEY) || name.equals("UIDefaults")) &&
!val.equals(className) && !isQuickFileChooser(className)) {
+ originalImpl = (Class<?>) uid.getUIClass(KEY);
+ uid.put(KEY, val);
}
});
+
+ Function<File[], File[]> fun = (Function<File[], File[]>) (File[]
files) -> {
+ Favorites favs = Favorites.getDefault();
+ ArrayList<File> list = new ArrayList<>(Arrays.asList(files));
+ for (FileObject root : favs.getFavoriteRoots()) {
+ File file = FileUtil.toFile(root);
+ if (file.isDirectory()) {
+ list.add(file);
+ }
+ }
+ return list.toArray(File[]::new);
+ };
+ UIManager.put("FileChooser.shortcuts.filesFunction", fun);
Review 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists