Package ca.spatial.util
Class SFileFetch
java.lang.Object
ca.spatial.util.SFileFetch
- All Implemented Interfaces:
ActionListener
,EventListener
This class encapsulates a JFileChooser with additional capabilities.
This object is used throughout the Patchworks system to select file
names.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
static int
static int
static int
-
Constructor Summary
ConstructorsConstructorDescriptionInsantiate the chooser with default optionsSFileFetch(String title)
Instantiate the choose with a specific title -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Add a filter for a given extentionvoid
Add a filter for a given extentionvoid
addFilter(FileFilter filter)
Add a filterdirnameOpen(Component parent)
Show the dialog for the DIR_OPEN operation and return the resultdirnameSave(Component parent)
Show the dialog for the DIR_SAVE operation and return the resultFile[]
dirnamesOpen(Component parent)
Show the dialog for the DIR_OPEN operation and return multiple resultsstatic String
escapeRegex(String glob)
This routine will escape special characters.Show the dialog for the default operation and return the resultfilenameOpen(Component parent)
Show the dialog for the FILE_OPEN operation and return the resultfilenameSave(Component parent)
Show the dialog for the FILE_SAVE operation and return the resultFile[]
filenamesOpen(Component parent)
Show the dialog for the FILE_OPEN operation and return multiple resultsReturn the current directory for this chooserstatic String[]
Get a list of files that match against a glob pattern.static String
globToRegex(String glob)
Convert a glob pattern to a regex pattern.loadLru()
Return the list of recently used foldersvoid
Reset the filter list to empty, accept allvoid
setCurrentDirectory(File dir)
Set the current directory for this chooservoid
setCurrentDirectory(String dirname)
Set the current directory for this chooservoid
setMatchingFilter(File file)
Set the first matching filter for the specifed filevoid
setOperation(int type)
Set the operation type for this chooser.void
setSelectedFile(File file)
Set the file that is selected this chooservoid
Set the title for the file chooserUpdate the list of recently used folders
-
Field Details
-
FILE_OPEN
public static final int FILE_OPEN- See Also:
- Constant Field Values
-
FILE_SAVE
public static final int FILE_SAVE- See Also:
- Constant Field Values
-
DIRECTORY_OPEN
public static final int DIRECTORY_OPEN- See Also:
- Constant Field Values
-
DIRECTORY_SAVE
public static final int DIRECTORY_SAVE- See Also:
- Constant Field Values
-
-
Constructor Details
-
SFileFetch
public SFileFetch()Insantiate the chooser with default options -
SFileFetch
Instantiate the choose with a specific title- Parameters:
title
- the title to use on eht file chooser dialog
-
-
Method Details
-
setTitle
Set the title for the file chooser- Parameters:
title
- the title to use on eht file chooser dialog
-
getCurrentDirectory
Return the current directory for this chooser -
setCurrentDirectory
Set the current directory for this chooser- Parameters:
dir
- the new current directory
-
setCurrentDirectory
Set the current directory for this chooser- Parameters:
dirname
- the new current directory
-
setSelectedFile
Set the file that is selected this chooser- Parameters:
file
- the selected file
-
setMatchingFilter
Set the first matching filter for the specifed file -
resetFilters
public void resetFilters()Reset the filter list to empty, accept all -
addFilter
Add a filter for a given extention- Parameters:
extention
- the file name extentiondescription
- what the extention means
-
addFilter
Add a filter for a given extention- Parameters:
extentions
- an array of file name extentionsdescription
- what the extentions mean
-
addFilter
Add a filter- Parameters:
filter
- the filter to add
-
setOperation
public void setOperation(int type)Set the operation type for this chooser. The operation type may be one of FILE_OPEN, FILE_SAVE, DIR_OPEN, DIR_SAVE- Parameters:
type
- one of FILE_OPEN, FILE_SAVE, DIR_OPEN, DIR_SAVE
-
filename
Show the dialog for the default operation and return the result- Parameters:
parent
- the parent component for the dialog
-
filenameOpen
Show the dialog for the FILE_OPEN operation and return the result- Parameters:
parent
- the parent component for the dialog
-
filenamesOpen
Show the dialog for the FILE_OPEN operation and return multiple results- Parameters:
parent
- the parent component for the dialog
-
filenameSave
Show the dialog for the FILE_SAVE operation and return the result- Parameters:
parent
- the parent component for the dialog
-
dirnameSave
Show the dialog for the DIR_SAVE operation and return the result- Parameters:
parent
- the parent component for the dialog
-
dirnameOpen
Show the dialog for the DIR_OPEN operation and return the result- Parameters:
parent
- the parent component for the dialog
-
dirnamesOpen
Show the dialog for the DIR_OPEN operation and return multiple results- Parameters:
parent
- the parent component for the dialog
-
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-
updateLru
Update the list of recently used folders -
loadLru
Return the list of recently used folders -
glob
Get a list of files that match against a glob pattern. Glob patterns use simple wildcards:- An asterisk ('*') represents any wildcard sequence
- A question mark ('?') represents a single wildcard character
- A sequence inside brackets ('[' and ']') will match a single matchiing character (e.g. [abc] will match to either a, b, or c.
- Parameters:
dir
- The directory containing the files to comparepattern
- The wildcard pattern- Returns:
- An array of matching filenames.
-
globToRegex
Convert a glob pattern to a regex pattern. This routine will escape special characters, and transform '*' and '?' to wildcard strings and characters. -
escapeRegex
This routine will escape special characters.
-