From: Jim Procter Date: Thu, 12 Sep 2024 13:56:31 +0000 (+0100) Subject: JAL-4461 after autodetection, update the filechooser dialog and let the user hit... X-Git-Tag: Release_2_11_4_0~6^2~1^2~5 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f9644737ff404d376d442fd21b2748ec9894ea2d;p=jalview.git JAL-4461 after autodetection, update the filechooser dialog and let the user hit OK again to confirm the autodetected format --- diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index b2dcd11..0113717 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -471,6 +471,31 @@ public class JalviewFileChooser extends JFileChooser } return null; } + /** + * Unused - could delete ? + * @param format - matches and configures the filefilter according to given format + * @return true if the format given matched an available filter + */ + public boolean setSelectedFormat(FileFormatI format) + { + if (format==null) + { + return false; + } + String toSelect = format.getName(); + for (FileFilter available:getChoosableFileFilters()) + { + if (available instanceof JalviewFileFilter) + { + if (((JalviewFileFilter)available).getDescription().equals(toSelect)) + { + setFileFilter(available); + return true; + } + } + } + return false; + } @Override public File getSelectedFile() @@ -551,9 +576,10 @@ public class JalviewFileChooser extends JFileChooser // extension, see if we can set the format from the file extension for (FileFilter jff : this.getChoosableFileFilters()) { - if (jff.accept(selectedFile)) + if (jvf!=jff && jff.accept(selectedFile)) { - this.setFileFilter(jff); + setFileFilter(jff); + return; } } }