JAL-3048 AlignFrame->File->Load Tree adapted for js
authorJim Procter <jprocter@issues.jalview.org>
Fri, 29 Jun 2018 15:38:29 +0000 (16:38 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Fri, 29 Jun 2018 15:38:29 +0000 (16:38 +0100)
src/jalview/gui/AlignFrame.java

index aa0a1fe..dafeafc 100644 (file)
@@ -3915,33 +3915,39 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     chooser.setToolTipText(
             MessageManager.getString("label.load_tree_file"));
 
-    int value = chooser.showOpenDialog(null);
-
-    if (value == JalviewFileChooser.APPROVE_OPTION)
-    {
-      String filePath = chooser.getSelectedFile().getPath();
-      Cache.setProperty("LAST_DIRECTORY", filePath);
-      NewickFile fin = null;
-      try
-      {
-        fin = new NewickFile(filePath, DataSourceType.FILE);
-        viewport.setCurrentTree(showNewickTree(fin, filePath).getTree());
-      } catch (Exception ex)
-      {
-        JvOptionPane.showMessageDialog(Desktop.desktop, ex.getMessage(),
-                MessageManager.getString("label.problem_reading_tree_file"),
-                JvOptionPane.WARNING_MESSAGE);
-        ex.printStackTrace();
-      }
-      if (fin != null && fin.hasWarningMessage())
-      {
-        JvOptionPane.showMessageDialog(Desktop.desktop,
-                fin.getWarningMessage(),
-                MessageManager
-                        .getString("label.possible_problem_with_tree_file"),
-                JvOptionPane.WARNING_MESSAGE);
-      }
-    }
+    chooser.response(
+            new jalview.util.dialogrunner.RunResponse(JalviewFileChooser.APPROVE_OPTION)
+            {
+              @Override
+              public void run()
+              {
+                String filePath = chooser.getSelectedFile().getPath();
+                Cache.setProperty("LAST_DIRECTORY", filePath);
+                NewickFile fin = null;
+                try
+                {
+                  fin = new NewickFile(filePath, DataSourceType.FILE);
+                  viewport.setCurrentTree(
+                          showNewickTree(fin, filePath).getTree());
+                } catch (Exception ex)
+                {
+                  JvOptionPane.showMessageDialog(Desktop.desktop,
+                          ex.getMessage(),
+                          MessageManager.getString(
+                                  "label.problem_reading_tree_file"),
+                          JvOptionPane.WARNING_MESSAGE);
+                  ex.printStackTrace();
+                }
+                if (fin != null && fin.hasWarningMessage())
+                {
+                  JvOptionPane.showMessageDialog(Desktop.desktop,
+                          fin.getWarningMessage(),
+                          MessageManager.getString(
+                                  "label.possible_problem_with_tree_file"),
+                          JvOptionPane.WARNING_MESSAGE);
+                }
+              }
+            }).openDialog(this);
   }
 
   public TreePanel showNewickTree(NewickFile nf, String treeTitle)