JAL-3032 DND enabled; additional io changes for File vs. String
[jalview.git] / src / jalview / gui / AlignFrame.java
index 26c5548..2587866 100644 (file)
@@ -4359,13 +4359,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    * Try to load a features file onto the alignment.
    * 
    * @param file
-   *          contents or path to retrieve file
+   *          contents or path to retrieve file or a File object
    * @param sourceType
    *          access mode of file (see jalview.io.AlignFile)
    * @return true if features file was parsed correctly.
    */
-  public boolean parseFeaturesFile(String file, DataSourceType sourceType)
+  public boolean parseFeaturesFile(Object file, DataSourceType sourceType)
   {
+    // BH 2018 
     return avc.parseFeaturesFile(file, sourceType,
             Cache.getDefault("RELAXEDSEQIDMATCHING", false));
 
@@ -4412,8 +4413,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     // Java's Transferable for native dnd
     evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
     Transferable t = evt.getTransferable();
+    
+    
     final AlignFrame thisaf = this;
-    final List<String> files = new ArrayList<>();
+    final List<Object> files = new ArrayList<>();
     List<DataSourceType> protocols = new ArrayList<>();
 
     try
@@ -4441,20 +4444,22 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
              * Object[] { String,SequenceI}
              */
             ArrayList<Object[]> filesmatched = new ArrayList<>();
-            ArrayList<String> filesnotmatched = new ArrayList<>();
+            ArrayList<Object> filesnotmatched = new ArrayList<>();
             for (int i = 0; i < files.size(); i++)
             {
-              String file = files.get(i).toString();
+              // BH 2018 
+              Object file = files.get(i);
+              String fileName = file.toString();
               String pdbfn = "";
-              DataSourceType protocol = FormatAdapter.checkProtocol(file);
+              DataSourceType protocol = (file instanceof File ? DataSourceType.FILE : FormatAdapter.checkProtocol(fileName));
               if (protocol == DataSourceType.FILE)
               {
-                File fl = new File(file);
+                File fl = (file instanceof File ? (File) file : new File(fileName));
                 pdbfn = fl.getName();
               }
               else if (protocol == DataSourceType.URL)
               {
-                URL url = new URL(file);
+                URL url = new URL(fileName);
                 pdbfn = url.getFile();
               }
               if (pdbfn.length() > 0)
@@ -4476,7 +4481,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                 }
                 if (mtch != null)
                 {
-                  FileFormatI type = null;
+                  FileFormatI type;
                   try
                   {
                     type = new IdentifyFile().identify(file, protocol);
@@ -4567,7 +4572,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               {
                 return;
               }
-              for (String fn : filesnotmatched)
+              for (Object fn : filesnotmatched)
               {
                 loadJalviewDataFile(fn, null, null, null);
               }
@@ -4594,9 +4599,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    * @param file
    *          either a filename or a URL string.
    */
-  public void loadJalviewDataFile(String file, DataSourceType sourceType,
+  public void loadJalviewDataFile(Object file, DataSourceType sourceType,
           FileFormatI format, SequenceI assocSeq)
   {
+    // BH 2018 was String file
     try
     {
       if (sourceType == null)