X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FJalviewFileChooser.java;fp=src%2Fjalview%2Fio%2FJalviewFileChooser.java;h=6b0eba819cc58215627443d8a72c27dd35ca2ec4;hb=d7527de9d963ee1869b0c7545be3d9213cdd0c6d;hp=271ac53943248cbdc84b3aa50fce707ec1ee0bbc;hpb=3dce97f35c416e0cc6f833df95544819b05059da;p=jalview.git 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()); } }); - } - } }