com.togethersoft.openapi.ide.window
Interface IdeFileChooser


public interface IdeFileChooser

IdeFileChooser provides a simple mechanism for the user to chooser a file.

Author:
TogetherSoft

Method Summary
 voidaddChoosableFileFilter(FileFilter filter)
           Adds a filter to the list of user choosable file filters.
 FileFiltergetAcceptAllFileFilter()
           Returns the AcceptAll file filter.
 StringgetApproveButtonText()
           Returns the text used in the ApproveButton in the FileChooserUI.
 FileFilter[]getChoosableFileFilters()
           Gets the list of the file filters that can be chosen by the user.
 FilegetCurrentDirectory()
           Returns the current directory.
 StringgetDialogTitle()
           Gets the string displayed in the FileChooser's titlebar.
 intgetDialogType()
           Returns the type of this dialog.
 FileFiltergetFileFilter()
           Returns the currently selected file filter.
 intgetFileSelectionMode()
           Returns the current file-selection mode.
 FilegetSelectedFile()
           Returns the selected file.
 booleanremoveChoosableFileFilter(FileFilter f)
           Removes specified filter from the list of user choosable file filters.
 voidresetChoosableFileFilters()
           Resets the choosable file filter list to it's initial state.
 voidsetApproveButtonText(String approveButtonText)
           Sets specified text for the ApproveButton in the FileChooserUI.
 voidsetCurrentDirectory(File dir)
           Sets the current directory.
 voidsetDialogTitle(String dialogTitle)
           Sets specified string to be displayed in the FileChooser window's title bar.
 voidsetDialogType(int dialogType)
           Sets the type of this dialog.
 voidsetFileFilter(FileFilter filter)
           Sets the current File Filter.
 voidsetFileSelectionMode(int mode)
           Sets the FileChooser to allow the user to select only files, to select only directories, or to select both files and directetories.
 voidsetSelectedFile(File selectedFile)
           Sets the selected file.
 intshowDialog(Component parent)
           Displays the file chooser dialog.

Method Detail

addChoosableFileFilter

public void addChoosableFileFilter(FileFilter filter)
Adds a filter to the list of user choosable file filters.
Parameters:
filter - FileFilter to be added to the choosable file filter list
See Also:
getChoosableFileFilters(), removeChoosableFileFilter(javax.swing.filechooser.FileFilter), resetChoosableFileFilters()

getAcceptAllFileFilter

public FileFilter getAcceptAllFileFilter()
Returns the AcceptAll file filter. (For example, (All Files *.*) on windows).
Returns: FileFilter AcceptAll

getApproveButtonText

public String getApproveButtonText()
Returns the text used in the ApproveButton in the FileChooserUI. If null, the UI object will determine the button's text. Typically, this would be "Open" or "Save".
Returns: String text used in the ApproveButton
See Also:
setApproveButtonText(java.lang.String), setDialogType(int), showDialog(java.awt.Component)

getChoosableFileFilters

public FileFilter[] getChoosableFileFilters()
Gets the list of the file filters that can be chosen by the user.
Returns: FileFilter[] array containing all the choosable file filters
See Also:
addChoosableFileFilter(javax.swing.filechooser.FileFilter), removeChoosableFileFilter(javax.swing.filechooser.FileFilter), resetChoosableFileFilters()

getCurrentDirectory

public File getCurrentDirectory()
Returns the current directory.
Returns: the current directory
See Also:
setCurrentDirectory(java.io.File)

getDialogTitle

public String getDialogTitle()
Gets the string displayed in the FileChooser's titlebar.
Returns: String title of the file chooser
See Also:
setDialogTitle(java.lang.String)

getDialogType

public int getDialogType()
Returns the type of this dialog.
Returns: int identifier of the dialog type: OPEN_DIALOG, SAVE_DIALOG, CUSTOM_DIALOG
See Also:
setDialogType(int), IdeFileChooserConstant

getFileFilter

public FileFilter getFileFilter()
Returns the currently selected file filter.
Returns: FileFilter object representing the current file filter.
See Also:
setFileFilter(javax.swing.filechooser.FileFilter), addChoosableFileFilter(javax.swing.filechooser.FileFilter)

getFileSelectionMode

public int getFileSelectionMode()
Returns the current file-selection mode.
Returns: int indicating the type of dialog to be displayed: FILES_ONLY, DIRECTORIES_ONLY, FILES_AND_DIRECTORIES
See Also:
setFileSelectionMode(int), IdeFileChooserConstant

getSelectedFile

public File getSelectedFile()
Returns the selected file.
Returns: the selected file
See Also:
setSelectedFile(java.io.File)

removeChoosableFileFilter

public boolean removeChoosableFileFilter(FileFilter f)
Removes specified filter from the list of user choosable file filters. Returns true if the file filter was successfully deleted.
Parameters:
f FileFilter - to be deleted
Returns: true if this filter is successfully deleted
See Also:
addChoosableFileFilter(javax.swing.filechooser.FileFilter), getChoosableFileFilters(), resetChoosableFileFilters()

resetChoosableFileFilters

public void resetChoosableFileFilters()
Resets the choosable file filter list to it's initial state. Normally, this removes all added file filters while leaving the AcceptAll file filter.
See Also:
addChoosableFileFilter(javax.swing.filechooser.FileFilter), getChoosableFileFilters(), removeChoosableFileFilter(javax.swing.filechooser.FileFilter)

setApproveButtonText

public void setApproveButtonText(String approveButtonText)
Sets specified text for the ApproveButton in the FileChooserUI.
Parameters:
approveButtonText - String text used in the ApproveButton
See Also:
getApproveButtonText(), setDialogType(int), showDialog(java.awt.Component)

setCurrentDirectory

public void setCurrentDirectory(File dir)
Sets the current directory. Passing in null sets the filechooser to point to the users's home directory.

If the file passed in as dir is not a directory, the parent of this file will be used as the current directory. 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 - File object representing the current directory to point to
See Also:
getCurrentDirectory()

setDialogTitle

public void setDialogTitle(String dialogTitle)
Sets specified string to be displayed in the FileChooser window's title bar.
Parameters:
dialogTitle - String title of the dialog
See Also:
getDialogTitle()

setDialogType

public void setDialogType(int dialogType)
Sets the type of this dialog. Use OPEN_DIALOG when you want to bring up a filechooser that the user can use to open a file. Likewise, use SAVE_DIALOG for letting the user choose a file for saving. Use CUSTOM_DIALOG when you want to use the filechooser in a context other than "Open" or "Save". For instance, you might want to bring up a filechooser that allows the user to choose a file to execute.
Parameters:
dialogType - int type of the dialog to be displayed: OPEN_DIALOG, SAVE_DIALOG, CUSTOM_DIALOG
See Also:
getDialogType(), setApproveButtonText(java.lang.String), IdeFileChooserConstant

setFileFilter

public void setFileFilter(FileFilter filter)
Sets the current File Filter. The file filter is used by the filechooser to filter out files that are visible to the user.
Parameters:
filter - the new current file filter to use
See Also:
getFileFilter()

setFileSelectionMode

public void setFileSelectionMode(int mode)
Sets the FileChooser to allow the user to select only files, to select only directories, or to select both files and directetories.
Parameters:
dialogType - int type of dialog to be displayed: FILES_ONLY, DIRECTORIES_ONLY, FILES_AND_DIRECTORIES
See Also:
getFileSelectionMode(), IdeFileChooserConstant

setSelectedFile

public void setSelectedFile(File selectedFile)
Sets the selected file. If the file's parent directory is not the current directory, it changes the current directory to be the files parent directory.
Parameters:
selectedFile - the selected file
See Also:
getSelectedFile()

showDialog

public int showDialog(Component parent)
Displays the file chooser dialog. If the Component is not null, the frame of the Component is used as the parent frame for the dialog box.
Parameters:
parent - Component descendant used to determine the parent of the dialog box.
Returns: int state of the filechooser on popdown: CANCEL_OPTION, APPROVE_OPTION
See Also:
IdeFileChooserConstant