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 Details

    • DEFAULT_CHARSET_SUFFIX

      protected static final String DEFAULT_CHARSET_SUFFIX
      See Also:
    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
    • uiProperties

      protected UiProperties uiProperties
    • coreProperties

      protected CoreProperties coreProperties
    • messages

      protected Messages messages
    • uiAsyncTasks

      protected UiAsyncTasks uiAsyncTasks
    • uiComponents

      protected UiComponents uiComponents
    • fileStorageLocator

      protected FileStorageLocator fileStorageLocator
    • fileStorage

      protected FileStorage fileStorage
    • newWindow

      protected boolean newWindow
    • useViewList

      protected boolean useViewList
    • viewFilePredicate

      protected Predicate<String> 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:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • setUiProperties

      @Autowired public void setUiProperties(UiProperties uiProperties)
    • setCoreProperties

      @Autowired public void setCoreProperties(CoreProperties coreProperties)
    • setMessages

      @Autowired public void setMessages(Messages messages)
    • setFileStorageLocator

      @Autowired public void setFileStorageLocator(FileStorageLocator fileStorageLocator)
    • setUiAsyncTasks

      @Autowired public void setUiAsyncTasks(UiAsyncTasks uiAsyncTasks)
    • setUiComponents

      @Autowired public void setUiComponents(UiComponents uiComponents)
    • setFileStorage

      public void setFileStorage(FileStorage fileStorage)
      Description copied from interface: Downloader
      Sets a file storage where the files will be downloaded from.
      Specified by:
      setFileStorage in interface Downloader
      Parameters:
      fileStorage - file storage
    • defaultViewFilePredicate

      protected boolean defaultViewFilePredicate(String fileExtension)
    • setViewFilePredicate

      public void setViewFilePredicate(Predicate<String> viewFilePredicate)
      Description copied from interface: Downloader
      Sets a predicate that checks if file is allowed to be opened. It takes file extension as an input parameter and returns true if file is allowed to be opened or false if file should be downloaded.
      Specified by:
      setViewFilePredicate in interface Downloader
      Parameters:
      viewFilePredicate - predicate
    • isShowNewWindow

      public boolean isShowNewWindow()
      Specified by:
      isShowNewWindow in interface Downloader
      Returns:
      true if downloader should open a new window with the file content
    • setShowNewWindow

      public void setShowNewWindow(boolean showNewWindow)
      Description copied from interface: Downloader
      Sets explicit new window option.
      Specified by:
      setShowNewWindow in interface Downloader
      Parameters:
      showNewWindow - true if downloader opens new window, otherwise false
    • download

      public void download(DownloadDataProvider dataProvider, String resourceName, @Nullable DownloadFormat downloadFormat)
      Show/Download resource at client side
      Specified by:
      download in interface Downloader
      Parameters:
      dataProvider - DownloadDataProvider
      resourceName - ResourceName for client side
      downloadFormat - 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

      public void download(DownloadDataProvider dataProvider, String resourceName)
      Show/Download resource at client side
      Specified by:
      download in interface Downloader
      Parameters:
      dataProvider - DownloadDataProvider
      resourceName - ResourceName for client side
      See Also:
    • download

      public void download(FileRef fileReference)
      Description copied from interface: Downloader
      Downloads a file from the FileStorage retrieved by FileStorageLocator using storage name from FileRef.
      Specified by:
      download in interface Downloader
      Parameters:
      fileReference - file reference
    • download

      public void download(FileRef fileReference, @Nullable DownloadFormat format)
      Description copied from interface: Downloader
      Downloads a file from the FileStorage retrieved by FileStorageLocator using storage name from FileRef.
      Specified by:
      download in interface Downloader
      Parameters:
      fileReference - file reference
      format - download format, can be null
    • download

      public void download(byte[] data, String resourceName)
      Description copied from interface: Downloader
      Downloads passed byte array.
      Specified by:
      download in interface Downloader
      Parameters:
      data - data in the form of byte array
      resourceName - resource name
    • download

      public void download(byte[] data, String resourceName, @Nullable DownloadFormat format)
      Description copied from interface: Downloader
      Downloads passed byte array.
      Specified by:
      download in interface Downloader
      Parameters:
      data - data in the form of byte array
      resourceName - resource name
      format - 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

      protected String normalize(String originString)
    • isBrowserSupportsPopups

      protected boolean isBrowserSupportsPopups()
    • isIPhone

      protected boolean isIPhone()