From 6a60c733dc23235562e32583e68284efa5d29ac9 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 16 Mar 2006 15:19:24 +0000 Subject: [PATCH] Allow loading from Zip files --- src/jalview/bin/JalviewLite.java | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 858c391..199a843 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -94,9 +94,7 @@ public class JalviewLite extends Applet && getParameter("embedded").equalsIgnoreCase("true")) { embedded = true; - LoadingThread loader = new LoadingThread(file, - AppletFormatAdapter.URL, - applet); + LoadingThread loader = new LoadingThread(file, applet); loader.start(); } else if (file != null) @@ -108,7 +106,6 @@ public class JalviewLite extends Applet public void actionPerformed(ActionEvent e) { LoadingThread loader = new LoadingThread(file, - AppletFormatAdapter.URL, applet); loader.start(); } @@ -141,7 +138,7 @@ public class JalviewLite extends Applet } if ( (sequences != null) && (sequences.length > 0)) { - AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0]); + AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0], false); af.statusBar.setText("Successfully loaded file " + args[0]); } } @@ -262,15 +259,16 @@ public class JalviewLite extends Applet JalviewLite applet; public LoadingThread(String _file, - String _protocol, JalviewLite _applet) { file = _file; if(inArchive(file)) protocol = AppletFormatAdapter.CLASSLOADER; else - protocol = _protocol; - + { + file = addProtocol(file); + protocol = AppletFormatAdapter.URL; + } format = new jalview.io.IdentifyFile().Identify(file, protocol); applet = _applet; } @@ -288,13 +286,12 @@ public class JalviewLite extends Applet if ((sequences != null) && (sequences.length > 0)) { currentAlignFrame = new AlignFrame(new Alignment(sequences), - applet, file); + applet, + file, + embedded); initialAlignFrame = currentAlignFrame; - if (embedded) - currentAlignFrame.setEmbedded(); - currentAlignFrame.statusBar.setText("Successfully loaded file " + file); @@ -317,12 +314,7 @@ public class JalviewLite extends Applet if (fin.getTree() != null) { - TreePanel tp = null; - tp = new TreePanel(currentAlignFrame.viewport, - currentAlignFrame.viewport.getAlignment().getSequences(), - fin, "FromFile", treeFile); - addFrame(tp, treeFile, 600, 500); - currentAlignFrame.addTreeMenuItem(tp, treeFile); + currentAlignFrame.loadTree(fin, treeFile); } } catch (Exception ex) @@ -391,7 +383,15 @@ public class JalviewLite extends Applet */ boolean inArchive(String file) { - return ( getClass().getResourceAsStream("/" + file) != null ); + //This might throw a security exception in certain browsers + //Netscape Communicator for instance. + try{ + return (getClass().getResourceAsStream("/" + file) != null); + }catch(Exception ex) + { + System.out.println("Exception checking resources: "+file+" "+ex); + return false; + } } String addProtocol(String file) -- 1.7.10.2