bug fix for Features/Annotations file parameter parsing in JalviewLite reported and...
[jalview.git] / src / jalview / appletgui / AppletJmol.java
index 1202c68..82a5911 100644 (file)
@@ -163,12 +163,34 @@ public class AppletJmol extends EmbmenuFrame
 
     if(pdbentry.getFile()!=null)
     {
+      // import structure data from pdbentry.getFile based on given protocol
       if (protocol.equals(AppletFormatAdapter.PASTE))
+      { 
         loadInline(pdbentry.getFile());
-      else
+      } else
+      if (protocol.equals(AppletFormatAdapter.FILE) || protocol.equals(AppletFormatAdapter.URL)){
           viewer.openFile(pdbentry.getFile());
+      }
+      else
+        {
+        // probably CLASSLOADER based datasource..
+        // Try and get a reader on the datasource, and pass that to Jmol
+        try {
+          FileParse fparser = new jalview.io.FileParse(protocol, pdbentry.getFile());
+          if (!fparser.isValid())
+          {
+            throw new Exception("Invalid datasource. "+fparser.getWarningMessage());
+          }
+          viewer.openReader(pdbentry.getFile(), pdbentry.getId(), fparser.getReader());
+        } catch (Exception e)
+        {
+          // give up!
+          System.err.println("Couldn't access pdbentry id="+pdbentry.getId()+" and file="+pdbentry.getFile()+" using protocol="+protocol);
+          e.printStackTrace();
+        }
+        }
     }
-
+    
     jalview.bin.JalviewLite.addFrame(this, "Jmol", 400,400);
   }