From 8cfac2a806a4028d3f35d8a57688b4b55a1de1b9 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 19 Jun 2009 09:55:34 +0000 Subject: [PATCH] drag'n'drop a URL on to an alignment --- src/jalview/gui/AlignFrame.java | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index d8459a9..d5a98fe 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4087,8 +4087,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } java.net.URI uri = new java.net.URI(s); - java.io.File file = new java.io.File(uri); - files.add(file); + // check to see if we can handle this kind of URI + if (uri.getScheme().toLowerCase().startsWith("http")) + { + files.add(uri.toString()); + } + else + { + // otherwise preserve old behaviour: catch all for file objects + java.io.File file = new java.io.File(uri); + files.add(file.toString()); + } } } } catch (Exception e) @@ -4112,7 +4121,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * Attempt to load a "dropped" file: First by testing whether it's and + * Attempt to load a "dropped" file or URL string: First by testing whether it's and * Annotation file, then a JNet file, and finally a features file. If all are * false then the user may have dropped an alignment file onto this * AlignFrame. @@ -4124,11 +4133,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - String protocol = "File"; - - if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1) + String protocol = jalview.io.FormatAdapter.FILE; + String f=file.toLowerCase(); + if (f.indexOf("http:") == 0 || f.indexOf("https:")==0 || f.indexOf("file:") == 0) { - protocol = "URL"; + protocol = jalview.io.FormatAdapter.URL; } boolean isAnnotation = new AnnotationFile().readAnnotationFile( -- 1.7.10.2