JAL-2154 register any new dataset codon frames only when all data imported
authorJim Procter <jprocter@issues.jalview.org>
Fri, 29 Jul 2016 14:02:03 +0000 (15:02 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Fri, 29 Jul 2016 14:02:03 +0000 (15:02 +0100)
src/jalview/gui/Jalview2XML.java

index 094fa7a..3e1359d 100644 (file)
@@ -2349,6 +2349,7 @@ public class Jalview2XML
       initSeqRefs();
     }
     AlignFrame af = null, _af = null;
+    IdentityHashMap<AlignmentI, AlignmentI> importedDatasets = new IdentityHashMap<AlignmentI, AlignmentI>();
     Map<String, AlignFrame> gatherToThisFrame = new HashMap<String, AlignFrame>();
     final String file = jprovider.getFilename();
     try
@@ -2383,6 +2384,9 @@ public class Jalview2XML
               {
                 gatherToThisFrame.put(af.viewport.getSequenceSetId(), af);
               }
+              // Save dataset to register mappings once all resolved
+              importedDatasets.put(af.viewport.getAlignment().getDataset(),
+                      af.viewport.getAlignment().getDataset());
             }
           }
           entryCount++;
@@ -2456,7 +2460,14 @@ public class Jalview2XML
     }
 
     restoreSplitFrames();
-
+    for (AlignmentI ds : importedDatasets.keySet())
+    {
+      if (ds.getCodonFrames() != null)
+      {
+        StructureSelectionManager.getStructureSelectionManager(
+                Desktop.instance).registerMappings(ds.getCodonFrames());
+      }
+    }
     if (errorMessage != null)
     {
       reportErrors();