public class RecentFileList
extends java.lang.Object
RecentFileList manages a list of file-sets. It is intended to be used to manage a collection of recently used files for convenient re-opening by a user. Note that each item in the list can comprise multiple files. The length of the list is currently hard-wired to 8, though this would be trivial to change if necessary.
RecentFileList loads and saves its data to a Preferences
object, using the keys of the form recentFileX
, where X is a non-negative
integer less than the maximum number of file-sets.
Constructor and Description |
---|
RecentFileList(java.util.prefs.Preferences prefs)
Creates a new file list, reading data (if any) from the supplied
Preferences object. |
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.List<java.io.File> files)
Adds a new file-set to the top of the list.
|
java.util.List<java.io.File> |
getFilesAndReorder(int index)
Returns a specified file-set and moves it to the top of the list.
|
java.util.List<java.lang.String> |
getFilesetLongNames()
Gets a list containing a long name for each fileset, intended for
use in the tooltips of the recent files menu.
|
java.lang.String[] |
getFilesetNames()
Gets a list containing the names of the file-sets in the file list.
|
void |
save(java.util.prefs.Preferences prefs)
Saves the recent file list to the specified Preferences object.
|
public RecentFileList(java.util.prefs.Preferences prefs)
Preferences
object. If any recentFile0
(and so on)
keys are absent, no error is raised, and the corresponding slots
in the file list are left empty.prefs
- the preferences object from which the read file list
datapublic void save(java.util.prefs.Preferences prefs)
prefs
- the Preferences to which to save the recent file listpublic java.lang.String[] getFilesetNames()
public java.util.List<java.lang.String> getFilesetLongNames()
public java.util.List<java.io.File> getFilesAndReorder(int index)
index
- the index of a file-set within the listpublic void add(java.util.List<java.io.File> files)
files
- the files to be added (as a single file-set) to the list