Class AbstractFileChooser
java.lang.Object
org.openstreetmap.josm.gui.widgets.AbstractFileChooser
- Direct Known Subclasses:
NativeFileChooser,SwingFileChooser
Abstract class to allow different file chooser implementations.
- Since:
- 7578
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddChoosableFileFilter(FileFilter filter) Adds a filter to the list of user choosable file filters.abstract ActionMapGets the list of action names.abstract FileFilter[]Gets the list of user choosable file filters.abstract FileReturns the current directory.abstract FileFilterReturns the currently selected file filter.abstract FileReturns the selected file.abstract File[]Returns a list of selected files if the file chooser is set to allow multiple selection.abstract booleanReturns true if multiple files can be selected.abstract voidsetAcceptAllFileFilterUsed(boolean b) Determines whether theAcceptAll FileFilteris used as an available choice in the choosable filter list.abstract voidsetCurrentDirectory(File dir) Sets the current directory.static voidSets the default locale for all implementations.abstract voidsetDialogTitle(String title) Sets the string that goes in theJFileChooserwindow's title bar.abstract voidsetFileFilter(FileFilter filter) Sets the current file filter.abstract voidsetFileSelectionMode(int selectionMode) Sets theJFileChooserto allow the user to just select files, just select directories, or select both files and directories.abstract voidsetMultiSelectionEnabled(boolean multiple) Sets the file chooser to allow multiple file selections.abstract voidsetSelectedFile(File file) Sets the selected file.abstract intshowOpenDialog(Component parent) Pops up an "Open File" file chooser dialog.abstract intshowSaveDialog(Component parent) Pops up a "Save File" file chooser dialog.
-
Field Details
-
locale
The locale for both implementations
-
-
Constructor Details
-
AbstractFileChooser
public AbstractFileChooser()
-
-
Method Details
-
setDefaultLocale
Sets the default locale for all implementations.- Parameters:
l- locale
-
addChoosableFileFilter
Adds a filter to the list of user choosable file filters. For information on setting the file selection mode, seesetFileSelectionMode.- Parameters:
filter- theFileFilterto add to the choosable file filter list- See Also:
-
getChoosableFileFilters
Gets the list of user choosable file filters.- Returns:
- a
FileFilterarray containing all the choosable file filters - See Also:
-
getCurrentDirectory
Returns the current directory.- Returns:
- the current directory
- See Also:
-
getFileFilter
Returns the currently selected file filter.- Returns:
- the current file filter
- See Also:
-
getSelectedFile
Returns the selected file. This can be set either by the programmer viasetSelectedFileor by a user action, such as either typing the filename into the UI or selecting the file from a list in the UI.- Returns:
- the selected file
- See Also:
-
getSelectedFiles
Returns a list of selected files if the file chooser is set to allow multiple selection.- Returns:
- an array of selected files if the file chooser is set to allow multiple selection, or an empty array otherwise.
-
isMultiSelectionEnabled
Returns true if multiple files can be selected.- Returns:
- true if multiple files can be selected
- See Also:
-
setAcceptAllFileFilterUsed
Determines whether theAcceptAll FileFilteris used as an available choice in the choosable filter list. If false, theAcceptAllfile filter is removed from the list of available file filters. If true, theAcceptAllfile filter will become the actively used file filter.- Parameters:
b- whether theAcceptAll FileFilteris used as an available choice in the choosable filter list- See Also:
-
setCurrentDirectory
Sets the current directory. Passing innullsets the file chooser to point to the user's default directory. This default depends on the operating system. It is typically the "My Documents" folder on Windows, and the user's home directory on Unix. If the file passed in ascurrentDirectoryis not a directory, the parent of the file will be used as the currentDirectory. If the parent is not traversable, then it will walk up the parent tree until it finds a traversable directory, or hits the root of the file system.- Parameters:
dir- the current directory to point to- See Also:
-
setDialogTitle
Sets the string that goes in theJFileChooserwindow's title bar.- Parameters:
title- the newStringfor the title bar
-
setFileFilter
Sets the current file filter. The file filter is used by the file chooser to filter out files from the user's view.- Parameters:
filter- the new current file filter to use- See Also:
-
setFileSelectionMode
Sets theJFileChooserto allow the user to just select files, just select directories, or select both files and directories. The default isJFilesChooser.FILES_ONLY.- Parameters:
selectionMode- the type of files to be displayed:- JFileChooser.FILES_ONLY
- JFileChooser.DIRECTORIES_ONLY
- JFileChooser.FILES_AND_DIRECTORIES
- Throws:
IllegalArgumentException- ifmodeis an illegal file selection mode
-
setMultiSelectionEnabled
Sets the file chooser to allow multiple file selections.- Parameters:
multiple- true if multiple files may be selected- See Also:
-
setSelectedFile
Sets the selected file. If the file's parent directory is not the current directory, changes the current directory to be the file's parent directory.- Parameters:
file- the selected file- See Also:
-
showOpenDialog
Pops up an "Open File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F.- Parameters:
parent- the parent component of the dialog, can benull; seeshowDialogfor details- Returns:
- the return state of the file chooser on popdown:
- JFileChooser.CANCEL_OPTION
- JFileChooser.APPROVE_OPTION
- JFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
- Throws:
HeadlessException- if GraphicsEnvironment.isHeadless() returns true.- See Also:
-
showSaveDialog
Pops up a "Save File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F.- Parameters:
parent- the parent component of the dialog, can benull; seeshowDialogfor details- Returns:
- the return state of the file chooser on popdown:
- JFileChooser.CANCEL_OPTION
- JFileChooser.APPROVE_OPTION
- JFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
- Throws:
HeadlessException- if GraphicsEnvironment.isHeadless() returns true.- See Also:
-
getActionMap
Gets the list of action names.- Returns:
- a
ActionMaparray containing all the action names - Since:
- 18113
-