JAL-3875 fully reset filter combo-box when fetch 3d-beacons button is pressed, and...
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 5 Nov 2021 12:45:13 +0000 (12:45 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 5 Nov 2021 16:52:35 +0000 (16:52 +0000)
src/jalview/gui/StructureChooser.java

index e400b51..ce57373 100644 (file)
@@ -191,7 +191,7 @@ public class StructureChooser extends GStructureChooser
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        promptForTDBFetch();
+        promptForTDBFetch(false);
       }
     });
 
@@ -242,7 +242,11 @@ public class StructureChooser extends GStructureChooser
     updateCurrentView();
   }
 
-  private void promptForTDBFetch()
+  /**
+   * raises dialog for Uniprot fetch followed by 3D beacons search
+   * @param ignoreGui - when true, don't ask, just fetch 
+   */
+  public void promptForTDBFetch(boolean ignoreGui)
   {
     final long progressId = System.currentTimeMillis();
 
@@ -260,6 +264,9 @@ public class StructureChooser extends GStructureChooser
         // redo initial discovery - this time with 3d beacons
         // Executors.
         previousWantedFields=null;
+        lastSelected=(FilterOption) cmb_filterOption.getSelectedItem();
+        cmb_filterOption.setSelectedItem(null);
+        cachedPDBExists=false; // reset to initial
         initialStructureDiscovery();
         if (!isStructuresDiscovered())
         {
@@ -267,6 +274,7 @@ public class StructureChooser extends GStructureChooser
           btn_queryTDB.setToolTipText(MessageManager.getString("status.no_structures_discovered_from_3d_beacons"));
           btn_queryTDB.setEnabled(false);
         } else {
+          cmb_filterOption.setSelectedIndex(0); // select 'best'
           btn_queryTDB.setVisible(false);
           progressBar.setProgressBar(null, progressId);
         }
@@ -322,8 +330,13 @@ public class StructureChooser extends GStructureChooser
         }
       };
     };
+    if (ignoreGui)
+    {
+      Executors.defaultThreadFactory().newThread(discoverCanonicalDBrefs).start();
+      return;
+    }
     // need cancel and no to result in the discoverPDB action - mocked is
-    // 'cancel'
+    // 'cancel' TODO: mock should be OK
     JvOptionPane.newOptionDialog(this)
             .setResponseHandler(JvOptionPane.OK_OPTION,
                     discoverCanonicalDBrefs)