JAL-1177 patches to loader to cope with dataset only jalview xml documents
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 25 Apr 2014 13:26:04 +0000 (14:26 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Fri, 25 Apr 2014 13:26:04 +0000 (14:26 +0100)
src/jalview/gui/Jalview2XML.java

index 5f9a131..3499f6d 100644 (file)
@@ -1836,7 +1836,7 @@ public class Jalview2XML
       frefedSequence = new Vector();
     }
 
-    jalview.gui.AlignFrame af = null;
+    jalview.gui.AlignFrame af= null,_af = null;
     Hashtable gatherToThisFrame = new Hashtable();
     final String file = jprovider.getFilename();
     try
@@ -1863,10 +1863,15 @@ public class Jalview2XML
           object = (JalviewModel) unmar.unmarshal(in);
           if (true) // !skipViewport(object))
           {
-            af = LoadFromObject(object, file, true, jprovider);
-            if (af.viewport.gatherViewsHere)
+            _af = LoadFromObject(object, file, true, jprovider);
+            if (object.getJalviewModelSequence().getViewportCount() > 0)
             {
-              gatherToThisFrame.put(af.viewport.getSequenceSetId(), af);
+              af = _af;
+              if (object.getJalviewModelSequence().getViewportCount() > 1
+                      && af.viewport.gatherViewsHere)
+              {
+                gatherToThisFrame.put(af.viewport.getSequenceSetId(), af);
+              }
             }
           }
           entryCount++;
@@ -2089,7 +2094,8 @@ public class Jalview2XML
 
     JalviewModelSequence jms = object.getJalviewModelSequence();
 
-    Viewport view = jms.getViewport(0);
+    Viewport view = (jms.getViewportCount()>0) ? jms.getViewport(0) : null;
+    
     // ////////////////////////////////
     // LOAD SEQUENCES
 
@@ -2614,7 +2620,11 @@ public class Jalview2XML
 
       }
     }
-
+    if (view==null)
+    {
+      // only dataset in this model, so just return.
+      return null;
+    }
     // ///////////////////////////////
     // LOAD VIEWPORT