X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FJalviewFileChooser.java;h=a7f8fa6f43ac905b2a174678bd84ecc777d2185f;hb=7047b076a62df177047ceb16c3611efe020bdd76;hp=c90ecdc5ef24475e8b7bbf845a774325d41690c4;hpb=fab0afc9e1e7a5ca460f0cbd48545536f989a435;p=jalview.git diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index c90ecdc..a7f8fa6 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -25,6 +25,7 @@ import jalview.bin.Cache; import jalview.gui.JvOptionPane; import jalview.util.MessageManager; import jalview.util.Platform; +import jalview.util.dialogrunner.DialogRunner; import jalview.util.dialogrunner.DialogRunnerI; import jalview.util.dialogrunner.Response; import jalview.util.dialogrunner.RunResponse; @@ -63,8 +64,8 @@ import javax.swing.plaf.basic.BasicFileChooserUI; public class JalviewFileChooser extends JFileChooser implements PropertyChangeListener, DialogRunnerI { - jalview.util.dialogrunner.DialogRunner runner = new jalview.util.dialogrunner.DialogRunner<>( - this); + DialogRunner runner = new DialogRunner<>(this); + /** * Factory method to return a file chooser that offers readable alignment file * formats @@ -191,16 +192,23 @@ public class JalviewFileChooser extends JFileChooser return f; } - public void openDialog(Component parent) + /** + * Overridden for JalviewJS compatibility: only one thread in Javascript, + * so we can't wait for user choice in another thread and then perform the + * desired action + */ + @Override + public int showOpenDialog(Component parent) { runner.resetResponses(); - int value = showOpenDialog(this); + int value = super.showOpenDialog(this); /** * @j2sNative */ { runner.firstRun(value); } + return value; } /** @@ -396,6 +404,11 @@ public class JalviewFileChooser extends JFileChooser }; }; + /** + * Overridden for JalviewJS compatibility: only one thread in Javascript, + * so we can't wait for user choice in another thread and then perform the + * desired action + */ @Override public int showSaveDialog(Component parent) throws HeadlessException { @@ -454,14 +467,14 @@ public class JalviewFileChooser extends JFileChooser class RecentlyOpened extends JPanel { - JList list; + JList list; public RecentlyOpened() { String historyItems = jalview.bin.Cache.getProperty("RECENT_FILE"); StringTokenizer st; - Vector recent = new Vector(); + Vector recent = new Vector<>(); if (historyItems != null) { @@ -469,11 +482,11 @@ public class JalviewFileChooser extends JFileChooser while (st.hasMoreTokens()) { - recent.addElement(st.nextElement()); + recent.addElement(st.nextToken()); } } - list = new JList(recent); + list = new JList<>(recent); DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT); @@ -499,7 +512,7 @@ public class JalviewFileChooser extends JFileChooser layout.putConstraint(SpringLayout.NORTH, scroller, 5, SpringLayout.NORTH, this); - if (new Platform().isAMac()) + if (Platform.isAMac()) { scroller.setPreferredSize(new Dimension(500, 100)); }