From: Ben Soares Date: Tue, 29 Jan 2019 11:41:52 +0000 (+0000) Subject: JAL-3141 Found a (not ideal) fix for updating the FileChooser list of files when... X-Git-Tag: Release_2_11_0~17^2~97^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bebc8c1502441eee34996343ecd785788f5b1def;p=jalview.git JAL-3141 Found a (not ideal) fix for updating the FileChooser list of files when 'Include backup files' checkbox is checked/unchecked. --- diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 7c3cf92..8fc5ddd 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -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); - */ } }); }