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)