com.limegroup.gnutella.gui
Class FileChooserHandler

java.lang.Object
  extended bycom.limegroup.gnutella.gui.FileChooserHandler

public final class FileChooserHandler
extends java.lang.Object

This is a utility class that displays a file chooser dialog to the user, automatically selecting the appropriate dialog based on the operating system, the current theme, etc. For example, if the user is on OS X and is not using the default theme, this displays the standard MetalLookAndFeel file chooser, as that is the only one that will appear with themes.


Constructor Summary
FileChooserHandler()
           
 
Method Summary
static java.io.File getInput(java.awt.Component parent, java.lang.String titleKey, java.lang.String approveKey, java.io.File directory, int mode, int option)
          The implementation that the other methods delegate to.
static java.io.File getInput(java.awt.Component parent, java.lang.String titleKey, java.lang.String approveKey, java.io.File directory, int mode, int option, javax.swing.filechooser.FileFilter filter)
          The implementation that the other methods delegate to.
static java.io.File getInputDirectory()
          Displays a directory chooser to the user and returns the selected File.
static java.io.File getInputDirectory(java.awt.Component parent)
          Same as getInputDirectory that takes no arguments, except this allows the caller to specify the parent component of the chooser.
static java.io.File getInputDirectory(java.awt.Component parent, java.io.File directory)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.
static java.io.File getInputDirectory(java.awt.Component parent, java.io.File directory, javax.swing.filechooser.FileFilter filter)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.
static java.io.File getInputDirectory(java.awt.Component parent, java.lang.String titleKey, java.io.File directory)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.
static java.io.File getInputDirectory(java.awt.Component parent, java.lang.String titleKey, java.io.File directory, javax.swing.filechooser.FileFilter filter)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.
static java.io.File getInputDirectory(java.awt.Component parent, java.lang.String titleKey, java.lang.String approveKey, java.io.File directory)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.
static java.io.File getInputDirectory(java.awt.Component parent, java.lang.String titleKey, java.lang.String approveKey, java.io.File directory, javax.swing.filechooser.FileFilter filter)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.
static java.io.File getInputFile()
          Displays a file chooser to the user and returns the selected File.
static java.io.File getInputFile(java.awt.Component parent)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.
static java.io.File getInputFile(java.awt.Component parent, javax.swing.filechooser.FileFilter filter)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.
static java.io.File getInputFile(java.awt.Component parent, java.lang.String titleKey, java.io.File directory)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.
static java.io.File getInputFile(java.awt.Component parent, java.lang.String titleKey, java.io.File directory, javax.swing.filechooser.FileFilter filter)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.
static java.io.File getInputFile(java.awt.Component parent, java.lang.String titleKey, java.lang.String approveKey, java.io.File directory)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.
static java.io.File getInputFile(java.awt.Component parent, java.lang.String titleKey, java.lang.String approveKey, java.io.File directory, javax.swing.filechooser.FileFilter filter)
          Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileChooserHandler

public FileChooserHandler()
Method Detail

getInputDirectory

public static java.io.File getInputDirectory()
Displays a directory chooser to the user and returns the selected File. This uses the main application frame as the parent component.

Returns:
the selected File instance, or null if a directory was not selected correctly

getInputDirectory

public static java.io.File getInputDirectory(java.awt.Component parent)
Same as getInputDirectory that takes no arguments, except this allows the caller to specify the parent component of the chooser.

Parameters:
parent - the Component that should be the dialog's parent
Returns:
the selected File instance, or null if a file was not selected correctly

getInputDirectory

public static java.io.File getInputDirectory(java.awt.Component parent,
                                             java.io.File directory)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.

Parameters:
parent - the Component that should be the dialog's parent
directory - the directory to open the dialog to
Returns:
the selected File instance, or null if a file was not selected correctly

getInputDirectory

public static java.io.File getInputDirectory(java.awt.Component parent,
                                             java.io.File directory,
                                             javax.swing.filechooser.FileFilter filter)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.

Parameters:
parent - the Component that should be the dialog's parent
directory - the directory to open the dialog to
filter - the FileFilter instance for customizing the files that are displayed -- if this is null, no filter is used
Returns:
the selected File instance, or null if a file was not selected correctly

getInputDirectory

public static java.io.File getInputDirectory(java.awt.Component parent,
                                             java.lang.String titleKey,
                                             java.io.File directory)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
directory - the directory to open the dialog to
Returns:
the selected File instance, or null if a file was not selected correctly

getInputDirectory

public static java.io.File getInputDirectory(java.awt.Component parent,
                                             java.lang.String titleKey,
                                             java.io.File directory,
                                             javax.swing.filechooser.FileFilter filter)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
directory - the directory to open the dialog to
filter - the FileFilter instance for customizing the files that are displayed -- if this is null, no filter is used
Returns:
the selected File instance, or null if a file was not selected correctly

getInputDirectory

public static java.io.File getInputDirectory(java.awt.Component parent,
                                             java.lang.String titleKey,
                                             java.lang.String approveKey,
                                             java.io.File directory)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
approveKey - the key for the locale-specific string to use for the approve button text
directory - the directory to open the dialog to
Returns:
the selected File instance, or null if a file was not selected correctly

getInputDirectory

public static java.io.File getInputDirectory(java.awt.Component parent,
                                             java.lang.String titleKey,
                                             java.lang.String approveKey,
                                             java.io.File directory,
                                             javax.swing.filechooser.FileFilter filter)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser as well as other options.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
approveKey - the key for the locale-specific string to use for the approve button text
directory - the directory to open the dialog to
filter - the FileFilter instance for customizing the files that are displayed -- if this is null, no filter is used
Returns:
the selected File instance, or null if a file was not selected correctly

getInputFile

public static java.io.File getInputFile()
Displays a file chooser to the user and returns the selected File. This uses the main application frame as the parent component.

Returns:
the selected File instance, or null if a file was not selected correctly

getInputFile

public static java.io.File getInputFile(java.awt.Component parent)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.

Parameters:
parent - the Component that should be the dialog's parent
Returns:
the selected File instance, or null if a file was not selected correctly

getInputFile

public static java.io.File getInputFile(java.awt.Component parent,
                                        javax.swing.filechooser.FileFilter filter)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.

Parameters:
parent - the Component that should be the dialog's parent
filter - the FileFilter instance for customizing the files that are displayed -- if this is null, no filter is used
Returns:
the selected File instance, or null if a file was not selected correctly

getInputFile

public static java.io.File getInputFile(java.awt.Component parent,
                                        java.lang.String titleKey,
                                        java.io.File directory)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
directory - the directory to open the dialog to
Returns:
the selected File instance, or null if a file was not selected correctly

getInputFile

public static java.io.File getInputFile(java.awt.Component parent,
                                        java.lang.String titleKey,
                                        java.io.File directory,
                                        javax.swing.filechooser.FileFilter filter)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
directory - the directory to open the dialog to
filter - the FileFilter instance for customizing the files that are displayed -- if this is null, no filter is used
Returns:
the selected File instance, or null if a file was not selected correctly

getInputFile

public static java.io.File getInputFile(java.awt.Component parent,
                                        java.lang.String titleKey,
                                        java.lang.String approveKey,
                                        java.io.File directory)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
approveKey - the key for the locale-specific string to use for the approve button text
directory - the directory to open the dialog to
Returns:
the selected File instance, or null if a file was not selected correctly

getInputFile

public static java.io.File getInputFile(java.awt.Component parent,
                                        java.lang.String titleKey,
                                        java.lang.String approveKey,
                                        java.io.File directory,
                                        javax.swing.filechooser.FileFilter filter)
Same as getInputFile that takes no arguments, except this allows the caller to specify the parent component of the chooser.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
approveKey - the key for the locale-specific string to use for the approve button text
directory - the directory to open the dialog to
filter - the FileFilter instance for customizing the files that are displayed -- if this is null, no filter is used
Returns:
the selected File instance, or null if a file was not selected correctly

getInput

public static java.io.File getInput(java.awt.Component parent,
                                    java.lang.String titleKey,
                                    java.lang.String approveKey,
                                    java.io.File directory,
                                    int mode,
                                    int option)
The implementation that the other methods delegate to. This provides the caller with all available options for customizing the JFileChooser instance. If a FileDialog is displayed instead of a JFileChooser (on OS X, for example), most or all of these options have no effect.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
approveKey - the key for the locale-specific string to use for the approve button text
directory - the directory to open the dialog to
mode - the "mode" to open the JFileChooser in from the JFileChooser class, such as JFileChooser.DIRECTORIES_ONLY
option - the option to look for in the return code, such as JFileChooser.APPROVE_OPTION
Returns:
the selected File instance, or null if a file was not selected correctly

getInput

public static java.io.File getInput(java.awt.Component parent,
                                    java.lang.String titleKey,
                                    java.lang.String approveKey,
                                    java.io.File directory,
                                    int mode,
                                    int option,
                                    javax.swing.filechooser.FileFilter filter)
The implementation that the other methods delegate to. This provides the caller with all available options for customizing the JFileChooser instance. If a FileDialog is displayed instead of a JFileChooser (on OS X, for example), most or all of these options have no effect.

Parameters:
parent - the Component that should be the dialog's parent
titleKey - the key for the locale-specific string to use for the file dialog title
approveKey - the key for the locale-specific string to use for the approve button text
directory - the directory to open the dialog to
mode - the "mode" to open the JFileChooser in from the JFileChooser class, such as JFileChooser.DIRECTORIES_ONLY
option - the option to look for in the return code, such as JFileChooser.APPROVE_OPTION
filter - the FileFilter instance for customizing the files that are displayed -- if this is null, no filter is used
Returns:
the selected File instance, or null if a file was not selected correctly