Package ucar.unidata.util
Class FileManager
java.lang.Object
ucar.unidata.util.FileManager
- Direct Known Subclasses:
FileManager
Wrapper cover for JFileChooser.
- Version:
- $Id: FileManager.java,v 1.22 2007/08/13 18:38:39 jeffmc Exp $
- Author:
- Unidata development staff
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
AFileFilter
extension that allows specifiying an extension and description.static class
Have our own class here so it can put the hook in to fix the lock up problem on windows.static class
AFileFilter
extension for netCDF files. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternFileFilter
Filter for QuickTime filesstatic final PatternFileFilter
Filter for QuickTime filesstatic final PatternFileFilter
Filter for CSV filesstatic final PatternFileFilter
Filter for Image filesstatic final PatternFileFilter
Filter for image or pdf filesstatic final PatternFileFilter
Filter for Image files for writingstatic final PatternFileFilter
File filter used for bundle filesstatic final PatternFileFilter
Filter for JPEG filesstatic final PatternFileFilter
Filter for xls filesstatic final PatternFileFilter
Filter for kmz filesstatic final PatternFileFilter
Filter for log filesstatic final PatternFileFilter
Filter for QuickTime filesstatic final PatternFileFilter
File filter for MPEG-4 files.static final PatternFileFilter
Filter for netCDF filesstatic final PatternFileFilter
static final PatternFileFilter
Filter for Text filesstatic final PatternFileFilter
Filter for xls filesstatic final PatternFileFilter
Filter for XML filesstatic final PatternFileFilter
Filter for ZIP filesstatic final String
null button text intrinsicstatic final String
null string intrinsicstatic final String
null title intrinsicstatic final String
Property in the store for the history liststatic final String
Property in the store for the last dirstatic final String
_more_static final String
Suffix for CSV filesstatic final String
Suffix for GIF filesstatic final String
Suffix for JAR filesstatic final String
Suffix for JPEG filesstatic final String
Suffix for CSV filesstatic final String
Suffix for CSV filesstatic final String
Suffix for log filesstatic final String
Suffix for Quicktime filesstatic final String
Suffix for MPEG-4 files.static final String
Suffix for netCDF filesstatic final String
Suffix for PNG filesstatic final String
Suffix for JAR filesstatic final String
Suffix for CSV filesstatic final String
Suffix for CSV filesstatic final String
Suffix for XML filesstatic final String
Suffix for JAR files -
Constructor Summary
ConstructorsConstructorDescriptionFileManager
(Component parent) Create a FileManager and useparent
as the parent for the dialog.FileManager
(Component parent, String defDir, String file_extension, String desc) Create a FileManager and use the specified params to configure its behavior.FileManager
(Component parent, String defDir, List filters) Create a FileManager and use the specified params to configure its behavior.FileManager
(Component parent, String defDir, List filters, String title) Create a FileManager and use the specified params to configure its behavior.FileManager
(Component parent, String defDir, List filters, String title, boolean includeAllFilter) Create a FileManager and use the specified params to configure its behavior.FileManager
(Component parent, String defDir, FileFilter filter) Create a FileManager and use the specified params to configure its behavior.FileManager
(Component parent, String defDir, FileFilter filter, String title) Create a FileManager and use the specified params to configure its behavior. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addToHistory
(File file) Add the file (or its parent directory if it is not a directory) to the history list.Choose a filename.chooseFilename
(String title) Choose a filename and set the title in the dialog.chooseFilename
(String title, String approveButtonText) Choose a filename, set the title in the dialog, and set the text of the approve button on the chooser.chooseFilename
(String title, String approveButtonText, boolean includeUrl) Choose a filename, set the title in the dialog, and set the text of the approve button on the chooser.Get the chooser that thisFileManager
wraps.static File
getDirectory
(String dfltDir) Return a directory selection.static File
getDirectory
(String dfltDir, String title) Have the user select a directorystatic File
getDirectory
(String dfltDir, String title, JComponent accessory) _more_Get the current directory name.static String
getFile
(boolean forWrite, String title, String buttonText, String property, List filters, String suffix, boolean includeAllFilter, JComponent accessory, boolean includeUrl) Get the file that this FileManager is pointing to.static String
getFile
(boolean forWrite, String title, String buttonText, String property, List filters, String suffix, boolean includeAllFilter, JComponent accessory, boolean includeUrl, String dfltFile) Get the file that this FileManager is pointing to.static boolean
_more_static List
Get the history list.static List
getHistoryList
(ActionListener listener) Get the history list.static String
Get the file that this FileManager will read from using the defaults.static String
getReadFile
(String title, List filters) Get the file that this FileManager will read from using the specified parameters to configure the widget.static String
getReadFile
(String title, List filters, JComponent accessory) Get the file that this FileManager will read from using the specified parameters to configure the widget.static String
getReadFile
(String title, FileFilter filter) Get the file that this FileManager will read from using the specified parameters to configure the widget.static String
getReadFile
(FileFilter filter) Get the file that this FileManager will read from using the specified parameters to configure the widget.static String
getReadFile
(FileFilter filter, boolean includeAllFilter) Get the file that this FileManager will read from using the specified parameters to configure the widget.static String
getReadFileOrURL
(String title, List filters, JComponent accessory) Get the file that this FileManager will read from using the specified parameters to configure the widget.static String
Get the file that this FileManager will write to using the defaults.static String
getWriteFile
(String filename) Get the file that this FileManager will write to using the defaults.static String
getWriteFile
(String title, List filters, String suffix) Get the file that this FileManager will write to using the specified parameters.static String
getWriteFile
(String title, FileFilter filter, String suffix) Get the file that this FileManager will write to using the specified parameters.static String
getWriteFile
(List filters, String suffix) Get the file that this FileManager will write to using the specified parameters.static String
getWriteFile
(List filters, String suffix, JComponent accessory) Get the file that this FileManager will write to using the specified parameters.static String
getWriteFile
(FileFilter filter, String suffix) Get the file that this FileManager will write to using the specified parameters.static String
getWriteFile
(FileFilter filter, String suffix, JComponent accessory) Get the file that this FileManager will write to using the specified parameters.static JComponent
makeDirectoryHistoryComponent
(JFileChooser fileChooser, boolean includeLabel) Create the directory history button and menuvoid
setAccessory
(JComponent comp) Set the accessory for the file chooser tocomp
.void
setApproveButtonText
(String approveButtonText) Set the approve button text for the chooser.static void
setFileHidingEnabled
(boolean value) _more_static void
setFixFileLockup
(boolean b) Do we set the FileChooser.useShellFolder=false This fixes the occasional problemo of a system lockup running under windowsvoid
setSelectedFile
(String file) Set the selected file for the chooser.static void
setStore
(PersistentStore store, String writeProperty, String readProperty) Set the persistent store for this FileManager.
-
Field Details
-
PROP_DIR_HISTORY
Property in the store for the history list- See Also:
-
PROP_DIRECTORY
Property in the store for the last dir- See Also:
-
SUFFIX_XML
Suffix for XML files- See Also:
-
SUFFIX_AVI
_more_- See Also:
-
SUFFIX_CSV
Suffix for CSV files- See Also:
-
SUFFIX_XLS
Suffix for CSV files- See Also:
-
SUFFIX_KML
Suffix for CSV files- See Also:
-
SUFFIX_KMZ
Suffix for CSV files- See Also:
-
SUFFIX_JPG
Suffix for JPEG files- See Also:
-
SUFFIX_PNG
Suffix for PNG files- See Also:
-
SUFFIX_GIF
Suffix for GIF files- See Also:
-
SUFFIX_MOV
Suffix for Quicktime files- See Also:
-
SUFFIX_MP4
Suffix for MPEG-4 files.- See Also:
-
SUFFIX_TXT
Suffix for CSV files- See Also:
-
SUFFIX_LOG
Suffix for log files- See Also:
-
SUFFIX_NETCDF
Suffix for netCDF files- See Also:
-
SUFFIX_JAR
Suffix for JAR files- See Also:
-
SUFFIX_ZIP
Suffix for JAR files- See Also:
-
SUFFIX_SHP
Suffix for JAR files- See Also:
-
FILTER_XML
Filter for XML files -
FILTER_NETCDF
Filter for netCDF files -
FILTER_CSV
Filter for CSV files -
FILTER_TXT
Filter for Text files -
FILTER_XLS
Filter for xls files -
FILTER_KML
Filter for xls files -
FILTER_JAR
File filter used for bundle files -
FILTER_JPG
Filter for JPEG files -
FILTER_IMAGE
Filter for Image files -
FILTER_IMAGEWRITE
Filter for Image files for writing -
FILTER_IMAGE_OR_PDF
Filter for image or pdf files -
FILTER_MOV
Filter for QuickTime files -
FILTER_AVI
Filter for QuickTime files -
FILTER_ANIMATEDGIF
Filter for QuickTime files -
FILTER_MP4
File filter for MPEG-4 files. -
FILTER_SHP
-
FILTER_ZIP
Filter for ZIP files -
FILTER_LOG
Filter for log files -
FILTER_KMZ
Filter for kmz files -
NULL_STRING
null string intrinsic -
NULL_BTNTEXT
null button text intrinsic -
NULL_TITLE
null title intrinsic
-
-
Constructor Details
-
FileManager
Create a FileManager and useparent
as the parent for the dialog.- Parameters:
parent
- parent component for the dialog.
-
FileManager
Create a FileManager and use the specified params to configure its behavior.- Parameters:
parent
- parent component for the dialog.defDir
- default directory to open upfile_extension
- file_extention to use for a filterdesc
- description of files of typefile_extension
-
FileManager
Create a FileManager and use the specified params to configure its behavior.- Parameters:
parent
- parent component for the dialog.defDir
- default directory to open upfilter
- defaultFileFilter
-
FileManager
Create a FileManager and use the specified params to configure its behavior.- Parameters:
parent
- parent component for the dialog.defDir
- default directory to open upfilter
- defaultFileFilter
title
- title for the dialog window
-
FileManager
Create a FileManager and use the specified params to configure its behavior.- Parameters:
parent
- parent component for the dialog.defDir
- default directory to open upfilters
-List
of defaultFileFilter
's
-
FileManager
Create a FileManager and use the specified params to configure its behavior.- Parameters:
parent
- parent component for the dialog.defDir
- default directory to open upfilters
-List
of defaultFileFilter
'stitle
- title for the dialog window
-
FileManager
public FileManager(Component parent, String defDir, List filters, String title, boolean includeAllFilter) Create a FileManager and use the specified params to configure its behavior.- Parameters:
parent
- parent component for the dialog.defDir
- default directory to open upfilters
-List
of defaultFileFilter
'stitle
- title for the dialog windowincludeAllFilter
- true to include the "All files" filter.
-
-
Method Details
-
getChooser
Get the chooser that thisFileManager
wraps.- Returns:
- the chooser
-
setFixFileLockup
public static void setFixFileLockup(boolean b) Do we set the FileChooser.useShellFolder=false This fixes the occasional problemo of a system lockup running under windows- Parameters:
b
- value
-
getFileHidingEnabled
public static boolean getFileHidingEnabled()_more_- Returns:
- _more_
-
setFileHidingEnabled
public static void setFileHidingEnabled(boolean value) _more_- Parameters:
value
- _more_
-
setSelectedFile
Set the selected file for the chooser.- Parameters:
file
- name of the file
-
chooseFilename
Choose a filename.- Returns:
- name of the file.
-
chooseFilename
Choose a filename and set the title in the dialog.- Parameters:
title
- for dialog- Returns:
- name of the file.
-
chooseFilename
Choose a filename, set the title in the dialog, and set the text of the approve button on the chooser.- Parameters:
title
- title for the dialog windowapproveButtonText
- text for the approve button in the dialog- Returns:
- name of the file.
-
chooseFilename
Choose a filename, set the title in the dialog, and set the text of the approve button on the chooser.- Parameters:
title
- title for the dialog windowapproveButtonText
- text for the approve button in the dialogincludeUrl
- inclues a URL- Returns:
- name of the file.
-
getHistoryList
Get the history list. Add the listener to the list of listeners.- Parameters:
listener
- Listener to notify- Returns:
- List of (String) directories from the user's past use
-
getHistoryList
Get the history list.- Returns:
- List of (String) directories from the user's past use
-
addToHistory
Add the file (or its parent directory if it is not a directory) to the history list.- Parameters:
file
- File to add
-
setAccessory
Set the accessory for the file chooser tocomp
.- Parameters:
comp
- component to use for the accessory.
-
getDirectoryName
Get the current directory name.- Returns:
- name of the current directory.
-
setApproveButtonText
Set the approve button text for the chooser.- Parameters:
approveButtonText
- text for the button.
-
setStore
Set the persistent store for this FileManager.- Parameters:
store
- store for persistencewriteProperty
- write propertyreadProperty
- read property
-
getDirectory
Return a directory selection.- Parameters:
dfltDir
-- Returns:
- A directory or nulll if none selected.
-
getDirectory
Have the user select a directory- Parameters:
dfltDir
- Default dirtitle
- Window title- Returns:
- The selected directory or null if none selected
-
getDirectory
_more_- Parameters:
dfltDir
- _more_title
- _more_accessory
- _more_- Returns:
- _more_
-
getWriteFile
Get the file that this FileManager will write to using the defaults.- Parameters:
filename
- default file name- Returns:
- the requested file name
-
getWriteFile
Get the file that this FileManager will write to using the defaults.- Returns:
- name of the file
-
getWriteFile
Get the file that this FileManager will write to using the specified parameters.- Parameters:
filters
-List
of file filterssuffix
- default suffix- Returns:
- name of the file
-
getWriteFile
Get the file that this FileManager will write to using the specified parameters.- Parameters:
filter
- file filtersuffix
- default suffix- Returns:
- name of the file
-
getWriteFile
Get the file that this FileManager will write to using the specified parameters.- Parameters:
filter
- file filtersuffix
- default suffixaccessory
- accessory component- Returns:
- name of the file
-
getWriteFile
Get the file that this FileManager will write to using the specified parameters.- Parameters:
filters
- file filterssuffix
- default suffixaccessory
- accessory component- Returns:
- name of the file
-
getWriteFile
Get the file that this FileManager will write to using the specified parameters.- Parameters:
title
- title for the dialog.filter
- file filtersuffix
- default suffix- Returns:
- name of the file
-
getWriteFile
Get the file that this FileManager will write to using the specified parameters.- Parameters:
title
- title for the dialog.filters
-List
of file filterssuffix
- default suffix- Returns:
- name of the file
-
getReadFile
Get the file that this FileManager will read from using the defaults.- Returns:
- name of the file
-
getReadFile
Get the file that this FileManager will read from using the specified parameters to configure the widget.- Parameters:
filter
- filter to use- Returns:
- name of the file
-
getReadFile
Get the file that this FileManager will read from using the specified parameters to configure the widget.- Parameters:
filter
- filter to useincludeAllFilter
- true to include the "All files (*.*)" filter- Returns:
- name of the file
-
getReadFile
Get the file that this FileManager will read from using the specified parameters to configure the widget.- Parameters:
title
- title for the dialogfilter
- filter to use- Returns:
- name of the file
-
getReadFile
Get the file that this FileManager will read from using the specified parameters to configure the widget.- Parameters:
title
- title for the dialogfilters
-List
of filters to use- Returns:
- name of the file
-
getReadFile
Get the file that this FileManager will read from using the specified parameters to configure the widget.- Parameters:
title
- title for the dialogfilters
-List
of filters to useaccessory
- accessory for the chooser (may be null)- Returns:
- name of the file
-
getReadFileOrURL
Get the file that this FileManager will read from using the specified parameters to configure the widget.- Parameters:
title
- title for the dialogfilters
-List
of filters to useaccessory
- accessory for the chooser (may be null)- Returns:
- name of the file
-
getFile
public static String getFile(boolean forWrite, String title, String buttonText, String property, List filters, String suffix, boolean includeAllFilter, JComponent accessory, boolean includeUrl) Get the file that this FileManager is pointing to.- Parameters:
forWrite
- true if this is for getting a file to write totitle
- title for the dialogbuttonText
- text for the approve buttonproperty
- property for the storefilters
-List
of filters to usesuffix
- default suffix for file to writeincludeAllFilter
- true to include the "All files (*.*)" filteraccessory
- accessory for the chooserincludeUrl
- allow a URL- Returns:
- name of the file
-
getFile
public static String getFile(boolean forWrite, String title, String buttonText, String property, List filters, String suffix, boolean includeAllFilter, JComponent accessory, boolean includeUrl, String dfltFile) Get the file that this FileManager is pointing to.- Parameters:
forWrite
- true if this is for getting a file to write totitle
- title for the dialogbuttonText
- text for the approve buttonproperty
- property for the storefilters
-List
of filters to usesuffix
- default suffix for file to writeincludeAllFilter
- true to include the "All files (*.*)" filteraccessory
- accessory for the chooserincludeUrl
- allow a URLdfltFile
- the default file- Returns:
- name of the file
-
makeDirectoryHistoryComponent
public static JComponent makeDirectoryHistoryComponent(JFileChooser fileChooser, boolean includeLabel) Create the directory history button and menu- Parameters:
fileChooser
- The chooser to set the dir onincludeLabel
- Should the label be included in the component.- Returns:
- The jbutton and label that pops up the directory history list
-