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;
/**
}
}
+ /**
+ * 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 <code>RECENT_FILE</code> in
+ * <code>.jalview_properties</code>. 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<String> list;
- String historyItems = jalview.bin.Cache.getProperty("RECENT_FILE");
+ RecentlyOpened()
+ {
+ String historyItems = Cache.getProperty("RECENT_FILE");
StringTokenizer st;
- Vector recent = new Vector();
+ Vector<String> 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);
}
});
- this.setBorder(new javax.swing.border.TitledBorder(
+ this.setBorder(new TitledBorder(
MessageManager.getString("label.recently_opened")));
final JScrollPane scroller = new JScrollPane(list);
layout.putConstraint(SpringLayout.NORTH, scroller, 5,
SpringLayout.NORTH, this);
- if (new Platform().isAMac())
+ if (Platform.isAMac())
{
scroller.setPreferredSize(new Dimension(500, 100));
}
this.add(scroller);
- javax.swing.SwingUtilities.invokeLater(new Runnable()
+ SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
.setValue(scroller.getHorizontalScrollBar().getMaximum());
}
});
-
}
-
}
}