Class JtvFileDialog
public class JtvFileDialog
extends JtvDialog
A standard file-open / file-save dialog box.
TFileDialog presents a resizable dialog that lets the user browse and select files. It contains:
- A filename input line (JtvFileInputLine) with a history list.
- A file list box (JtvFileList) showing the current directory.
- A file information pane (JtvFileInfoPane) at the bottom.
- Configurable action buttons controlled by the
aOptionsflag.
The set of buttons is controlled by aOptions (see fdXXXX constants):
fdOpenButton, fdOKButton, fdReplaceButton, fdClearButton,
fdHelpButton. A Cancel button is always present.
When an action button is pressed, the dialog ends its modal state with the
corresponding command (cmFileOpen, cmFileReplace, cmFileClear).
A double-click in the file list is treated as cmOK.
valid(int) checks the filename input line before closing:
- A wildcard updates the directory/filter and reloads the list without closing.
- A directory path navigates into that directory without closing.
- A plain filename closes the dialog.
After the dialog closes, the fully-qualified selected file path can be retrieved via getFileName(StringBuilder).
org.viktor44.jtvision.dialogs.JtvFileDialog
Summary
Constructors
| Visibility | Signature |
|---|---|
| public | JtvFileDialog(String aWildCard, String aTitle, String inputName, int aOptions, int histId) |
Fields
| Modifiers | Field name | Type |
|---|---|---|
| private static final | filesText | String |
| private static final | openText | String |
| private static final | okText | String |
| private static final | replaceText | String |
| private static final | clearText | String |
| private static final | cancelText | String |
| private static final | helpText | String |
| private static final | invalidDriveText | String |
| private static final | invalidFileText | String |
| private | fileName | org.viktor44.jtvision.dialogs.JtvFileInputLine |
| private | fileList | org.viktor44.jtvision.dialogs.JtvFileList |
| private | wildCard | String |
| private | directory | String |
Methods
| Modifiers | Method signature | Return type |
|---|---|---|
| private | addButton(JtvRect r, String title, int cmd, int flags) | void |
| public | getFileName(StringBuilder out) | void |
| public | handleEvent(JtvEvent event) | void |
| public | readDirectory() | void |
| public | setDataFrom(Object rec) | void |
| public | getDataTo(Object rec) | void |
| private | checkDirectory(String str) | boolean |
| public | valid(int command) | boolean |
| public | getFileName() | org.viktor44.jtvision.dialogs.JtvFileInputLine |
| public | getWildCard() | String |
| public | getDirectory() | String |
Constructors
JtvFileDialog(String aWildCard, String aTitle, String inputName, int aOptions, int histId)
Creates the file dialog.
The dialog is initially centred and sized for the current screen, expanding
further if the screen is large enough. Unless fdNoLoadDir is set in
aOptions, the file list is loaded immediately with the current directory.
Parameters
aWildCard- the initial wildcard filter (e.g.,"*.java"); defaults to"*"ifnullaTitle- the dialog title bar textinputName- the label string for the file-name input lineaOptions- combination offdXXXXflag constants controlling which buttons appearhistId- the history list ID for the filename input line
Fields
String filesText
No description provided
String openText
No description provided
String okText
No description provided
String replaceText
No description provided
String clearText
No description provided
String cancelText
No description provided
String helpText
No description provided
String invalidDriveText
No description provided
String invalidFileText
No description provided
org.viktor44.jtvision.dialogs.JtvFileInputLine fileName
The filename input line. Exposed so callers can read or set the filename programmatically.
org.viktor44.jtvision.dialogs.JtvFileList fileList
The file list box that displays directory contents.
String wildCard
The current wildcard filter (e.g., "*.java").
Updated when the user types a wildcard pattern in the input line.
String directory
The absolute path of the directory currently displayed, always ending with a file separator character.
Methods
addButton(JtvRect r, String title, int cmd, int flags)
Creates and inserts a growing button with the given parameters.
Parameters
rtitlecmdflags
getFileName(StringBuilder out)
Builds the fully-qualified path of the selected file and appends it to
out. If the filename in the input line is relative, it is resolved
against the current directory.
Parameters
out- theStringBuilderto receive the absolute file path
handleEvent(JtvEvent event)
Overrides:
handleEvent(JtvEvent event) in org.viktor44.jtvision.dialogs.JtvDialog
Handles cmFileOpen, cmFileReplace, and cmFileClear
commands by ending the modal state. Handles cmFileDoubleClicked
broadcasts from the file list by converting them to a cmOK command.
Parameters
event- the incoming event
readDirectory()
Reloads the file list from the current JVM working directory using the
active wildCard filter.
setDataFrom(Object rec)
Handles data transfer from the dialog. If the record is a string that contains a wildcard, re-initialises the file list filter.
Parameters
rec- the source data record
getDataTo(Object rec)
Writes the selected file path into rec if it is a StringBuilder.
Parameters
rec- aStringBuilderto receive the selected file path
checkDirectory(String str)
Shows an "invalid directory" message box and refocuses the filename input line.
Parameters
str- the directory path that failed validation
Returns
true if the directory exists and is valid
valid(int command)
Overrides:
valid(int command) in org.viktor44.jtvision.dialogs.JtvDialog
Validates the dialog before closing.
- Zero or
cmCancel/cmFileClear— always valid. - Wildcard in the input line — updates the filter and reloads the list,
returns
falseto keep the dialog open. - Directory path in the input line — navigates to that directory,
returns
falseto keep the dialog open. - Plain filename — returns
trueallowing the dialog to close.
Parameters
command- the command that is attempting to close the dialog
Returns
true if the dialog may close; false otherwise
getFileName()
The filename input line. Exposed so callers can read or set the filename programmatically.
getWildCard()
The current wildcard filter (e.g., "*.java").
Updated when the user types a wildcard pattern in the input line.
getDirectory()
The absolute path of the directory currently displayed, always ending with a file separator character.