From baaf65b19f3dfea486da401fba610ac66bf36817 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 25 Apr 2014 14:27:23 +0100 Subject: [PATCH] JAL-1177 additional saveState calls to write a dataset only jalview xml document --- src/jalview/gui/Jalview2XML.java | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 3499f6d..3bca941 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -39,6 +39,7 @@ import jalview.schemabinding.version2.*; import jalview.schemes.*; import jalview.util.Platform; import jalview.util.jarInputStreamProvider; +import jalview.viewmodel.AlignmentViewport; import jalview.ws.jws2.Jws2Discoverer; import jalview.ws.jws2.dm.AAConSettings; import jalview.ws.jws2.jabaws2.Jws2Instance; @@ -278,6 +279,8 @@ public class Jalview2XML return; } + Hashtable dsses = new Hashtable(); + try { @@ -332,6 +335,7 @@ public class Jalview2XML } int ap, apSize = af.alignPanels.size(); + for (ap = 0; ap < apSize; ap++) { AlignmentPanel apanel = (AlignmentPanel) af.alignPanels @@ -343,9 +347,19 @@ public class Jalview2XML } SaveState(apanel, fileName, jout); + + String dssid = getDatasetIdRef(af.getViewport().getAlignment().getDataset()); + if (!dsses.containsKey(dssid)) + { + dsses.put(dssid, af); + } + } } } + + writeDatasetFor(dsses, ""+jout.hashCode()+" "+uniqueSetSuffix, jout); + try { jout.flush(); @@ -375,6 +389,7 @@ public class Jalview2XML int ap, apSize = af.alignPanels.size(); FileOutputStream fos = new FileOutputStream(jarFile); JarOutputStream jout = new JarOutputStream(fos); + Hashtable dsses = new Hashtable(); for (ap = 0; ap < apSize; ap++) { AlignmentPanel apanel = (AlignmentPanel) af.alignPanels @@ -385,8 +400,13 @@ public class Jalview2XML jfileName = jfileName + ".xml"; } SaveState(apanel, jfileName, jout); + String dssid = getDatasetIdRef(af.getViewport().getAlignment().getDataset()); + if (!dsses.containsKey(dssid)) + { + dsses.put(dssid, af); + } } - + writeDatasetFor(dsses, fileName, jout); try { jout.flush(); @@ -404,6 +424,22 @@ public class Jalview2XML } } + private void writeDatasetFor(Hashtable dsses, + String fileName, JarOutputStream jout) + { + + for (String dssids:dsses.keySet()) + { + AlignFrame _af = dsses.get(dssids); + String jfileName = fileName + " Dataset for "+ _af.getTitle(); + if (!jfileName.endsWith(".xml")) + { + jfileName = jfileName + ".xml"; + } + SaveState(_af.alignPanel, jfileName, true, jout); + } + } + /** * create a JalviewModel from an algnment view and marshall it to a * JarOutputStream -- 1.7.10.2