JAL-1942 JAL-1479 DBRefFetcher refactor
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 22 Oct 2015 15:10:56 +0000 (16:10 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 22 Oct 2015 15:10:56 +0000 (16:10 +0100)
src/jalview/gui/AlignFrame.java
src/jalview/gui/PopupMenu.java
src/jalview/ws/DBRefFetcher.java
src/jalview/ws/DasSequenceFeatureFetcher.java

index 5c29b9b..a41e519 100644 (file)
@@ -845,6 +845,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    * operation that affects the data in the current view (selection changed,
    * etc) to update the menus to reflect the new state.
    */
+  @Override
   public void setMenusForViewport()
   {
     setMenusFromViewport(viewport);
@@ -1401,6 +1402,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     alignPanel.makeEPS(f);
   }
 
+  @Override
   public void createSVG(File f)
   {
     alignPanel.makeSVG(f);
@@ -1574,6 +1576,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
   }
 
+  @Override
   public void addHistoryItem(CommandI command)
   {
     if (command.getSize() > 0)
@@ -3497,6 +3500,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    * @param cs
    *          DOCUMENT ME!
    */
+  @Override
   public void changeColour(ColourSchemeI cs)
   {
     // TODO: pull up to controller method
@@ -5531,8 +5535,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           @Override
           public void run()
           {
+            boolean isNuclueotide = alignPanel.alignFrame
+                    .getViewport().getAlignment()
+                    .isNucleotide();
             new jalview.ws.DBRefFetcher(alignPanel.av
-                    .getSequenceSelection(), alignPanel.alignFrame)
+                    .getSequenceSelection(),
+                    alignPanel.alignFrame, null,
+                    alignPanel.alignFrame.featureSettings,
+                    isNuclueotide)
                     .fetchDBRefs(false);
           }
         }).start();
@@ -5601,9 +5611,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                       @Override
                       public void run()
                       {
+                        boolean isNuclueotide = alignPanel.alignFrame
+                                .getViewport().getAlignment()
+                                .isNucleotide();
                         new jalview.ws.DBRefFetcher(alignPanel.av
                                 .getSequenceSelection(),
-                                alignPanel.alignFrame, dassource)
+                                alignPanel.alignFrame, dassource,
+                                alignPanel.alignFrame.featureSettings,
+                                isNuclueotide)
                                 .fetchDBRefs(false);
                       }
                     }).start();
@@ -5637,9 +5652,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                       @Override
                       public void run()
                       {
+                        boolean isNuclueotide = alignPanel.alignFrame
+                                .getViewport().getAlignment()
+                                .isNucleotide();
                         new jalview.ws.DBRefFetcher(alignPanel.av
                                 .getSequenceSelection(),
-                                alignPanel.alignFrame, dassource)
+                                alignPanel.alignFrame, dassource,
+                                alignPanel.alignFrame.featureSettings,
+                                isNuclueotide)
                                 .fetchDBRefs(false);
                       }
                     }).start();
@@ -5688,9 +5708,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                         @Override
                         public void run()
                         {
+                          boolean isNuclueotide = alignPanel.alignFrame
+                                  .getViewport().getAlignment()
+                                  .isNucleotide();
                           new jalview.ws.DBRefFetcher(alignPanel.av
                                   .getSequenceSelection(),
-                                  alignPanel.alignFrame, dassrc)
+                                  alignPanel.alignFrame, dassrc,
+                                  alignPanel.alignFrame.featureSettings,
+                                  isNuclueotide)
                                   .fetchDBRefs(false);
                         }
                       }).start();
@@ -5755,6 +5780,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     viewport.firePropertyChange("alignment", null, al);
   }
 
+  @Override
   public void setShowSeqFeatures(boolean b)
   {
     showSeqFeatures.setSelected(b);
index 3491431..e86b2c5 100644 (file)
@@ -2451,9 +2451,13 @@ public class PopupMenu extends JPopupMenu
       @Override
       public void run()
       {
+        boolean isNuclueotide = ap.alignFrame.getViewport().getAlignment()
+                .isNucleotide();
 
-        new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
+        new jalview.ws.DBRefFetcher(sequences, ap.alignFrame, null,
+                ap.alignFrame.featureSettings, isNuclueotide)
                 .fetchDBRefs(false);
+
       }
 
     });
index b708ec1..2e0197c 100644 (file)
@@ -28,9 +28,9 @@ import jalview.datamodel.DBRefSource;
 import jalview.datamodel.Mapping;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
-import jalview.gui.AlignFrame;
 import jalview.gui.CutAndPasteTransfer;
 import jalview.gui.Desktop;
+import jalview.gui.FeatureSettings;
 import jalview.gui.IProgressIndicator;
 import jalview.gui.OOMWarning;
 import jalview.util.MessageManager;
@@ -91,34 +91,25 @@ public class DBRefFetcher implements Runnable
   }
 
   /**
-   * Creates a new SequenceFeatureFetcher object and fetches from the currently
-   * selected set of databases.
+   * Creates a new DBRefFetcher object and fetches from the currently selected
+   * set of databases, if this is null then it fetches based on feature settings
    * 
    * @param seqs
-   *          fetch references for these sequences
-   * @param af
-   *          the parent alignframe for progress bar monitoring.
-   */
-  public DBRefFetcher(SequenceI[] seqs, AlignFrame af)
-  {
-    this(seqs, af, null);
-  }
-
-  /**
-   * Creates a new SequenceFeatureFetcher object and fetches from the currently
-   * selected set of databases.
-   * 
-   * @param seqs
-   *          fetch references for these sequences
-   * @param af
-   *          the parent alignframe for progress bar monitoring.
+   *          fetch references for these SequenceI array
+   * @param progressIndicatorFrame
+   *          the frame for progress bar monitoring
    * @param sources
-   *          array of database source strings to query references from
+   *          array of DbSourceProxy to query references form
+   * @param featureSettings
+   *          FeatureSettings to get alternative DbSourceProxy from
+   * @param isNucleotide
+   *          indicates if the array of SequenceI are Nucleotides or not
    */
-  public DBRefFetcher(SequenceI[] seqs, AlignFrame af,
-          DbSourceProxy[] sources)
+  public DBRefFetcher(SequenceI[] seqs,
+          IProgressIndicator progressIndicatorFrame,
+          DbSourceProxy[] sources, FeatureSettings featureSettings, boolean isNucleotide)
   {
-    this.af = af;
+    this.af = progressIndicatorFrame;
     alseqs = new SequenceI[seqs.length];
     SequenceI[] ds = new SequenceI[seqs.length];
     for (int i = 0; i < seqs.length; i++)
@@ -135,7 +126,8 @@ public class DBRefFetcher implements Runnable
     }
     this.dataset = ds;
     // TODO Jalview 2.5 lots of this code should be in the gui package!
-    sfetcher = jalview.gui.SequenceFetcher.getSequenceFetcherSingleton(af);
+    sfetcher = jalview.gui.SequenceFetcher
+            .getSequenceFetcherSingleton(progressIndicatorFrame);
     // set default behaviour for transferring excess sequence data to the
     // dataset
     trimDsSeqs = Cache.getDefault("TRIM_FETCHED_DATASET_SEQS", true);
@@ -145,7 +137,7 @@ public class DBRefFetcher implements Runnable
       String[] defdb = null, otherdb = sfetcher
               .getDbInstances(jalview.ws.dbsources.das.datamodel.DasSequenceSource.class);
       List<DbSourceProxy> selsources = new ArrayList<DbSourceProxy>();
-      Vector dasselsrc = (af.featureSettings != null) ? af.featureSettings
+      Vector dasselsrc = (featureSettings != null) ? featureSettings
               .getSelectedSources() : new jalview.gui.DasSourceBrowser()
               .getSelectedSources();
       Enumeration<jalviewSourceI> en = dasselsrc.elements();
@@ -163,7 +155,7 @@ public class DBRefFetcher implements Runnable
         }
       }
       // select appropriate databases based on alignFrame context.
-      if (af.getViewport().getAlignment().isNucleotide())
+      if (isNucleotide)
       {
         defdb = DBRefSource.DNACODINGDBS;
       }
@@ -283,6 +275,7 @@ public class DBRefFetcher implements Runnable
   /**
    * DOCUMENT ME!
    */
+  @Override
   public void run()
   {
     if (dbSources == null)
index 8faba60..d7ba24d 100644 (file)
@@ -238,6 +238,7 @@ public class DasSequenceFeatureFetcher
 
   class FetchSeqFeatures implements Runnable
   {
+    @Override
     public void run()
     {
       startFetching();
@@ -247,10 +248,15 @@ public class DasSequenceFeatureFetcher
 
   class FetchDBRefs implements Runnable
   {
+    @Override
     public void run()
     {
       running = true;
-      new DBRefFetcher(sequences, af).fetchDBRefs(true);
+      boolean isNuclueotide = af.getViewport().getAlignment()
+              .isNucleotide();
+      new jalview.ws.DBRefFetcher(sequences, af, null, af.featureSettings,
+              isNuclueotide).fetchDBRefs(true);
+
       startFetching();
       setGuiFetchComplete();
     }