JAL-4034 Non-blocking 3D Beacons query after warning dialog
authorBen Soares <b.soares@dundee.ac.uk>
Mon, 11 Jul 2022 16:14:56 +0000 (17:14 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 11 Jul 2022 16:14:56 +0000 (17:14 +0100)
src/jalview/gui/StructureChooser.java

index 3f5f39c..a5fb2dd 100644 (file)
@@ -357,29 +357,48 @@ public class StructureChooser extends GStructureChooser
     int threshold = Cache.getDefault("THRESHOLD_WARN_UNIPROT_FETCH",
             THRESHOLD_WARN_UNIPROT_FETCH_NEEDED);
     Console.debug("Using Uniprot fetch threshold of " + threshold);
+    boolean runThread = false;
     if (ignoreGui || seqsWithoutSourceDBRef.size() < threshold)
     {
+      runThread = true;
+    }
+    // need cancel and no to result in the discoverPDB action - mocked is
+    // 'cancel' TODO: mock should be OK
+    if (!runThread)
+    {
+      int answer = JvOptionPane.showOptionDialog(this,
+
+              MessageManager.formatMessage(
+                      "label.fetch_references_for_3dbeacons",
+                      seqsWithoutSourceDBRef.size()),
+
+              MessageManager.getString("label.3dbeacons"),
+
+              JvOptionPane.YES_NO_OPTION,
+
+              JvOptionPane.PLAIN_MESSAGE,
+
+              null,
+
+              new Object[]
+              { MessageManager.getString("action.ok"),
+                  MessageManager.getString("action.cancel") },
+
+              MessageManager.getString("action.ok")
+
+      );
+      runThread = (answer == JvOptionPane.OK_OPTION);
+    }
+    if (runThread)
+    {
       Executors.defaultThreadFactory().newThread(discoverCanonicalDBrefs)
               .start();
       return;
     }
-    // need cancel and no to result in the discoverPDB action - mocked is
-    // 'cancel' TODO: mock should be OK
-    JvOptionPane.newOptionDialog(this)
-            .setResponseHandler(JvOptionPane.OK_OPTION,
-                    discoverCanonicalDBrefs)
-            .setResponseHandler(JvOptionPane.CANCEL_OPTION, revertview)
-            .setResponseHandler(JvOptionPane.NO_OPTION, revertview)
-            .showDialog(
-                    MessageManager.formatMessage(
-                            "label.fetch_references_for_3dbeacons",
-                            seqsWithoutSourceDBRef.size()),
-                    MessageManager.getString("label.3dbeacons"),
-                    JvOptionPane.YES_NO_OPTION, JvOptionPane.PLAIN_MESSAGE,
-                    null, new Object[]
-                    { MessageManager.getString("action.ok"),
-                        MessageManager.getString("action.cancel") },
-                    MessageManager.getString("action.ok"));
+    else
+    {
+      revertview.run();
+    }
   }
 
   /**