Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public abstract class FileDialogRequest<T extends FileDialogRequest<T>>

  1. Object
  2. FileDialogRequest

Known subtypesOpenFileRequest, SaveFileRequest

The settings shared by OpenFileRequest and SaveFileRequest.

Every setter returns the request, so a dialog is described in one chain. Settings a platform cannot honour are ignored rather than failing, and com.codename1.ui.Display#isFileDialogFeatureSupported(int) says up front which ones apply. Platform specific tuning goes through #hint(String, Object).

Parameters

  • <T>: the concrete request type, so chained setters keep it

Fields

public static final String HINT_MAC_SHOWS_TAG_FIELD = "mac.showsTagField"Boolean: show the Finder tag field in a macOS save panel.
public static final String HINT_MAC_CAN_CREATE_DIRECTORIES = "mac.canCreateDirectories"Boolean: allow creating folders from a macOS panel.
public static final String HINT_MAC_SHOWS_HIDDEN_FILES = "mac.showsHiddenFiles"Boolean: show hidden files in a macOS panel.
public static final String HINT_MAC_CAN_SELECT_HIDDEN_EXTENSION = "mac.canSelectHiddenExtension"Boolean: let the user hide the extension in a macOS save panel.
public static final String HINT_MAC_TREATS_PACKAGES_AS_DIRECTORIES = "mac.treatsFilePackagesAsDirectories"Boolean: treat packages (.app, .bundle) as folders in a macOS open panel.
public static final String HINT_IOS_SHOWS_FILE_EXTENSIONS = "ios.showsFileExtensions"Boolean: show file extensions in the iOS document picker.
public static final String HINT_IOS_EXPORT_AS_MOVE = "ios.exportAsMove"Boolean: move rather than copy the exported file on iOS.
public static final String HINT_ANDROID_INITIAL_URI = "android.initialUri"String: a content:// URI the Android picker starts in.
public static final String HINT_ANDROID_PERSIST_PERMISSION = "android.persistPermission"Boolean: keep persistable read/write permission to the picked Android document across restarts.
public static final String HINT_WIN_CLIENT_GUID = "win.clientGuid"String: a GUID string; Windows remembers the last folder and size separately per GUID, so different dialogs of one app do not share state.
public static final String HINT_WIN_DEFAULT_FOLDER = "win.defaultFolder"String: the folder Windows shows when the user has no recent folder, as opposed to FileDialogRequest#initialDirectory, which always wins.
public static final String HINT_DESKTOP_SHOW_HIDDEN = "desktop.showHidden"Boolean: show hidden files in the GTK chooser and the simulator.

Methods

public T title(String title)Sets the window title.
public T message(String message)Sets an explanatory line shown in the dialog (NSSavePanel.message on macOS, the fallback dialog’s header elsewhere).
public T acceptLabel(String label)Replaces the text of the Open or Save button on desktops.
public T initialDirectory(String path)Sets the folder the dialog starts in, as a FileSystemStorage path.
public T addFilter(FileTypeFilter filter)Adds a file type filter.
public T selectedFilter(int index)Selects the filter shown initially.
public T hint(String key, Object value)Sets a platform specific hint; see the HINT_ constants.
public T addOption(FileDialogOption option)Adds a portable control to the dialog; see FileDialogOption.
public T accessory(Component accessory)Embeds a Codename One component in the dialog, such as a format and quality panel for an export.
public String getTitle()The window title, or null.
public String getMessage()The explanatory message, or null.
public String getAcceptLabel()The accept button text, or null for the platform default.
public String getInitialDirectory()The starting folder, or null.
public FileTypeFilter[] getFilters()The filters in the order they were added.
public int getSelectedFilter()The initially selected filter index, clamped to the filters present.
public Object getHint(String key)Reads a hint.
public boolean getBooleanHint(String key, boolean def)Reads a boolean hint.
public String getStringHint(String key)Reads a string hint.
public FileDialogOption[] getOptions()The portable controls in the order they were added.
public Component getAccessory()The accessory component, or null.
public String toAcceptString()Joins every filter’s extensions and MIME types into the comma separated form com.codename1.ui.Display#openFileChooser takes.

Inherited methods

Field details

HINT_MAC_SHOWS_TAG_FIELD

public static final String HINT_MAC_SHOWS_TAG_FIELD = "mac.showsTagField"
Boolean: show the Finder tag field in a macOS save panel.

HINT_MAC_CAN_CREATE_DIRECTORIES

public static final String HINT_MAC_CAN_CREATE_DIRECTORIES = "mac.canCreateDirectories"
Boolean: allow creating folders from a macOS panel. Defaults to true.

HINT_MAC_SHOWS_HIDDEN_FILES

public static final String HINT_MAC_SHOWS_HIDDEN_FILES = "mac.showsHiddenFiles"
Boolean: show hidden files in a macOS panel.

HINT_MAC_CAN_SELECT_HIDDEN_EXTENSION

public static final String HINT_MAC_CAN_SELECT_HIDDEN_EXTENSION = "mac.canSelectHiddenExtension"
Boolean: let the user hide the extension in a macOS save panel.

HINT_MAC_TREATS_PACKAGES_AS_DIRECTORIES

public static final String HINT_MAC_TREATS_PACKAGES_AS_DIRECTORIES = "mac.treatsFilePackagesAsDirectories"
Boolean: treat packages (.app, .bundle) as folders in a macOS open panel.

HINT_IOS_SHOWS_FILE_EXTENSIONS

public static final String HINT_IOS_SHOWS_FILE_EXTENSIONS = "ios.showsFileExtensions"
Boolean: show file extensions in the iOS document picker.

HINT_IOS_EXPORT_AS_MOVE

public static final String HINT_IOS_EXPORT_AS_MOVE = "ios.exportAsMove"
Boolean: move rather than copy the exported file on iOS. Defaults to copy.

HINT_ANDROID_INITIAL_URI

public static final String HINT_ANDROID_INITIAL_URI = "android.initialUri"
String: a content:// URI the Android picker starts in.

HINT_ANDROID_PERSIST_PERMISSION

public static final String HINT_ANDROID_PERSIST_PERMISSION = "android.persistPermission"
Boolean: keep persistable read/write permission to the picked Android document across restarts.

HINT_WIN_CLIENT_GUID

public static final String HINT_WIN_CLIENT_GUID = "win.clientGuid"
String: a GUID string; Windows remembers the last folder and size separately per GUID, so different dialogs of one app do not share state.

HINT_WIN_DEFAULT_FOLDER

public static final String HINT_WIN_DEFAULT_FOLDER = "win.defaultFolder"
String: the folder Windows shows when the user has no recent folder, as opposed to FileDialogRequest#initialDirectory, which always wins.

HINT_DESKTOP_SHOW_HIDDEN

public static final String HINT_DESKTOP_SHOW_HIDDEN = "desktop.showHidden"
Boolean: show hidden files in the GTK chooser and the simulator.

Method details

title

public T title(String title)
Sets the window title. Ignored by the mobile pickers.

Parameters

title String
the title

Returns

this request

message

public T message(String message)
Sets an explanatory line shown in the dialog (NSSavePanel.message on macOS, the fallback dialog’s header elsewhere).

Parameters

message String
the text

Returns

this request

acceptLabel

public T acceptLabel(String label)
Replaces the text of the Open or Save button on desktops.

Parameters

label String
the button text

Returns

this request

initialDirectory

public T initialDirectory(String path)
Sets the folder the dialog starts in, as a FileSystemStorage path.

Parameters

path String
the folder

Returns

this request

addFilter

public T addFilter(FileTypeFilter filter)
Adds a file type filter. The first one added is selected unless #selectedFilter(int) says otherwise.

Parameters

filter FileTypeFilter
the filter

Returns

this request

selectedFilter

public T selectedFilter(int index)
Selects the filter shown initially.

Parameters

index int
an index into the filters added so far

Returns

this request

hint

public T hint(String key, Object value)
Sets a platform specific hint; see the HINT_ constants. Unknown hints are ignored.

Parameters

key String
the hint name
value Object
its value

Returns

this request

addOption

public T addOption(FileDialogOption option)
Adds a portable control to the dialog; see FileDialogOption.

Parameters

option FileDialogOption
the control

Returns

this request

accessory

public T accessory(Component accessory)
Embeds a Codename One component in the dialog, such as a format and quality panel for an export. Only shown where FileDialogFeatures#ACCESSORY_COMPONENT is supported (today only the Codename One fallback save form); use #addOption(FileDialogOption) for controls that must appear on every desktop. The component is still reachable from the callback, so its state can be read after the dialog closes.

Parameters

accessory Component
the component

Returns

this request

getTitle

public String getTitle()
The window title, or null.

Returns

the title

getMessage

public String getMessage()
The explanatory message, or null.

Returns

the message

getAcceptLabel

public String getAcceptLabel()
The accept button text, or null for the platform default.

Returns

the label

getInitialDirectory

public String getInitialDirectory()
The starting folder, or null.

Returns

the folder path

getFilters

public FileTypeFilter[] getFilters()
The filters in the order they were added.

Returns

a copy of the filters

getSelectedFilter

public int getSelectedFilter()
The initially selected filter index, clamped to the filters present.

Returns

the index, or -1 when there are no filters

getHint

public Object getHint(String key)
Reads a hint.

Parameters

key String
the hint name

Returns

the value, or null

getBooleanHint

public boolean getBooleanHint(String key, boolean def)
Reads a boolean hint.

Parameters

key String
the hint name
def boolean
the value when the hint is absent or not a boolean

Returns

the value

getStringHint

public String getStringHint(String key)
Reads a string hint.

Parameters

key String
the hint name

Returns

the value as a string, or null

getOptions

public FileDialogOption[] getOptions()
The portable controls in the order they were added.

Returns

a copy of the options

getAccessory

public Component getAccessory()
The accessory component, or null.

Returns

the accessory

toAcceptString

public String toAcceptString()
Joins every filter’s extensions and MIME types into the comma separated form com.codename1.ui.Display#openFileChooser takes.

Returns

the accept string, or null when nothing is filtered