JAL-4034 Use the new non-modal JDialog for 3DBeacons uniprot lookup confirmation...
[jalview.git] / src / jalview / gui / StructureChooser.java
index 246d162..6eb8d10 100644 (file)
@@ -321,6 +321,7 @@ public class StructureChooser extends GStructureChooser
       @Override
       public void run()
       {
+        btn_queryTDB.setEnabled(false);
         populateSeqsWithoutSourceDBRef();
 
         final int y = seqsWithoutSourceDBRef.size();
@@ -333,6 +334,7 @@ public class StructureChooser extends GStructureChooser
                   { new jalview.ws.dbsources.Uniprot() }, null, false);
           dbRefFetcher.addListener(afterDbRefFetch);
           // ideally this would also gracefully run with callbacks
+
           dbRefFetcher.fetchDBRefs(true);
         }
         else
@@ -357,33 +359,31 @@ public class StructureChooser extends GStructureChooser
     int threshold = Cache.getDefault("UNIPROT_AUTOFETCH_THRESHOLD",
             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.showConfirmDialog(this,
-              MessageManager.formatMessage(
-                      "label.fetch_references_for_3dbeacons",
-                      seqsWithoutSourceDBRef.size()),
-              MessageManager.getString("label.3dbeacons"),
-              JvOptionPane.YES_NO_OPTION, JvOptionPane.PLAIN_MESSAGE);
-      runThread = (answer == JvOptionPane.OK_OPTION);
-    }
-    if (runThread)
-    {
       Executors.defaultThreadFactory().newThread(discoverCanonicalDBrefs)
               .start();
       return;
     }
-    else
-    {
-      revertview.run();
-    }
+    // need cancel and no to result in the discoverPDB action - mocked is
+    // 'cancel' TODO: mock should be OK
+
+    StructureChooser thisSC = this;
+    JvOptionPane.newOptionDialog(thisSC.getFrame())
+            .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"), false);
   }
 
   /**