numerous bugfixs (tree panel synchs) and DatastoreRegistry clas.
authorjprocter <Jim Procter>
Fri, 12 Jun 2009 15:54:09 +0000 (15:54 +0000)
committerjprocter <Jim Procter>
Fri, 12 Jun 2009 15:54:09 +0000 (15:54 +0000)
src/jalview/io/VamsasAppDatastore.java

index 886f515..e21a9ed 100644 (file)
@@ -33,6 +33,7 @@ import jalview.gui.Desktop;
 import jalview.gui.TreePanel;
 import jalview.io.vamsas.Datasetsequence;
 import jalview.io.vamsas.DatastoreItem;
+import jalview.io.vamsas.DatastoreRegistry;
 import jalview.io.vamsas.Rangetype;
 import jalview.util.UrlLink;
 
@@ -334,7 +335,6 @@ public class VamsasAppDatastore
       }
       // update dataset
       Sequence sequence;
-      DbRef dbref;
       // set new dataset and alignment sequences based on alignment Nucleotide
       // flag.
       // this *will* break when alignment contains both nucleotide and amino
@@ -367,7 +367,7 @@ public class VamsasAppDatastore
       }
       // dataset.setProvenance(getVamsasProvenance(jal.getDataset().getProvenance()));
       // ////////////////////////////////////////////
-      if (!av.getAlignment().isAligned())
+      if (alignmentWillBeSkipped(av))
       {
         // TODO: trees could be written - but for the moment we just
         addToSkipList(av);
@@ -687,7 +687,7 @@ public class VamsasAppDatastore
           {
             TreePanel tp = (TreePanel) frames[t];
 
-            if (tp.getAlignment() == jal)
+            if (tp.getViewPort().getSequenceSetId().equals(av.getSequenceSetId()))
             {
               DatastoreItem vtree = new jalview.io.vamsas.Tree(this, tp,
                       jal, alignment);
@@ -707,6 +707,17 @@ public class VamsasAppDatastore
     return true;
   }
 
+  /**
+   * very quick test to see if the viewport would be stored in the vamsas document.
+   * Reasons for not storing include the unaligned flag being false.
+   * @param av
+   * @return true if alignment associated with this view will be stored in document.
+   */
+  public boolean alignmentWillBeSkipped(AlignViewport av)
+  {
+    return (!av.getAlignment().isAligned());
+  }
+
   private void addToSkipList(AlignViewport av)
   {
     if (skipList == null)
@@ -1520,8 +1531,9 @@ public class VamsasAppDatastore
   }
   /**
    * synchronize Jalview from the vamsas document
+   * @return number of new views from document
    */
-  public void updateToJalview()
+  public int updateToJalview()
   {
     VAMSAS _roots[] = cdoc.getVamsasRoots();
 
@@ -1652,9 +1664,8 @@ public class VamsasAppDatastore
               jal = (av.hasHiddenRows()) ? av.getAlignment()
                       .getHiddenSequences().getFullAlignment() : av
                       .getAlignment();
-            }
+            } 
             iSize = alignment.getAlignmentSequenceCount();
-            boolean newal = (jal == null) ? true : false;
             boolean refreshal = false;
             Vector newasAnnots = new Vector();
             char gapChar = ' '; // default for new alignments read in from the
@@ -1908,6 +1919,7 @@ public class VamsasAppDatastore
         }
       }
     }
+    return newAlignmentViews.size();
   }
 
   public AlignViewport findViewport(Alignment alignment)
@@ -2715,4 +2727,16 @@ public class VamsasAppDatastore
   {
     this.skipList = skipList;
   }
+  /**
+   * registry for datastoreItems
+   */
+  DatastoreRegistry dsReg = new DatastoreRegistry();
+  public DatastoreRegistry getDatastoreRegisty()
+  {
+    if (dsReg==null)
+    {
+      dsReg = new DatastoreRegistry();
+    }
+    return dsReg;
+  }
 }