Class UploadHelper

java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.addons.f0rce.uploadhelper.UploadHelper
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, java.io.Serializable

@Tag("lit-uploadhelper")
@JsModule("./@f0rce/uploadhelper/lit-uploadhelper.js")
@CssImport("./@f0rce/uploadhelper/styles.css")
public class UploadHelper
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasSize
See Also:
Serialized Form
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  UploadHelper.UHFileRejectEvent  
    static class  UploadHelper.UHUploadErrorEvent  
    static class  UploadHelper.UHUploadStartEvent  
    static class  UploadHelper.UHUploadSuccessEvent  
  • Constructor Summary

    Constructors 
    Constructor Description
    UploadHelper​(com.vaadin.flow.component.Component dropZone, java.lang.String shadowDomDropZone, UHReceiver receiver)  
    UploadHelper​(com.vaadin.flow.component.Component dropZone, UHReceiver receiver)  
    UploadHelper​(java.lang.String dropZone, java.lang.String shadowDomDropZone, UHReceiver receiver)  
    UploadHelper​(java.lang.String dropZone, UHReceiver receiver)  
    UploadHelper​(UHReceiver receiver)  
  • Method Summary

    Modifier and Type Method Description
    com.vaadin.flow.shared.Registration addAllFinishedListener​(com.vaadin.flow.component.ComponentEventListener<UHAllFinishedEvent> listener)
    Add listener that is informed on the finished upload.
    com.vaadin.flow.shared.Registration addFailedListener​(com.vaadin.flow.component.ComponentEventListener<UHFailedEvent> listener)
    Add a succeeded listener that is informed on upload failure.
    com.vaadin.flow.shared.Registration addFileRejectedListener​(com.vaadin.flow.component.ComponentEventListener<UHFileRejectedEvent> listener)
    Adds a listener for uh-file-reject events fired when a file cannot be added due to some constrains: setMaxFileSize, setAcceptedFileTypes
    com.vaadin.flow.shared.Registration addFinishedListener​(com.vaadin.flow.component.ComponentEventListener<UHFinishedEvent> listener)
    Add a succeeded listener that is informed on upload finished.
    com.vaadin.flow.shared.Registration addProgressListener​(com.vaadin.flow.component.ComponentEventListener<UHProgressUpdateEvent> listener)
    Add a progress listener that is informed on upload progress.
    com.vaadin.flow.shared.Registration addStartedListener​(com.vaadin.flow.component.ComponentEventListener<UHStartedEvent> listener)
    Add a succeeded listener that is informed on upload start.
    com.vaadin.flow.shared.Registration addSucceededListener​(com.vaadin.flow.component.ComponentEventListener<UHSucceededEvent> listener)
    Add a succeeded listener that is informed on upload succeeded.
    int getMaxFiles()  
    int getMaxFileSize()
    Get the maximum allowed file size in the client-side, in bytes.
    UHReceiver getReceiver()
    Return the current receiver.
    boolean isVisualFeedback()
    Returns if visual feedback is enabled.
    void removeDropZone()
    Removes the dropZone / disables uploading to it.
    void setDropZone​(com.vaadin.flow.component.Component dropZone)
    Sets the dropZone (the Component which Upload-Helper should be enabled on).
    void setDropZone​(com.vaadin.flow.component.Component dropZone, java.lang.String shadowDomDropZone)
    Sets the dropZone in the Component's ShadowDom.
    void setDropZone​(java.lang.String dropZone)
    Sets the dropZone (the Element ID which Upload-Helper should be enabled on).
    void setDropZone​(java.lang.String dropZone, java.lang.String shadowDomDropZone)
    Sets the dropZone in the ShadowDom of given Element ID.
    void setMaxFiles​(int maxFiles)
    Limit of files to upload, by default it is 1.
    void setMaxFileSize​(int maxFileSize)
    Specify the maximum file size in bytes allowed to upload.
    void setReceiver​(UHReceiver receiver)
    Sets a receiver.
    void setVisualFeedback​(boolean visualFeedback)
    If set the false, the background color and the opacity of the dropZone Element is not changed.

    Methods inherited from class com.vaadin.flow.component.Component

    from, getChildren, getElement, getId, getParent, getTranslation, getTranslation, getUI, isAttached, isVisible, onEnabledStateChanged, setId, setVisible

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasSize

    getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
  • Constructor Details

  • Method Details

    • setReceiver

      public void setReceiver​(UHReceiver receiver)
      Sets a receiver.
      Parameters:
      receiver - UHReceiver
    • setDropZone

      public void setDropZone​(com.vaadin.flow.component.Component dropZone)
      Sets the dropZone (the Component which Upload-Helper should be enabled on).
      Parameters:
      dropZone - Component
    • setDropZone

      public void setDropZone​(com.vaadin.flow.component.Component dropZone, java.lang.String shadowDomDropZone)
      Sets the dropZone in the Component's ShadowDom.
      Parameters:
      dropZone - Component
      shadowDomDropZone - String
    • setDropZone

      public void setDropZone​(java.lang.String dropZone)
      Sets the dropZone (the Element ID which Upload-Helper should be enabled on).
      Parameters:
      dropZone - String
    • setDropZone

      public void setDropZone​(java.lang.String dropZone, java.lang.String shadowDomDropZone)
      Sets the dropZone in the ShadowDom of given Element ID.
      Parameters:
      dropZone - String
      shadowDomDropZone - String
    • removeDropZone

      public void removeDropZone()
      Removes the dropZone / disables uploading to it.
    • getReceiver

      public UHReceiver getReceiver()
      Return the current receiver.
      Returns:
      the StreamVariable.
    • setMaxFileSize

      public void setMaxFileSize​(int maxFileSize)
      Specify the maximum file size in bytes allowed to upload. Notice that it is a client-side constraint, which will be checked before sending the request.
      Parameters:
      maxFileSize - the maximum file size in bytes
    • getMaxFileSize

      public int getMaxFileSize()
      Get the maximum allowed file size in the client-side, in bytes.
      Returns:
      the maximum file size in bytes
    • setMaxFiles

      public void setMaxFiles​(int maxFiles)
      Limit of files to upload, by default it is 1. If the value is set to one, native file browser will prevent selecting multiple files.
      Parameters:
      maxFiles - int
    • getMaxFiles

      public int getMaxFiles()
      Returns:
      maxFiles int
    • addAllFinishedListener

      public com.vaadin.flow.shared.Registration addAllFinishedListener​(com.vaadin.flow.component.ComponentEventListener<UHAllFinishedEvent> listener)
      Add listener that is informed on the finished upload.
      Parameters:
      listener - all finished listener to add
      Returns:
      a Registration for removing the event listener
    • addProgressListener

      public com.vaadin.flow.shared.Registration addProgressListener​(com.vaadin.flow.component.ComponentEventListener<UHProgressUpdateEvent> listener)
      Add a progress listener that is informed on upload progress.
      Parameters:
      listener - progress listener to add
      Returns:
      registration for removal of listener
    • addFailedListener

      public com.vaadin.flow.shared.Registration addFailedListener​(com.vaadin.flow.component.ComponentEventListener<UHFailedEvent> listener)
      Add a succeeded listener that is informed on upload failure.
      Parameters:
      listener - failed listener to add
      Returns:
      registration for removal of listener
    • addFinishedListener

      public com.vaadin.flow.shared.Registration addFinishedListener​(com.vaadin.flow.component.ComponentEventListener<UHFinishedEvent> listener)
      Add a succeeded listener that is informed on upload finished.
      Parameters:
      listener - finished listener to add
      Returns:
      registration for removal of listener
    • addStartedListener

      public com.vaadin.flow.shared.Registration addStartedListener​(com.vaadin.flow.component.ComponentEventListener<UHStartedEvent> listener)
      Add a succeeded listener that is informed on upload start.
      Parameters:
      listener - start listener to add
      Returns:
      registration for removal of listener
    • addSucceededListener

      public com.vaadin.flow.shared.Registration addSucceededListener​(com.vaadin.flow.component.ComponentEventListener<UHSucceededEvent> listener)
      Add a succeeded listener that is informed on upload succeeded.
      Parameters:
      listener - succeeded listener to add
      Returns:
      registration for removal of listener
    • addFileRejectedListener

      public com.vaadin.flow.shared.Registration addFileRejectedListener​(com.vaadin.flow.component.ComponentEventListener<UHFileRejectedEvent> listener)
      Adds a listener for uh-file-reject events fired when a file cannot be added due to some constrains: setMaxFileSize, setAcceptedFileTypes
      Parameters:
      listener - the listener
      Returns:
      a Registration for removing the event listener
    • setVisualFeedback

      public void setVisualFeedback​(boolean visualFeedback)
      If set the false, the background color and the opacity of the dropZone Element is not changed. Else CSS Classes are added to have some kind of visual feedback.
      Parameters:
      visualFeedback - boolean
    • isVisualFeedback

      public boolean isVisualFeedback()
      Returns if visual feedback is enabled.
      Returns:
      boolean