Class OpenFileRequest
Describes a native Open dialog for
com.codename1.ui.Display#showOpenDialog(OpenFileRequest, com.codename1.util.SuccessCallback).
Display.getInstance().showOpenDialog(new OpenFileRequest()
.title("Import photos")
.multiSelect(true)
.addFilter(new FileTypeFilter("Images").extensions("png", "jpg").mimeTypes("image/*"))
.preview(path -> new ScaleImageLabel(loadThumbnail(path))),
result -> {
if (!result.isCancelled()) {
for (String p : result.getPaths()) {
importFile(p);
}
}
});
The paths reported are readable with com.codename1.io.FileSystemStorage.
On Android and iOS the picked document is copied into the app's cache first,
since those platforms hand out content that outlives no process.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondirectories(boolean directories) Picks folders instead of files, whereFileDialogFeatures#DIRECTORIESis supported.The preview provider, or null.booleanWhether folders are picked.booleanWhether several files may be picked.multiSelect(boolean multiSelect) Lets the user pick several files.preview(FilePreviewProvider preview) Supplies a preview shown beside the file list as the selection changes, whereFileDialogFeatures#PREVIEWis supported.Methods inherited from class FileDialogRequest
acceptLabel, accessory, addFilter, addOption, getAcceptLabel, getAccessory, getBooleanHint, getFilters, getHint, getInitialDirectory, getMessage, getOptions, getSelectedFilter, getStringHint, getTitle, hint, initialDirectory, message, selectedFilter, title, toAcceptString
-
Constructor Details
-
OpenFileRequest
public OpenFileRequest()
-
-
Method Details
-
multiSelect
Lets the user pick several files. Platforms without
FileDialogFeatures#MULTI_SELECTreturn one.Parameters
multiSelect: true to allow several files
Returns
this request
-
directories
Picks folders instead of files, where
FileDialogFeatures#DIRECTORIESis supported.Parameters
directories: true to pick folders
Returns
this request
-
preview
Supplies a preview shown beside the file list as the selection changes, where
FileDialogFeatures#PREVIEWis supported.Parameters
preview: the preview provider
Returns
this request
-
isMultiSelect
public boolean isMultiSelect()Whether several files may be picked.
Returns
true for multi selection
-
isDirectories
public boolean isDirectories()Whether folders are picked.
Returns
true for folders
-
getPreview
The preview provider, or null.
Returns
the provider
-