From d7527de9d963ee1869b0c7545be3d9213cdd0c6d Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 10 Dec 2018 12:09:43 +0000 Subject: [PATCH] JAL-1421 added type to List and Vector --- src/jalview/io/JalviewFileChooser.java | 33 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 271ac53..6b0eba8 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -44,6 +44,8 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.SpringLayout; +import javax.swing.SwingUtilities; +import javax.swing.border.TitledBorder; import javax.swing.plaf.basic.BasicFileChooserUI; /** @@ -392,28 +394,35 @@ public class JalviewFileChooser extends JFileChooser } } + /** + * A panel to set as the 'accessory' component to the file chooser dialog, + * holding a list of recently opened files (if any). These are held as a + * tab-separated list of file paths under key RECENT_FILE in + * .jalview_properties. A click in the list calls a method in + * JalviewFileChooser to set the chosen file as the selection. + */ class RecentlyOpened extends JPanel { - JList list; + private static final long serialVersionUID = 1L; - public RecentlyOpened() - { + private JList list; - String historyItems = jalview.bin.Cache.getProperty("RECENT_FILE"); + RecentlyOpened() + { + String historyItems = Cache.getProperty("RECENT_FILE"); StringTokenizer st; - Vector recent = new Vector(); + Vector recent = new Vector<>(); if (historyItems != null) { st = new StringTokenizer(historyItems, "\t"); - 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); @@ -428,7 +437,7 @@ public class JalviewFileChooser extends JFileChooser } }); - this.setBorder(new javax.swing.border.TitledBorder( + this.setBorder(new TitledBorder( MessageManager.getString("label.recently_opened"))); final JScrollPane scroller = new JScrollPane(list); @@ -439,7 +448,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)); } @@ -450,7 +459,7 @@ public class JalviewFileChooser extends JFileChooser this.add(scroller); - javax.swing.SwingUtilities.invokeLater(new Runnable() + SwingUtilities.invokeLater(new Runnable() { @Override public void run() @@ -459,8 +468,6 @@ public class JalviewFileChooser extends JFileChooser .setValue(scroller.getHorizontalScrollBar().getMaximum()); } }); - } - } } -- 1.7.10.2