From 3c632a005aed4189a1f1ad1a34d35303829cee4f Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 3 Feb 2015 16:49:47 +0000 Subject: [PATCH] JAL-845 preparation for awareness of AlignFrame in SplitFrame for save --- src/jalview/gui/Jalview2XML.java | 89 ++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index d3a7e2c..f08306a 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -336,7 +336,7 @@ public class Jalview2XML */ public void SaveState(JarOutputStream jout) { - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + AlignFrame[] frames = Desktop.getAlignFrames(); // Desktop.desktop.getAllFrames(); if (frames == null) { @@ -353,71 +353,66 @@ public class Jalview2XML // NOTE ALSO new PrintWriter must be used for each new JarEntry PrintWriter out = null; - Vector shortNames = new Vector(); + List shortNames = new ArrayList(); // REVERSE ORDER for (int i = frames.length - 1; i > -1; i--) { - if (frames[i] instanceof AlignFrame) + AlignFrame af = frames[i]; + // skip ? + if (skipList != null + && skipList + .containsKey(af.getViewport().getSequenceSetId())) { - AlignFrame af = (AlignFrame) frames[i]; - // skip ? - if (skipList != null - && skipList.containsKey(af.getViewport() - .getSequenceSetId())) - { - continue; - } + continue; + } - String shortName = af.getTitle(); + String shortName = af.getTitle(); - if (shortName.indexOf(File.separatorChar) > -1) + if (shortName.indexOf(File.separatorChar) > -1) + { + shortName = shortName.substring(shortName + .lastIndexOf(File.separatorChar) + 1); + } + + int count = 1; + + while (shortNames.contains(shortName)) + { + if (shortName.endsWith("_" + (count - 1))) { - shortName = shortName.substring(shortName - .lastIndexOf(File.separatorChar) + 1); + shortName = shortName.substring(0, shortName.lastIndexOf("_")); } - int count = 1; + shortName = shortName.concat("_" + count); + count++; + } - while (shortNames.contains(shortName)) - { - if (shortName.endsWith("_" + (count - 1))) - { - shortName = shortName - .substring(0, shortName.lastIndexOf("_")); - } + shortNames.add(shortName); - shortName = shortName.concat("_" + count); - count++; - } + if (!shortName.endsWith(".xml")) + { + shortName = shortName + ".xml"; + } - shortNames.addElement(shortName); + int apSize = af.alignPanels.size(); - if (!shortName.endsWith(".xml")) + for (int ap = 0; ap < apSize; ap++) + { + AlignmentPanel apanel = af.alignPanels.get(ap); + String fileName = apSize == 1 ? shortName : ap + shortName; + if (!fileName.endsWith(".xml")) { - shortName = shortName + ".xml"; + fileName = fileName + ".xml"; } - int ap, apSize = af.alignPanels.size(); + SaveState(apanel, fileName, jout); - for (ap = 0; ap < apSize; ap++) + String dssid = getDatasetIdRef(af.getViewport().getAlignment() + .getDataset()); + if (!dsses.containsKey(dssid)) { - AlignmentPanel apanel = af.alignPanels.get(ap); - String fileName = apSize == 1 ? shortName : ap + shortName; - if (!fileName.endsWith(".xml")) - { - fileName = fileName + ".xml"; - } - - SaveState(apanel, fileName, jout); - - String dssid = getDatasetIdRef(af.getViewport().getAlignment() - .getDataset()); - if (!dsses.containsKey(dssid)) - { - dsses.put(dssid, af); - } - + dsses.put(dssid, af); } } } -- 1.7.10.2