Package io.jmix.flowui.download
Class DownloaderImpl
java.lang.Object
io.jmix.flowui.download.DownloaderImpl
- All Implemented Interfaces:
Downloader,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Component("flowui_Downloader")
@Scope("prototype")
public class DownloaderImpl
extends Object
implements Downloader, org.springframework.context.ApplicationContextAware
Shows exported data in the web browser or downloads it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContextprotected CorePropertiesprotected static final Stringprotected FileStorageprotected FileStorageLocatorprotected Messagesprotected booleanprotected UiAsyncTasksprotected UiComponentsprotected UiPropertiesprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected DownloadContextcreateDownloadContext(DownloadDataProvider dataProvider, String resourceName, DownloadFormat downloadFormat, boolean download) protected com.vaadin.flow.server.streams.DownloadHandlercreateDownloadHandler(DownloadContext downloadContext) protected com.vaadin.flow.component.html.AnchorcreateFileDownloaderComponent(DownloadContext downloadContext) protected booleandefaultViewFilePredicate(String fileExtension) voidDownloads passed byte array.voiddownload(byte[] data, String resourceName, DownloadFormat format) Downloads passed byte array.voidDownloads a file from theFileStorageretrieved byFileStorageLocatorusing storage name from FileRef.voiddownload(FileRef fileReference, DownloadFormat format) Downloads a file from theFileStorageretrieved byFileStorageLocatorusing storage name from FileRef.voiddownload(DownloadDataProvider dataProvider, String resourceName) Show/Download resource at client sidevoiddownload(DownloadDataProvider dataProvider, String resourceName, DownloadFormat downloadFormat) Show/Download resource at client sideprotected voiddownloadFile(com.vaadin.flow.component.html.Anchor fileDownloader) protected voidprotected booleanhandleFileNotFoundException(DownloaderExportHandler.FileNotFoundContext fileNotFoundEvent) protected voidinitFileDownloaderComponent(com.vaadin.flow.component.html.Anchor fileDownloader, DownloadContext downloadContext) protected booleanprotected booleanisIPhone()booleanprotected StringvoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetCoreProperties(CoreProperties coreProperties) voidsetFileStorage(FileStorage fileStorage) Sets a file storage where the files will be downloaded from.voidsetFileStorageLocator(FileStorageLocator fileStorageLocator) voidsetMessages(Messages messages) voidsetShowNewWindow(boolean showNewWindow) Sets explicit new window option.voidsetUiAsyncTasks(UiAsyncTasks uiAsyncTasks) voidsetUiComponents(UiComponents uiComponents) voidsetUiProperties(UiProperties uiProperties) voidsetViewFilePredicate(Predicate<String> viewFilePredicate) Sets a predicate that checks if file is allowed to be opened.protected voidwriteFileNotFoundException(com.vaadin.flow.server.VaadinResponse response, String message)
-
Field Details
-
DEFAULT_CHARSET_SUFFIX
- See Also:
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
uiProperties
-
coreProperties
-
messages
-
uiAsyncTasks
-
uiComponents
-
fileStorageLocator
-
fileStorage
-
newWindow
protected boolean newWindow -
useViewList
protected boolean useViewList -
viewFilePredicate
-
-
Constructor Details
-
DownloaderImpl
public DownloaderImpl()Constructor with newWindow=false -
DownloaderImpl
public DownloaderImpl(boolean newWindow) - Parameters:
newWindow- if true, show data in the same browser window; if false, open new browser window
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
setUiProperties
-
setCoreProperties
-
setMessages
-
setFileStorageLocator
-
setUiAsyncTasks
-
setUiComponents
-
setFileStorage
Description copied from interface:DownloaderSets a file storage where the files will be downloaded from.- Specified by:
setFileStoragein interfaceDownloader- Parameters:
fileStorage- file storage
-
defaultViewFilePredicate
-
setViewFilePredicate
Description copied from interface:DownloaderSets a predicate that checks if file is allowed to be opened. It takes file extension as an input parameter and returnstrueif file is allowed to be opened orfalseif file should be downloaded.- Specified by:
setViewFilePredicatein interfaceDownloader- Parameters:
viewFilePredicate- predicate
-
isShowNewWindow
public boolean isShowNewWindow()- Specified by:
isShowNewWindowin interfaceDownloader- Returns:
trueif downloader should open a new window with the file content
-
setShowNewWindow
public void setShowNewWindow(boolean showNewWindow) Description copied from interface:DownloaderSets explicit new window option.- Specified by:
setShowNewWindowin interfaceDownloader- Parameters:
showNewWindow-trueif downloader opens new window, otherwisefalse
-
download
public void download(DownloadDataProvider dataProvider, String resourceName, @Nullable DownloadFormat downloadFormat) Show/Download resource at client side- Specified by:
downloadin interfaceDownloader- Parameters:
dataProvider- DownloadDataProviderresourceName- ResourceName for client sidedownloadFormat- DownloadFormat- See Also:
-
downloadFile
protected void downloadFile(com.vaadin.flow.component.html.Anchor fileDownloader) -
createFileDownloaderComponent
protected com.vaadin.flow.component.html.Anchor createFileDownloaderComponent(DownloadContext downloadContext) -
initFileDownloaderComponent
protected void initFileDownloaderComponent(com.vaadin.flow.component.html.Anchor fileDownloader, DownloadContext downloadContext) -
createDownloadHandler
protected com.vaadin.flow.server.streams.DownloadHandler createDownloadHandler(DownloadContext downloadContext) -
createDownloadContext
protected DownloadContext createDownloadContext(DownloadDataProvider dataProvider, String resourceName, @Nullable DownloadFormat downloadFormat, boolean download) -
download
Show/Download resource at client side- Specified by:
downloadin interfaceDownloader- Parameters:
dataProvider- DownloadDataProviderresourceName- ResourceName for client side- See Also:
-
download
Description copied from interface:DownloaderDownloads a file from theFileStorageretrieved byFileStorageLocatorusing storage name from FileRef.- Specified by:
downloadin interfaceDownloader- Parameters:
fileReference- file reference
-
download
Description copied from interface:DownloaderDownloads a file from theFileStorageretrieved byFileStorageLocatorusing storage name from FileRef.- Specified by:
downloadin interfaceDownloader- Parameters:
fileReference- file referenceformat- download format, can be null
-
download
Description copied from interface:DownloaderDownloads passed byte array.- Specified by:
downloadin interfaceDownloader- Parameters:
data- data in the form of byte arrayresourceName- resource name
-
download
Description copied from interface:DownloaderDownloads passed byte array.- Specified by:
downloadin interfaceDownloader- Parameters:
data- data in the form of byte arrayresourceName- resource nameformat- download format, can be null
-
checkUIAccess
protected void checkUIAccess() -
fileDownloaderRemoveHandler
protected void fileDownloaderRemoveHandler(SupportDownloadSuccessHandler.DownloadSuccessContext context) -
handleFileNotFoundException
protected boolean handleFileNotFoundException(DownloaderExportHandler.FileNotFoundContext fileNotFoundEvent) -
writeFileNotFoundException
protected void writeFileNotFoundException(com.vaadin.flow.server.VaadinResponse response, String message) throws IOException - Throws:
IOException
-
normalize
-
isBrowserSupportsPopups
protected boolean isBrowserSupportsPopups() -
isIPhone
protected boolean isIPhone()
-