Allow loading from Zip files
authoramwaterhouse <Andrew Waterhouse>
Thu, 16 Mar 2006 15:19:24 +0000 (15:19 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 16 Mar 2006 15:19:24 +0000 (15:19 +0000)
src/jalview/bin/JalviewLite.java

index 858c391..199a843 100755 (executable)
@@ -94,9 +94,7 @@ public class JalviewLite extends Applet
            && getParameter("embedded").equalsIgnoreCase("true"))\r
         {\r
           embedded = true;\r
-          LoadingThread loader = new LoadingThread(file,\r
-                            AppletFormatAdapter.URL,\r
-                            applet);\r
+          LoadingThread loader = new LoadingThread(file, applet);\r
           loader.start();\r
         }\r
         else if (file != null)\r
@@ -108,7 +106,6 @@ public class JalviewLite extends Applet
                     public void actionPerformed(ActionEvent e)\r
                     {\r
                         LoadingThread loader = new LoadingThread(file,\r
-                            AppletFormatAdapter.URL,\r
                             applet);\r
                         loader.start();\r
                       }\r
@@ -141,7 +138,7 @@ public class JalviewLite extends Applet
      }\r
       if ( (sequences != null) && (sequences.length > 0))\r
       {\r
-        AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0]);\r
+        AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0], false);\r
         af.statusBar.setText("Successfully loaded file " + args[0]);\r
       }\r
     }\r
@@ -262,15 +259,16 @@ public class JalviewLite extends Applet
         JalviewLite applet;\r
 \r
         public LoadingThread(String _file,\r
-                             String _protocol,\r
                              JalviewLite _applet)\r
         {\r
             file = _file;\r
             if(inArchive(file))\r
               protocol = AppletFormatAdapter.CLASSLOADER;\r
             else\r
-              protocol = _protocol;\r
-\r
+            {\r
+              file = addProtocol(file);\r
+              protocol = AppletFormatAdapter.URL;\r
+            }\r
             format = new jalview.io.IdentifyFile().Identify(file, protocol);\r
             applet = _applet;\r
         }\r
@@ -288,13 +286,12 @@ public class JalviewLite extends Applet
             if ((sequences != null) && (sequences.length > 0))\r
             {\r
               currentAlignFrame = new AlignFrame(new Alignment(sequences),\r
-                                                 applet, file);\r
+                                                 applet,\r
+                                                 file,\r
+                                                 embedded);\r
 \r
               initialAlignFrame = currentAlignFrame;\r
 \r
-              if (embedded)\r
-                currentAlignFrame.setEmbedded();\r
-\r
               currentAlignFrame.statusBar.setText("Successfully loaded file " + file);\r
 \r
 \r
@@ -317,12 +314,7 @@ public class JalviewLite extends Applet
 \r
                     if (fin.getTree() != null)\r
                     {\r
-                      TreePanel tp = null;\r
-                      tp = new TreePanel(currentAlignFrame.viewport,\r
-                                         currentAlignFrame.viewport.getAlignment().getSequences(),\r
-                                         fin, "FromFile", treeFile);\r
-                      addFrame(tp, treeFile, 600, 500);\r
-                      currentAlignFrame.addTreeMenuItem(tp, treeFile);\r
+                      currentAlignFrame.loadTree(fin, treeFile);\r
                     }\r
                   }\r
                   catch (Exception ex)\r
@@ -391,7 +383,15 @@ public class JalviewLite extends Applet
          */\r
         boolean inArchive(String file)\r
         {\r
-          return ( getClass().getResourceAsStream("/" + file) != null );\r
+          //This might throw a security exception in certain browsers\r
+          //Netscape Communicator for instance.\r
+          try{\r
+            return (getClass().getResourceAsStream("/" + file) != null);\r
+          }catch(Exception ex)\r
+          {\r
+            System.out.println("Exception checking resources: "+file+" "+ex);\r
+            return false;\r
+          }\r
         }\r
 \r
         String addProtocol(String file)\r