From f9644737ff404d376d442fd21b2748ec9894ea2d Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 12 Sep 2024 14:56:31 +0100 Subject: [PATCH] JAL-4461 after autodetection, update the filechooser dialog and let the user hit OK again to confirm the autodetected format --- src/jalview/io/JalviewFileChooser.java | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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; } } } -- 1.7.10.2