public class FileDialog
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private boolean |
askOverwrite
If
true , a dialog is displayed to prompt for confirmation if the user enters the
name of a file that already exists. |
private boolean |
createTestFile
The dialog will attempt to create a temporary file with selected filename before it
completes in order to verify that the user has write access to the directory path specified
for the filename entry.
|
private java.lang.String |
defaultExtension
The default extension to be appended to the user’s filename entry after completing the
filename dialog.
|
private java.lang.String[] |
filters
Defines one or more filters for the filename dialog.
|
private boolean |
findDirectories
Flag to mark a dialog for selecting a directory.
|
private java.lang.String |
initialDir
The initial directory presented to user when dialog opens.
|
private int |
initialFilter
If
filters are specified, then the default one is designed by this value. |
private handle |
inWindow
Specifies the window from which the dialog box is displayed.
|
private boolean |
mustExist
Enforces that the selected filename entry must exist in the directory specified for the
filename entry before the dialog completes.
|
private character |
path
As input parameter, when
useFilename == true this is the default filename presented
to user. |
private boolean |
returnToStartDir
If this option is not specified, the directory remains set at the last directory referenced
by the user.
|
private boolean |
saveAs
Converts the dialog to a "Save As..." dialog box.
|
private java.lang.String |
title
The optional title of the dialog.
|
private logical |
toUpdate
A logical variable to return the status of the user’s filename dialog interaction.
|
private boolean |
useFilename
Specifies the contents of
path as the default filename entry for the dialog. |
Modifier | Constructor and Description |
---|---|
private |
FileDialog(character path,
boolean findDirs)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
FileDialog |
askOverwrite()
Configures the file selection dialog to warn the user that the selected file already exists
and prompt for overwrite it.
|
static FileDialog |
createDirSearchDialog(character dirPath)
Creates a configurable
FileDialog object that will prompt the user to select a
directory when executed. |
static FileDialog |
createFileSearchDialog(character filePath)
Creates a configurable
FileDialog object that will prompt the user to select a file
when executed. |
FileDialog |
createTestFile()
Configures the file selection dialog to check write access.
|
void |
execute()
Displays the file selection dialog that was already configured.
|
FileDialog |
mustExist()
Configures the file selection dialog not to select new files.
|
FileDialog |
returnToStartDir()
Configures the file selection dialog to discard any used navigation and not to save the
destination directory as default location for subsequent dialogs.
|
FileDialog |
saveAs()
Configures the file selection dialog as a Save-as dialog.
|
FileDialog |
setDefaultExtension(character defaultExtension)
Configures the default extension of the file selection dialog.
|
FileDialog |
setDefaultExtension(java.lang.String defaultExtension)
Configures the default extension of the file selection dialog.
|
FileDialog |
setFilters(java.lang.Object... filters)
Configures the filters of the file selection dialog.
|
FileDialog |
setInitialDir(character initialDir)
Configures the initial directory where the file selection dialog is open.
|
FileDialog |
setInitialDir(java.lang.String initialDir)
Configures the initial directory where the file selection dialog is open.
|
FileDialog |
setInitialFilter(long initialFilter)
Configures the initial filter of the file selection dialog.
|
FileDialog |
setInitialFilter(NumberType initialFilter)
Configures the initial filter of the file selection dialog.
|
FileDialog |
setTitle(character title)
Configures the title of the file selection dialog.
|
FileDialog |
setTitle(java.lang.String title)
Configures the title of the file selection dialog.
|
FileDialog |
setWindow(handle window)
Configures the file dialog to be created as child of a certain windows.
|
FileDialog |
update(logical update)
Configures the variable to be set when the file selection dialog is closed.
|
FileDialog |
useFilename()
Configures the file selection dialog to use the current value of the
path as default
filename and location. |
private static void |
validateParam(BaseDataType param)
Validates a parameter.
|
private final boolean findDirectories
true
the user can select only
directories. If false
the user can select only files.private character path
useFilename == true
this is the default filename presented
to user. When the dialog finished with success it contains the filename the user has
selected - as OUTPUT parameter.private logical toUpdate
private handle inWindow
private java.lang.String title
private boolean askOverwrite
true
, a dialog is displayed to prompt for confirmation if the user enters the
name of a file that already exists. This option is used only if SAVE-AS
option is
also active.private boolean createTestFile
private java.lang.String defaultExtension
private java.lang.String initialDir
private boolean mustExist
private boolean returnToStartDir
private boolean saveAs
private boolean useFilename
path
as the default filename entry for the dialog. The
user is free to change it if needed.private int initialFilter
filters
are specified, then the default one is designed by this value.private java.lang.String[] filters
private FileDialog(character path, boolean findDirs)
execute
. Depending on the findDirs
flag,
some of the options to be set may not be valid (FILTERS, INITIAL-FILTER, DEFAULT-EXTENSION,
MUST-EXIST, CREATE-TEST-FILE, SAVE-AS, ASK-OVERWRITE, USE-FILENAME and UPDATE are not valid
when findDirs == false
).path
- A reference to a character
variable to be updated if the dialog is
accepted.findDirs
- Sets the type of file dialog. If true
this will select folders only (behave
like the SYSTEM-DIALOG-GET-DIR), otherwise, only files are allowed to be returned
(behave like the SYSTEM-DIALOG-GET-FILE).public static FileDialog createFileSearchDialog(character filePath)
FileDialog
object that will prompt the user to select a file
when executed.filePath
- The output parameter that will contain result (full absolute path).FileDialog
that can be configured with various options using chained
methods before calling execute()
to be displayed.public static FileDialog createDirSearchDialog(character dirPath)
FileDialog
object that will prompt the user to select a
directory when executed.dirPath
- The output parameter that will contain result (full absolute path).FileDialog
that can be configured with various options using chained
methods before calling execute()
to be displayed.public FileDialog setWindow(handle window)
window
- A handle to a window that will be the parent of the file dialog.FileDialog
. Used for chaining.inWindow
public FileDialog setTitle(character title)
title
- The title of the file selection dialog.FileDialog
. Used for chaining.title
public FileDialog setTitle(java.lang.String title)
title
- The title of the file selection dialog.FileDialog
. Used for chaining.title
public FileDialog askOverwrite()
FileDialog
. Used for chaining.askOverwrite
public FileDialog createTestFile()
FileDialog
. Used for chaining.createTestFile
public FileDialog setDefaultExtension(character defaultExtension)
defaultExtension
- The default extension for selected file.FileDialog
. Used for chaining.defaultExtension
public FileDialog setDefaultExtension(java.lang.String defaultExtension)
defaultExtension
- The default extension for selected file.FileDialog
. Used for chaining.defaultExtension
public FileDialog setInitialDir(character initialDir)
initialDir
- the initial directory where the file selection dialog is open.FileDialog
. Used for chaining.initialDir
public FileDialog setInitialDir(java.lang.String initialDir)
initialDir
- the initial directory where the file selection dialog is open.FileDialog
. Used for chaining.initialDir
public FileDialog mustExist()
FileDialog
. Used for chaining.mustExist
public FileDialog returnToStartDir()
FileDialog
. Used for chaining.returnToStartDir
public FileDialog saveAs()
FileDialog
. Used for chaining.saveAs
public FileDialog useFilename()
path
as default
filename and location.FileDialog
. Used for chaining.useFilename
public FileDialog update(logical update)
update
- A variable that will hold the status of the dialog.FileDialog
. Used for chaining.toUpdate
public FileDialog setInitialFilter(long initialFilter)
initialFilter
- The index of the initial filter.FileDialog
. Used for chaining.initialFilter
public FileDialog setInitialFilter(NumberType initialFilter)
initialFilter
- The index of the initial filter.FileDialog
. Used for chaining.initialFilter
public FileDialog setFilters(java.lang.Object... filters)
filters
- The list of filters for the file selection dialog.FileDialog
. Used for chaining.filters
public void execute()
private static void validateParam(BaseDataType param)
null
or
unknown
.param
- The parameter to check.ErrorConditionException
- if the parameter does not meet the requirements.