From: Ben Soares Date: Tue, 29 Jan 2019 14:15:51 +0000 (+0000) Subject: JAL-3141 Found a good fix for updating the FileChooser list of files when 'Include... X-Git-Tag: Release_2_11_0~17^2~97^2~8 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c17e378d6f5fd831af5969d6ba815619dfb54a65;p=jalview.git JAL-3141 Found a good 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 8fc5ddd..0d78bda 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -259,62 +259,19 @@ public class JalviewFileChooser extends JFileChooser Cache.setProperty(BackupFiles.NS + "_FC_INCLUDE", String.valueOf(includeBackupFiles)); - if (Platform.isAMac()) + FileFilter f = jfc.getFileFilter(); + // deselect the selected file if it's no longer choosable + File selectedFile = jfc.getSelectedFile(); + if (selectedFile != null && !f.accept(selectedFile)) { - // 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()); - } - */ } + // fake the OK button changing (to force it to upate) + String s = jfc.getApproveButtonText(); + jfc.firePropertyChange( + APPROVE_BUTTON_TEXT_CHANGED_PROPERTY, null, s); + // fake the file filter changing (its behaviour actually has) + jfc.firePropertyChange(FILE_FILTER_CHANGED_PROPERTY, null, f); jfc.rescanCurrentDirectory(); jfc.revalidate();