From 6d9ff99acf35278e6dc1c85bbc65f8e419cd91b6 Mon Sep 17 00:00:00 2001 From: hansonr Date: Tue, 16 Apr 2019 17:28:14 -0500 Subject: [PATCH] caching of DnD files dropped --- src/jalview/gui/AlignFrame.java | 9 +++++++-- src/jalview/gui/AppJmolBinding.java | 7 +------ src/jalview/gui/Desktop.java | 5 ++++- src/jalview/util/Platform.java | 10 ++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index b655b2e..77b8552 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4544,8 +4544,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, : FormatAdapter.checkProtocol(fileName)); if (protocol == DataSourceType.FILE) { - File fl = (file instanceof File ? (File) file - : new File(fileName)); + File fl; + if (file instanceof File) { + fl = (File) file; + Platform.cacheFileData(fl); + } else { + fl = new File(fileName); + } pdbfn = fl.getName(); } else if (protocol == DataSourceType.URL) diff --git a/src/jalview/gui/AppJmolBinding.java b/src/jalview/gui/AppJmolBinding.java index 1d7cd6c..75b98bc 100644 --- a/src/jalview/gui/AppJmolBinding.java +++ b/src/jalview/gui/AppJmolBinding.java @@ -230,12 +230,7 @@ public class AppJmolBinding extends JalviewJmolBinding } for (File f : files) { - String path = f.getAbsolutePath(); - byte[] data = Platform.getFileBytes(f); - if (data != null) - { - Platform.cacheFileData(path, data); - } + Platform.cacheFileData(f); } } } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 14beac2..cd8330a 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1096,7 +1096,10 @@ public class Desktop extends jalview.jbgui.GDesktop { format = new IdentifyFile().identify(file, protocol); } - + if (file instanceof File) + { + Platform.cacheFileData((File) file); + } new FileLoader().LoadFile(null, file, protocol, format); } diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 3297104..f9eb2a6 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -319,6 +319,16 @@ public class Platform */ } + public static void cacheFileData(File file) + { + byte[] data; + if (!isJS() || (data = Platform.getFileBytes(file)) == null) + { + return; + } + cacheFileData(file.toString(), data); + } + public static byte[] getFileBytes(File f) { return /** @j2sNative f && f._bytes || */ -- 1.7.10.2