JAL-4460 In save as, set format from file extension if a multi-format file filter...
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 11 Sep 2024 16:24:33 +0000 (17:24 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 11 Sep 2024 16:24:33 +0000 (17:24 +0100)
src/jalview/io/JalviewFileChooser.java

index ee39458..9a0640c 100755 (executable)
@@ -518,6 +518,18 @@ public class JalviewFileChooser extends JFileChooser
         selectedFile = (new File(getCurrentDirectory(), withExtension));
         setSelectedFile(selectedFile);
       }
+      else if (jvf.isMultiFormat() && jvf.accept(selectedFile))
+      {
+        // if a multiFormat filter is selected, with an acceptable file
+        // extension, see if we can set the format from the file extension
+        for (FileFilter jff : this.getChoosableFileFilters())
+        {
+          if (jff.accept(selectedFile))
+          {
+            this.setFileFilter(jff);
+          }
+        }
+      }
     }
 
     if (selectedFile.exists())