public class FileDialog
extends java.lang.Object
Each public method emulates an option of the statement. They do a quick validation. If successful, they return a reference to this object to allow other method to be chained.
The execute()
method does the final checks, send the request with gathered options
to client, awaits the user to interact and finally sets up the response and confirmation
variable update
.
Modifier and Type | Field and Description |
---|---|
private boolean |
askOverwrite
If
true , a dialog is displayed to prompt for confirmation if the user selects the
a file that already exists. |
private boolean |
createTestFile
The dialog will attempt to create a temporary file with selected name and location before it
completes in order to verify whether the user has write access to respective directory.
|
private java.lang.String |
defaultExtension
The default extension to be appended to the user's selection if it does not have one.
|
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 where dialog opens for the first time.
|
private int |
initialFilter
If
filters are specified, then the default one is designed by this value. |
private handle |
inWindow
Specifies the parent window for the dialog box to be displayed.
|
private boolean |
mustExist
Enforces that the user must select and existing file.
|
private character |
path
As input parameter, when
useFilename == true this is the default filename presented
to user. |
private boolean |
returnToStartDir
By default, the last directory where the user has selected a file remains will be used as
the default initial directory for subsequent invocations of this method.
|
private boolean |
saveAs
Converts the dialog to a "Save As..." dialog box.
|
private java.lang.String |
title
The title of the dialog.
|
private logical |
toUpdate
A logical variable used as output parameter that will contain the status of the user's
dialog interaction: if the user validates it by selecting the
OK button, the
value of the variable is set to TRUE on return. |
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
OK
button, the
value of the variable is set to TRUE
on return. If the user rejects the dialog by
pressing the Cancel
button, the variable's value on return will be FALSE
.private handle inWindow
private java.lang.String title
Open
and Save As
dialogs will be used.private boolean askOverwrite
true
, a dialog is displayed to prompt for confirmation if the user selects the
a file that already exists. This option is used only if SAVE-AS
option is
also active.private boolean createTestFile
Note: this option is not supported yet.
private java.lang.String defaultExtension
private java.lang.String initialDir
private boolean mustExist
Cancel
button to reject
the dialog.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 dialog. The handle must
refer a window or an error condition will be issued.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 return status of the dialog. That is true
if the dialog was accepted and false
otherwise.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 initially active 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.