drag'n'drop a URL on to an alignment
authorjprocter <Jim Procter>
Fri, 19 Jun 2009 09:55:34 +0000 (09:55 +0000)
committerjprocter <Jim Procter>
Fri, 19 Jun 2009 09:55:34 +0000 (09:55 +0000)
src/jalview/gui/AlignFrame.java

index d8459a9..d5a98fe 100755 (executable)
@@ -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(