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 classAFileFilterextension that allows specifiying an extension and description.static classHave our own class here so it can put the hook in to fix the lock up problem on windows.static classAFileFilterextension for netCDF files. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternFileFilterFilter for QuickTime filesstatic final PatternFileFilterFilter for QuickTime filesstatic final PatternFileFilterFilter for CSV filesstatic final PatternFileFilterFilter for Image filesstatic final PatternFileFilterFilter for image or pdf filesstatic final PatternFileFilterFilter for Image files for writingstatic final PatternFileFilterFile filter used for bundle filesstatic final PatternFileFilterFilter for JPEG filesstatic final PatternFileFilterFilter for xls filesstatic final PatternFileFilterFilter for kmz filesstatic final PatternFileFilterFilter for log filesstatic final PatternFileFilterFilter for QuickTime filesstatic final PatternFileFilterFile filter for MPEG-4 files.static final PatternFileFilterFilter for netCDF filesstatic final PatternFileFilterstatic final PatternFileFilterFilter for Text filesstatic final PatternFileFilterFilter for xls filesstatic final PatternFileFilterFilter for XML filesstatic final PatternFileFilterFilter for ZIP filesstatic final Stringnull button text intrinsicstatic final Stringnull string intrinsicstatic final Stringnull title intrinsicstatic final StringProperty in the store for the history liststatic final StringProperty in the store for the last dirstatic final String_more_static final StringSuffix for CSV filesstatic final StringSuffix for GIF filesstatic final StringSuffix for JAR filesstatic final StringSuffix for JPEG filesstatic final StringSuffix for CSV filesstatic final StringSuffix for CSV filesstatic final StringSuffix for log filesstatic final StringSuffix for Quicktime filesstatic final StringSuffix for MPEG-4 files.static final StringSuffix for netCDF filesstatic final StringSuffix for PNG filesstatic final StringSuffix for JAR filesstatic final StringSuffix for CSV filesstatic final StringSuffix for CSV filesstatic final StringSuffix for XML filesstatic final StringSuffix for JAR files -
Constructor Summary
ConstructorsConstructorDescriptionFileManager(Component parent) Create a FileManager and useparentas 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 voidaddToHistory(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 thisFileManagerwraps.static FilegetDirectory(String dfltDir) Return a directory selection.static FilegetDirectory(String dfltDir, String title) Have the user select a directorystatic FilegetDirectory(String dfltDir, String title, JComponent accessory) _more_Get the current directory name.static StringgetFile(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 StringgetFile(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 ListGet the history list.static ListgetHistoryList(ActionListener listener) Get the history list.static StringGet the file that this FileManager will read from using the defaults.static StringgetReadFile(String title, List filters) Get the file that this FileManager will read from using the specified parameters to configure the widget.static StringgetReadFile(String title, List filters, JComponent accessory) Get the file that this FileManager will read from using the specified parameters to configure the widget.static StringgetReadFile(String title, FileFilter filter) Get the file that this FileManager will read from using the specified parameters to configure the widget.static StringgetReadFile(FileFilter filter) Get the file that this FileManager will read from using the specified parameters to configure the widget.static StringgetReadFile(FileFilter filter, boolean includeAllFilter) Get the file that this FileManager will read from using the specified parameters to configure the widget.static StringgetReadFileOrURL(String title, List filters, JComponent accessory) Get the file that this FileManager will read from using the specified parameters to configure the widget.static StringGet the file that this FileManager will write to using the defaults.static StringgetWriteFile(String filename) Get the file that this FileManager will write to using the defaults.static StringgetWriteFile(String title, List filters, String suffix) Get the file that this FileManager will write to using the specified parameters.static StringgetWriteFile(String title, FileFilter filter, String suffix) Get the file that this FileManager will write to using the specified parameters.static StringgetWriteFile(List filters, String suffix) Get the file that this FileManager will write to using the specified parameters.static StringgetWriteFile(List filters, String suffix, JComponent accessory) Get the file that this FileManager will write to using the specified parameters.static StringgetWriteFile(FileFilter filter, String suffix) Get the file that this FileManager will write to using the specified parameters.static StringgetWriteFile(FileFilter filter, String suffix, JComponent accessory) Get the file that this FileManager will write to using the specified parameters.static JComponentmakeDirectoryHistoryComponent(JFileChooser fileChooser, boolean includeLabel) Create the directory history button and menuvoidsetAccessory(JComponent comp) Set the accessory for the file chooser tocomp.voidsetApproveButtonText(String approveButtonText) Set the approve button text for the chooser.static voidsetFileHidingEnabled(boolean value) _more_static voidsetFixFileLockup(boolean b) Do we set the FileChooser.useShellFolder=false This fixes the occasional problemo of a system lockup running under windowsvoidsetSelectedFile(String file) Set the selected file for the chooser.static voidsetStore(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 useparentas 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- defaultFileFiltertitle- 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-Listof 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-Listof 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-Listof defaultFileFilter'stitle- title for the dialog windowincludeAllFilter- true to include the "All files" filter.
-
-
Method Details
-
getChooser
Get the chooser that thisFileManagerwraps.- 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-Listof 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-Listof 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-Listof 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-Listof 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-Listof 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-Listof 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-Listof 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
-