From 9cd3ff27d8a47b2e8b1f3be9ff07d47ea9bc6fd1 Mon Sep 17 00:00:00 2001 From: hansonr Date: Tue, 8 Oct 2019 19:21:24 +0200 Subject: [PATCH] JAL-3436 fix for reload not reloading files -- fix for Jalview projects reload where reload was using just the file name. -- will test further to ensure this is only in relation to JVP files --- src/jalview/gui/AlignFrame.java | 5 ++++- src/jalview/project/Jalview2XML.java | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 0271506..0c25262 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1053,6 +1053,7 @@ public class AlignFrame extends GAlignFrame @Override public void reload_actionPerformed(ActionEvent e) { + System.out.println("AlignFrame.reload " + fileName); if (fileName != null) { // TODO: JAL-1108 - ensure all associated frames are closed regardless of @@ -1084,7 +1085,9 @@ public class AlignFrame extends GAlignFrame DataSourceType protocol = fileName.startsWith("http:") ? DataSourceType.URL : DataSourceType.FILE; - loader.loadFile(viewport, fileName, protocol, currentFileFormat); + loader.loadFile(viewport, + (fileObject == null ? fileName : fileObject), protocol, + currentFileFormat); } else { diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index 186f786..ccfe460 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -2742,6 +2742,13 @@ public class Jalview2XML public boolean attemptversion1parse = false; /** + * JalviewJS only -- to preserve bytes in AlignFrame + * + * BH 2019 JAL-3436 + */ + private File file; + + /** * Load a jalview project archive from a jar file * * @param file @@ -2800,6 +2807,10 @@ public class Jalview2XML String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString()); byte[] bytes = Platform.isJS() ? Platform.getFileBytes((File) ofile) : null; + if (bytes != null) + { + this.file = (File) ofile; + } URL url = null; errorMessage = null; uniqueSetSuffix = null; @@ -4997,7 +5008,7 @@ public class Jalview2XML } } - AlignFrame loadViewport(String file, List JSEQ, + AlignFrame loadViewport(String fileName, List JSEQ, List hiddenSeqs, AlignmentI al, JalviewModel jm, Viewport view, String uniqueSeqSetId, String viewId, List autoAlan) @@ -5017,7 +5028,8 @@ public class Jalview2XML // } ; af.alignPanel.setHoldRepaint(true); - af.setFileName(file, FileFormat.Jalview); + af.setFileName(fileName, FileFormat.Jalview); + af.setFileObject(file); // BH 2019 JAL-3436 final AlignViewport viewport = af.getViewport(); for (int i = 0; i < JSEQ.size(); i++) -- 1.7.10.2