From 58735c979dbb573eb12d57e33ef7d6e3f3a82c8e Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 11 Oct 2023 12:12:28 +0100 Subject: [PATCH] JAL-3772 Preference to NOT prompt to save remotely loaded alignments --- src/jalview/io/DataSourceType.java | 5 +++++ src/jalview/io/FileLoader.java | 23 +++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/jalview/io/DataSourceType.java b/src/jalview/io/DataSourceType.java index 6d00a7d..c983dfe 100644 --- a/src/jalview/io/DataSourceType.java +++ b/src/jalview/io/DataSourceType.java @@ -28,4 +28,9 @@ public enum DataSourceType { return this != FILE; } + + public boolean isUrl() + { + return this == URL || this == RELATIVE_URL; + } } diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index dc7adac..de88ce9 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -361,8 +361,9 @@ public class FileLoader implements Runnable // We read the data anyway - it might make sense. } // BH 2018 switch to File object here instead of filename - alignFrame = new Jalview2XML(raiseGUI && !Jalview.isBatchMode()).loadJalviewAlign( - selectedFile == null ? file : selectedFile); + alignFrame = new Jalview2XML(raiseGUI && !Jalview.isBatchMode()) + .loadJalviewAlign( + selectedFile == null ? file : selectedFile); } else { @@ -563,7 +564,8 @@ public class FileLoader implements Runnable } catch (Exception er) { - jalview.bin.Console.errPrintln("Exception whilst opening file '" + file); + jalview.bin.Console + .errPrintln("Exception whilst opening file '" + file); er.printStackTrace(); if (raiseGUI && !Jalview.isBatchMode()) { @@ -603,7 +605,8 @@ public class FileLoader implements Runnable } }); } - jalview.bin.Console.errPrintln("Out of memory loading file " + file + "!!"); + jalview.bin.Console + .errPrintln("Out of memory loading file " + file + "!!"); } loadtime += System.currentTimeMillis(); @@ -684,10 +687,18 @@ public class FileLoader implements Runnable AlignViewport avp = af.getViewport(); if (avp == null) return; - avp.setSavedUpToDate(!protocol.isDynamic(), - QuitHandler.Message.UNSAVED_ALIGNMENTS); + boolean upToDate = !protocol.isDynamic(); + if (protocol.isUrl() + && Cache.getDefault(PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS, true)) + { + upToDate = true; + } + avp.setSavedUpToDate(upToDate, + upToDate ? null : QuitHandler.Message.UNSAVED_ALIGNMENTS); } + public static final String PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS = "PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS"; + public static boolean getUseDefaultFileFormat() { return useDefaultFileFormat; -- 1.7.10.2