Package xal.tools.apputils.files
Class RecentFileTracker
java.lang.Object
xal.tools.apputils.files.RecentFileTracker
RecentFileTracker caches recently accessed files into the the user's
preferences and has accessors for getting the recent files and the most
recent folder.
- Author:
- tap
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
default buffer size for a trackerprotected final String
ID for the preferencesprotected final Preferences
preferences storageprotected final int
buffer size for this tracker -
Constructor Summary
ConstructorsConstructorDescriptionRecentFileTracker
(int bufferSize, Class<?> preferenceNode, String preferenceID) Constructor which generates the preferences from the specified preference nodeRecentFileTracker
(int bufferSize, Preferences prefs, String preferenceID) Primary constructorRecentFileTracker
(Class<?> preferenceNode, String preferenceID) Constructor with a default buffer size of 10 -
Method Summary
Modifier and TypeMethodDescriptionapplyMostRecentFile
(JFileChooser fileChooser) Set the file chooser's selected file to the most recent file.applyRecentFolder
(JFileChooser fileChooser) Set the file chooser's current directory to the recent folder.void
Cache the URL of the specified file.void
Cache the URLvoid
Cache the URL.void
Clear the cache of the recent URL specsGet the most recent fileGet the folder corresponding to the most recently cached URL.Get the folder path corresponding to the most recently cached URL.String[]
Get the array of URLs corresponding to recently registered URLs.protected static String[]
Parse a string into tokens where whitespace is the delimiter.protected static String[]
Parse a string into tokens with the specified delimiter.
-
Field Details
-
DEFAULT_BUFFER_SIZE
protected static final int DEFAULT_BUFFER_SIZEdefault buffer size for a tracker- See Also:
-
recentUrlsBufferSize
protected final int recentUrlsBufferSizebuffer size for this tracker -
prefs
preferences storage -
preferenceId
ID for the preferences
-
-
Constructor Details
-
RecentFileTracker
Primary constructor- Parameters:
bufferSize
- the buffer size of the recent URL specs to cacheprefs
- the preferences used to save the cache of recent URL specspreferenceID
- the ID of the preference to save
-
RecentFileTracker
Constructor which generates the preferences from the specified preference node- Parameters:
bufferSize
- the buffer size of the recent URL specs to cachepreferenceNode
- the node used for saving the preferencepreferenceID
- the ID of the preference to save
-
RecentFileTracker
Constructor with a default buffer size of 10- Parameters:
preferenceNode
- the node used for saving the preferencepreferenceID
- the ID of the preference to save
-
-
Method Details
-
clearCache
public void clearCache()Clear the cache of the recent URL specs -
cacheURL
Cache the URL of the specified file.- Parameters:
file
- the file whose URL is to be cached.
-
cacheURL
Cache the URL.- Parameters:
url
- the URL to cache.
-
cacheURL
Cache the URL- Parameters:
urlSpec
- the URL Spec to cache.
-
getRecentURLSpecs
Get the array of URLs corresponding to recently registered URLs. Fetch the recent items from the list saved in the user's preferences for the preference node.- Returns:
- The array of recent URLs.
-
getRecentFolder
Get the folder corresponding to the most recently cached URL.- Returns:
- the most recent folder accessed
-
getRecentFolderPath
Get the folder path corresponding to the most recently cached URL.- Returns:
- path to the most recent folder accessed or null if none has been accessed
-
getMostRecentFile
Get the most recent file- Returns:
- the most recently accessed file.
-
applyRecentFolder
Set the file chooser's current directory to the recent folder.- Parameters:
fileChooser
- the file chooser for which to set the current directory- Returns:
- the file chooser (same as the argument)
-
applyMostRecentFile
Set the file chooser's selected file to the most recent file.- Parameters:
fileChooser
- the file chooser for which to set the current directory- Returns:
- the file chooser (same as the argument)
-
getTokens
Parse a string into tokens where whitespace is the delimiter.- Parameters:
string
- The string to parse.- Returns:
- The array of tokens.
-
getTokens
Parse a string into tokens with the specified delimiter.- Parameters:
string
- The string to parse.delim
- The delimiter- Returns:
- The array of tokens.
-