From: Ben Soares Date: Thu, 15 Jun 2023 12:15:26 +0000 (+0100) Subject: JAL-4206 Use All Known Alignment Files as default until a file is loaded X-Git-Tag: Release_2_11_4_0~213^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3bf2b5ea57b1d77d6e2e7adc11a50387e5376dc0;p=jalview.git JAL-4206 Use All Known Alignment Files as default until a file is loaded --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 2dfe820..6fd70a9 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -569,15 +569,16 @@ public class Desktop extends jalview.jbgui.GDesktop } // Thread off a new instance of the file chooser - this reduces the time - // it - // takes to open it later on. + // it takes to open it later on. new Thread(new Runnable() { @Override public void run() { jalview.bin.Console.debug("Filechooser init thread started."); - String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); + String fileFormat = FileLoader.getUseDefaultFileFormat() + ? Cache.getProperty("DEFAULT_FILE_FORMAT") + : null; JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat); jalview.bin.Console.debug("Filechooser init thread finished."); @@ -1235,7 +1236,9 @@ public class Desktop extends jalview.jbgui.GDesktop @Override public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport) { - String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); + String fileFormat = FileLoader.getUseDefaultFileFormat() + ? Cache.getProperty("DEFAULT_FILE_FORMAT") + : null; JalviewFileChooser chooser = JalviewFileChooser.forRead( Cache.getProperty("LAST_DIRECTORY"), fileFormat, BackupFiles.getEnabled()); diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index a2585b3..9ede0f5 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -74,6 +74,8 @@ public class FileLoader implements Runnable private File selectedFile; + private static boolean useDefaultFileFormat = false; + /** * default constructor always raised errors in GUI dialog boxes */ @@ -642,6 +644,8 @@ public class FileLoader implements Runnable } this.setShouldBeSaved(); + // after first file loaded we revert to assuming a default file format + useDefaultFileFormat = true; } /** @@ -684,4 +688,9 @@ public class FileLoader implements Runnable QuitHandler.Message.UNSAVED_ALIGNMENTS); } + public static boolean getUseDefaultFileFormat() + { + return useDefaultFileFormat; + } + } diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 1a4326c..b01536e 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -286,6 +286,11 @@ public class JalviewFileChooser extends JFileChooser alljvf.setExtensionListInDescription(false); addChoosableFileFilter(alljvf); + if (selected == null) + { + chosen = alljvf; + } + for (String[] format : formats) { JalviewFileFilter jvf = new JalviewFileFilter(format[0], format[1]);