From 01218585457b22243771439d85aa43b6ccb2b62a Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 2 Jun 2005 11:06:21 +0000 Subject: [PATCH] Reverse order for windows, readin from url --- src/jalview/gui/Jalview2XML.java | 74 +++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 3eebf5c..fa8e50b 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -7,6 +7,7 @@ import java.util.jar.*; import jalview.binding.*; import jalview.schemes.*; import javax.swing.JInternalFrame; +import java.net.URL; public class Jalview2XML @@ -17,6 +18,9 @@ public class Jalview2XML { long creation = System.currentTimeMillis(); JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + if(frames==null) + return; + try{ FileOutputStream fos = new FileOutputStream(statefile); JarOutputStream jout = new JarOutputStream(fos); @@ -25,7 +29,8 @@ public class Jalview2XML PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, "UTF-8")); Vector shortNames = new Vector(); - for (int i = 0; i < frames.length; i++) + //REVERSE ORDER + for (int i = frames.length-1; i > -1; i--) { if (frames[i] instanceof AlignFrame) { @@ -33,8 +38,9 @@ public class Jalview2XML String shortName = af.getTitle(); - shortName = shortName.replace('/', '_'); - shortName = shortName.replace('\\', '_'); + if(shortName.indexOf(File.separatorChar)>-1) + shortName = shortName.substring( + shortName.lastIndexOf(File.separatorChar)+1); int count=1; while( shortNames.contains(shortName) ) @@ -331,11 +337,20 @@ public class Jalview2XML JalviewModel object = new JalviewModel(); try{ //UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING - JarInputStream jin = new JarInputStream(new FileInputStream(file)); + + URL url = null; + if( file.startsWith("http://")) + url = new URL(file); + + JarInputStream jin = null; JarEntry jarentry=null; int entryCount = 1; do{ - jin = new JarInputStream(new FileInputStream(file)); + if (url != null) + jin = new JarInputStream(url.openStream()); + else + jin = new JarInputStream(new FileInputStream(file)); + for(int i=0; i