Class FileChooserUtil
java.lang.Object
com.compomics.util.gui.file_handling.FileChooserUtil
public class FileChooserUtil extends Object
This class contains utilities functions for the file choosers.
- Author:
- Marc Vaudel, Harald Barsnes
-
Constructor Summary
Constructors Constructor Description FileChooserUtil()
-
Method Summary
Modifier and Type Method Description static FileAndFileFilter
getUserSelectedFile(Component parent, String[] fileEndings, String[] fileFormatDescriptions, String aDialogTitle, String lastSelectedFolder, String aSuggestedFileName, boolean openDialog, boolean formatSelectedByUser, boolean showAllFilesOption, int defaultFilterIndex)
Returns the file selected by the user, or null if no file was selected.static File
getUserSelectedFile(Component parent, String aFileEnding, String aFileFormatDescription, String aDialogTitle, String lastSelectedFolder, String aSuggestedFileName, boolean openDialog)
Returns the file selected by the user, or null if no file was selected.static File
getUserSelectedFolder(Component parent, String aDialogTitle, String lastSelectedFolder, String aFolderDescription, String approveButtonText, boolean openDialog)
Returns the folder selected by the user, or null if no folder was selected.
-
Constructor Details
-
FileChooserUtil
public FileChooserUtil()
-
-
Method Details
-
getUserSelectedFile
public static File getUserSelectedFile(Component parent, String aFileEnding, String aFileFormatDescription, String aDialogTitle, String lastSelectedFolder, String aSuggestedFileName, boolean openDialog)Returns the file selected by the user, or null if no file was selected. Note that the last selected folder value is not updated during this method, and the code calling this method therefore has to take care of this if wanted.- Parameters:
parent
- the parent dialog or frameaFileEnding
- the file type, e.g., .txtaFileFormatDescription
- the file format description, e.g., (Mascot Generic Format) *.mgfaDialogTitle
- the title for the dialoglastSelectedFolder
- the last selected folderaSuggestedFileName
- the suggested file name, can be nullopenDialog
- if true an open dialog is shown, false results in a save dialog- Returns:
- the file selected by the user, or null if no file was selected
-
getUserSelectedFile
public static FileAndFileFilter getUserSelectedFile(Component parent, String[] fileEndings, String[] fileFormatDescriptions, String aDialogTitle, String lastSelectedFolder, String aSuggestedFileName, boolean openDialog, boolean formatSelectedByUser, boolean showAllFilesOption, int defaultFilterIndex)Returns the file selected by the user, or null if no file was selected. Note that the last selected folder value is not updated during this method, and the code calling this method therefore has to take care of this if wanted.- Parameters:
parent
- the parent dialog or framefileEndings
- the file types, e.g., .txtfileFormatDescriptions
- the file format description, e.g., (Mascot Generic Format) *.mgfaDialogTitle
- the title for the dialoglastSelectedFolder
- the last selected folderaSuggestedFileName
- the suggested file name, can be nullopenDialog
- if true an open dialog is shown, false results in a save dialogformatSelectedByUser
- if true the user will have to select the format by himself, otherwise all formats will be availableshowAllFilesOption
- if true, the 'All files' filter option will be includeddefaultFilterIndex
- the index of the filter selected by default- Returns:
- the file selected and the file filter used, null if the selection was canceled.
-
getUserSelectedFolder
public static File getUserSelectedFolder(Component parent, String aDialogTitle, String lastSelectedFolder, String aFolderDescription, String approveButtonText, boolean openDialog)Returns the folder selected by the user, or null if no folder was selected. Note that the last selected folder value is not updated during this method, and the code calling this method therefore has to take care of this if wanted.- Parameters:
parent
- the parent dialog or frameaDialogTitle
- the title for the dialoglastSelectedFolder
- the last selected folderaFolderDescription
- the folder description, e.g., PSDB FolderapproveButtonText
- the text on the approve buttonopenDialog
- if true the folder has to exist, if false the user will be asked if he/she wants to create the folder is missing- Returns:
- the file selected by the user, or null if no file was selected
-