8000969: [macosx] Directories are not deselected when JFileChooser has FILES_ONLY selection mode
authoralexsch
Wed, 17 Oct 2012 17:33:26 +0400
changeset 14162 a78ee9af4a48
parent 14161 2b346f8e3b8f
child 14163 87f1bc730fe2
8000969: [macosx] Directories are not deselected when JFileChooser has FILES_ONLY selection mode Reviewed-by: rupashka
jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java
--- a/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Wed Oct 17 14:32:15 2012 +0400
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Wed Oct 17 17:33:26 2012 +0400
@@ -379,6 +379,19 @@
                         }
                     }
                     updateButtonState(getFileChooser());
+                } else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
+                    JFileChooser fileChooser = getFileChooser();
+                    if (!fileChooser.isDirectorySelectionEnabled()) {
+                        final File[] files = (File[]) e.getNewValue();
+                        if (files != null) {
+                            for (int selectedRow : fFileList.getSelectedRows()) {
+                                File file = (File) fFileList.getValueAt(selectedRow, 0);
+                                if (fileChooser.isTraversable(file)) {
+                                    fFileList.removeSelectedIndex(selectedRow);
+                                }
+                            }
+                        }
+                    }
                 } else if (prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
                     fFileList.clearSelection();
                     final File currentDirectory = getFileChooser().getCurrentDirectory();