changeset 11033:3b2bc2801098

8031696: [macosx] TwentyThousandTest test failed with OOM Reviewed-by: serb, pchelko
author alexsch
date Fri, 28 Nov 2014 19:17:00 +0400
parents 754d2145a54a
children 43f4dc0c2489
files src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Fri Nov 28 14:03:56 2014 +0300
+++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Fri Nov 28 19:17:00 2014 +0400
@@ -1300,12 +1300,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);
             }
@@ -1353,6 +1353,10 @@
         }
     }
 
+    private boolean containsFileFilter(Object fileFilter) {
+        return Objects.equals(fileFilter, getFileChooser().getFileFilter());
+    }
+
     /**
      * Acts when FilterComboBox has changed the selected item.
      */
@@ -1363,7 +1367,10 @@
         }
 
         public void actionPerformed(final ActionEvent e) {
-            getFileChooser().setFileFilter((FileFilter) filterComboBox.getSelectedItem());
+            Object selectedFilter = filterComboBox.getSelectedItem();
+            if (!containsFileFilter(selectedFilter)) {
+                getFileChooser().setFileFilter((FileFilter) selectedFilter);
+            }
         }
     }