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 Details

  • 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 frame
      aFileEnding - the file type, e.g., .txt
      aFileFormatDescription - the file format description, e.g., (Mascot Generic Format) *.mgf
      aDialogTitle - the title for the dialog
      lastSelectedFolder - the last selected folder
      aSuggestedFileName - the suggested file name, can be null
      openDialog - 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 frame
      fileEndings - the file types, e.g., .txt
      fileFormatDescriptions - the file format description, e.g., (Mascot Generic Format) *.mgf
      aDialogTitle - the title for the dialog
      lastSelectedFolder - the last selected folder
      aSuggestedFileName - the suggested file name, can be null
      openDialog - if true an open dialog is shown, false results in a save dialog
      formatSelectedByUser - if true the user will have to select the format by himself, otherwise all formats will be available
      showAllFilesOption - if true, the 'All files' filter option will be included
      defaultFilterIndex - 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 frame
      aDialogTitle - the title for the dialog
      lastSelectedFolder - the last selected folder
      aFolderDescription - the folder description, e.g., PSDB Folder
      approveButtonText - the text on the approve button
      openDialog - 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