changeset 10302:24abdac0deb6

8031696: [macosx] TwentyThousandTest test failed with OOM Reviewed-by: serb, pchelko
author alexsch
date Tue, 02 Dec 2014 15:12:12 +0400
parents 28b81c5a7034
children 8aa2480d90d3
files src/macosx/classes/com/apple/laf/AquaFileChooserUI.java
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Mon Dec 01 23:01:48 2014 +0000
+++ b/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Tue Dec 02 15:12:12 2014 +0400
@@ -1280,12 +1280,12 @@
                 filters = (FileFilter[]) e.getNewValue();
                 fireContentsChanged(this, -1, -1);
             } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
-                fireContentsChanged(this, -1, -1);
+                setSelectedItem(e.getNewValue());
             }
         }
 
         public void setSelectedItem(Object filter) {
-            if(filter != null) {
+            if (filter != null && !containsFileFilter(filter)) {
                 getFileChooser().setFileFilter((FileFilter) filter);
                 fireContentsChanged(this, -1, -1);
             }
@@ -1333,6 +1333,10 @@
         }
     }
 
+    private boolean containsFileFilter(Object fileFilter) {
+        return Objects.equals(fileFilter, getFileChooser().getFileFilter());
+    }
+
     /**
      * Acts when FilterComboBox has changed the selected item.
      */
@@ -1342,7 +1346,10 @@
         }
 
         public void actionPerformed(final ActionEvent e) {
-            getFileChooser().setFileFilter((FileFilter)filterComboBox.getSelectedItem());
+            Object selectedFilter = filterComboBox.getSelectedItem();
+            if (!containsFileFilter(selectedFilter)) {
+                getFileChooser().setFileFilter((FileFilter) selectedFilter);
+            }
         }
     }