JAL-1668 further clean-up of popup menu and NPE check while transfering ResNum featur...
[jalview.git] / src / jalview / gui / Jalview2XML.java
index a448d19..2799a7e 100644 (file)
@@ -163,7 +163,7 @@ public class Jalview2XML
    */
   Map<String, SequenceI> seqRefIds = null;
 
-  Vector frefedSequence = null;
+  Vector<Object[]> frefedSequence = null;
 
   boolean raiseGUI = true; // whether errors are raised in dialog boxes or not
 
@@ -258,7 +258,7 @@ public class Jalview2XML
       int r = 0, rSize = frefedSequence.size();
       while (r < rSize)
       {
-        Object[] ref = (Object[]) frefedSequence.elementAt(r);
+        Object[] ref = frefedSequence.elementAt(r);
         if (ref != null)
         {
           String sref = (String) ref[0];
@@ -761,10 +761,11 @@ public class Jalview2XML
           if (sf[index].otherDetails != null)
           {
             String key;
-            Enumeration keys = sf[index].otherDetails.keys();
-            while (keys.hasMoreElements())
+            Iterator<String> keys = sf[index].otherDetails.keySet()
+                    .iterator();
+            while (keys.hasNext())
             {
-              key = keys.nextElement().toString();
+              key = keys.next();
               OtherData keyValue = new OtherData();
               keyValue.setKey(key);
               keyValue.setValue(sf[index].otherDetails.get(key).toString());
@@ -879,7 +880,7 @@ public class Jalview2XML
     // SAVE MAPPINGS
     if (jal.getCodonFrames() != null)
     {
-      Set<AlignedCodonFrame> jac = jal.getCodonFrames();
+      List<AlignedCodonFrame> jac = jal.getCodonFrames();
       for (AlignedCodonFrame acf : jac)
       {
         AlcodonFrame alc = new AlcodonFrame();
@@ -1092,15 +1093,26 @@ public class Jalview2XML
       view.setViewName(av.viewName);
       view.setGatheredViews(av.isGatherViewsHere());
 
-      Rectangle position = ap.av.getExplodedGeometry();
-      if (position == null)
+      Rectangle size = ap.av.getExplodedGeometry();
+      Rectangle position = size;
+      if (size == null)
       {
-        position = ap.alignFrame.getBounds();
+        size = ap.alignFrame.getBounds();
+        if (av.getCodingComplement() != null)
+        {
+          position = ((SplitFrame) ap.alignFrame.getSplitViewContainer())
+                  .getBounds();
+        }
+        else
+        {
+          position = size;
+        }
       }
       view.setXpos(position.x);
       view.setYpos(position.y);
-      view.setWidth(position.width);
-      view.setHeight(position.height);
+
+      view.setWidth(size.width);
+      view.setHeight(size.height);
 
       view.setStartRes(av.startRes);
       view.setStartSeq(av.startSeq);
@@ -1937,16 +1949,16 @@ public class Jalview2XML
     if (jds.getDatasetSequence() != null)
     {
       vamsasSeq.setDsseqid(seqHash(jds.getDatasetSequence()));
-      if (jds.getDatasetSequence().getDBRef() != null)
+      if (jds.getDatasetSequence().getDBRefs() != null)
       {
-        dbrefs = jds.getDatasetSequence().getDBRef();
+        dbrefs = jds.getDatasetSequence().getDBRefs();
       }
     }
     else
     {
       vamsasSeq.setDsseqid(id); // so we can tell which sequences really are
       // dataset sequences only
-      dbrefs = jds.getDBRef();
+      dbrefs = jds.getDBRefs();
     }
     if (dbrefs != null)
     {
@@ -2167,6 +2179,7 @@ public class Jalview2XML
       {
         SwingUtilities.invokeAndWait(new Runnable()
         {
+          @Override
           public void run()
           {
             setLoadingFinishedForNewStructureViewers();
@@ -2241,7 +2254,7 @@ public class Jalview2XML
     }
     if (frefedSequence == null)
     {
-      frefedSequence = new Vector();
+      frefedSequence = new Vector<Object[]>();
     }
 
     AlignFrame af = null, _af = null;
@@ -2453,6 +2466,11 @@ public class Jalview2XML
     int width = (int) dnaFrame.getBounds().getWidth();
     int height = (int) (dnaFrame.getBounds().getHeight()
             + proteinFrame.getBounds().getHeight() + 50);
+
+    /*
+     * SplitFrame location is saved to both enclosed frames
+     */
+    splitFrame.setLocation(dnaFrame.getX(), dnaFrame.getY());
     Desktop.addInternalFrame(splitFrame, title, width, height);
 
     /*
@@ -2832,7 +2850,7 @@ public class Jalview2XML
             {
               mapping = addMapping(maps[m].getMapping());
             }
-            if (dnaseq != null)
+            if (dnaseq != null && mapping.getTo() != null)
             {
               cf.addMap(dnaseq, mapping.getTo(), mapping.getMap());
             }