JAL-3141 Found a (not ideal) fix for updating the FileChooser list of files when...
authorBen Soares <bsoares@dundee.ac.uk>
Tue, 29 Jan 2019 11:41:52 +0000 (11:41 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Tue, 29 Jan 2019 11:41:52 +0000 (11:41 +0000)
src/jalview/io/JalviewFileChooser.java

index 7c3cf92..8fc5ddd 100755 (executable)
@@ -48,6 +48,7 @@ import javax.swing.JList;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.SpringLayout;
+import javax.swing.filechooser.FileFilter;
 import javax.swing.plaf.basic.BasicFileChooserUI;
 
 /**
@@ -257,17 +258,67 @@ public class JalviewFileChooser extends JFileChooser
             includeBackupFiles = backupfilesCheckBox.isSelected();
             Cache.setProperty(BackupFiles.NS + "_FC_INCLUDE",
                     String.valueOf(includeBackupFiles));
+
+            if (Platform.isAMac())
+            {
+              // This is a kludge. Cannot find out how to get the file list to
+              // refresh on its own! This works the best out of a number of
+              // different attempts!
+              FileFilter ff = jfc.getFileFilter();
+              jfc.setFileFilter(jfc.getAcceptAllFileFilter());
+              jfc.setFileFilter(ff);
+
+              /*
+              jfc.setFileHidingEnabled(!jfc.isFileHidingEnabled());
+              jfc.setFileHidingEnabled(!jfc.isFileHidingEnabled());
+              */
+
+              /*
+              jfc.getRootPane()
+                      .paintImmediately(jfc.getRootPane().getBounds());
+              jfc.paintImmediately(jfc.getBounds());
+              */
+
+              /*
+              Object o = jfc.getClientProperty(
+                      CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY);
+              jfc.firePropertyChange(CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY,
+                      o, o);
+              */
+
+              /*
+              File f = jfc.getSelectedFile();
+              jfc.setSelectedFile(null);
+              if (f != null)
+              {
+                jfc.setSelectedFile(f);
+              }
+              */
+
+              /*
+              Graphics g = jfc.getGraphics();
+              jfc.update(g);
+              jfc.paintAll(g);
+              */
+
+              /*
+              jfc.setFileHidingEnabled(!jfc.isFileHidingEnabled());
+              jfc.setFileHidingEnabled(!jfc.isFileHidingEnabled());
+              */
+              /*
+              jfc.invalidate();
+              Component[] c = jfc.getComponents();
+              for (int i = 0; i < c.length; i++)
+              {
+                c[i].invalidate();
+                System.out.println("INVALIDATING " + c[i].getName());
+              }
+              */
+            }
+
             jfc.rescanCurrentDirectory();
             jfc.revalidate();
             jfc.repaint();
-            // This is a kludge. Cannot find out how to get the file list to
-            // refresh!
-            /*
-            Object o = jfc.getClientProperty(
-                    CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY);
-            jfc.firePropertyChange(CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY,
-                    o, o);
-            */
           }
         });
       }