Package io.jmix.ui.widget
Class JmixFileUpload
java.lang.Object
com.vaadin.server.AbstractClientConnector
com.vaadin.ui.AbstractComponent
io.jmix.ui.widget.JmixFileUpload
- All Implemented Interfaces:
com.vaadin.event.ConnectorEventListener,com.vaadin.event.ContextClickEvent.ContextClickNotifier,com.vaadin.event.MethodEventSource,com.vaadin.event.SerializableEventListener,com.vaadin.server.ClientConnector,com.vaadin.server.Sizeable,com.vaadin.server.VariableOwner,com.vaadin.shared.Connector,com.vaadin.ui.Component,com.vaadin.ui.Component.Focusable,com.vaadin.ui.Component.HasContextHelp,com.vaadin.ui.LegacyComponent,UploadComponent,Serializable,EventListener
public class JmixFileUpload
extends com.vaadin.ui.AbstractComponent
implements com.vaadin.ui.Component.Focusable, UploadComponent, com.vaadin.ui.LegacyComponent
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classJmixFileUpload.FailedEvent event is sent when the upload is received, but the reception is interrupted for some reason.static interfaceReceives events when the uploads are finished, but unsuccessful.static classstatic interfaceReceives events when the file extension is not included ingetPermittedExtensions().static classstatic interfaceReceives events when the file size is greater thangetFileSizeLimit().static classJmixFileUpload.FinishedEvent is sent when the upload receives a file, regardless of whether the reception was successful or failed.static interfaceReceives the events when the uploads are ready.static classFailedEvent that indicates that an input stream could not be obtained.static classFailedEvent that indicates that an output stream could not be obtained.static classJmixFileUpload.StartedEvent event is sent when the queue upload is finished.static interfacestatic interfaceInterface that must be implemented by the upload receivers to provide the JmixFileUpload component an output stream to write the uploaded data.static classJmixFileUpload.StartedEvent event is sent when the upload is started to received.static interfaceReceives the events when the upload starts.static classJmixFileUpload.SucceededEvent event is sent when the upload is received successfully.static interfaceReceives events when the uploads are successfully finished.Nested classes/interfaces inherited from class com.vaadin.server.AbstractClientConnector
com.vaadin.server.AbstractClientConnector.IncorrectConcurrentAccessHandlerNested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListenerNested classes/interfaces inherited from interface com.vaadin.ui.Component
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.HasContextHelp, com.vaadin.ui.Component.ListenerNested classes/interfaces inherited from interface com.vaadin.ui.Component.HasContextHelp
com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickEvent, com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickListenerNested classes/interfaces inherited from interface com.vaadin.server.Sizeable
com.vaadin.server.Sizeable.Unit -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected booleanprotected booleanprotected JmixFileUpload.ReceiverThe output of the upload is redirected to this receiver.protected com.vaadin.server.StreamVariableFields inherited from class com.vaadin.ui.AbstractComponent
componentErrorProvider, DESIGN_ATTR_PLAIN_TEXT, requiredErrorFields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidvoidvoidvoidchangeVariables(Object source, Map<String, Object> variables) protected voidGo into state where new uploading can begin.protected voidfireFileExtensionNotAllowed(String fileName) protected voidfireFileSizeLimitExceeded(String fileName) protected voidfireNoInputStream(String fileName, String MIMEType, long length) protected voidfireNoOutputStream(String fileName, String MIMEType, long length) protected voidprotected voidfireStarted(String fileName, String MIMEType) protected voidfireUploadInterrupted(String fileName, String MIMEType, long length, Exception e) protected voidfireUploadSuccess(String fileName, String MIMEType, long length) voidfocus()com.vaadin.ui.ComponentdoubleReturns the icon's alt text.com.vaadin.ui.Componentprotected JmixFileUploadStategetState()protected JmixFileUploadStategetState(boolean markAsDirty) protected com.vaadin.server.StreamVariableintprotected voidInterrupts the upload currently being received.booleanReturn HTML rendering settingbooleanvoidpaintContent(com.vaadin.server.PaintTarget target) voidvoidvoidvoidvoidvoidvoidprotected voidvoidNote: this is just a hint for browser, user may select files that do not meet this propertyvoidsetCancelButtonCaption(String cancelButtonCaption) voidsetDropZone(com.vaadin.ui.Component component) voidsetDropZonePrompt(String dropZonePrompt) voidsetFileSizeLimit(long fileSizeLimit) voidsetHtmlContentAllowed(boolean htmlContentAllowed) Set whether the caption text is rendered as HTML or not.voidSets the component's icon and alt text.voidsetIconAlternateText(String iconAltText) voidsetMultiSelect(boolean multiSelect) voidsetPasteZone(com.vaadin.ui.Component component) voidsetPermittedExtensions(Set<String> permittedExtensions) voidsetProgressWindowCaption(String progressWindowCaption) voidsetReceiver(JmixFileUpload.Receiver receiver) voidsetTabIndex(int tabIndex) voidsetUnableToUploadFileMessage(String message) protected voidprotected voidGo into upload state.Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addContextHelpIconClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, ensureContextHelpInitialized, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireContextHelpClick, getActionManager, getCaption, getComponentError, getComponentErrorProvider, getContextHelpText, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getJTestId, getLocale, getParent, getPrimaryStyleName, getRequiredError, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isContextHelpTextHtmlEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, readDesign, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setComponentErrorProvider, setContextHelpText, setContextHelpTextHtmlEnabled, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setJTestId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredError, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefined, writeDesignMethods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getIncorrectConcurrentAccessHandler, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setConnectorResource, setErrorHandler, setIncorrectConcurrentAccessHandler, setResource, updateDiffstateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlerMethods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getJTestId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setJTestId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesignMethods inherited from interface com.vaadin.shared.Connector
getConnectorIdMethods inherited from interface com.vaadin.ui.LegacyComponent
markAsDirtyMethods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefinedMethods inherited from interface io.jmix.ui.widget.UploadComponent
setDescriptionMethods inherited from interface com.vaadin.server.VariableOwner
isEnabled
-
Field Details
-
receiver
The output of the upload is redirected to this receiver. -
isUploading
protected boolean isUploading -
contentLength
protected long contentLength -
mimeTypes
-
interrupted
protected boolean interrupted -
streamVariable
protected com.vaadin.server.StreamVariable streamVariable
-
-
Constructor Details
-
JmixFileUpload
public JmixFileUpload()
-
-
Method Details
-
setUploadingErrorHandler
protected void setUploadingErrorHandler() -
resetUploadingErrorHandler
protected void resetUploadingErrorHandler() -
getState
- Overrides:
getStatein classcom.vaadin.ui.AbstractComponent
-
getState
- Overrides:
getStatein classcom.vaadin.ui.AbstractComponent
-
getTabIndex
public int getTabIndex()- Specified by:
getTabIndexin interfacecom.vaadin.ui.Component.Focusable
-
setTabIndex
public void setTabIndex(int tabIndex) - Specified by:
setTabIndexin interfacecom.vaadin.ui.Component.Focusable
-
getIconAlternateText
Returns the icon's alt text.- Returns:
- String with the alt text
-
setIconAlternateText
-
isHtmlContentAllowed
public boolean isHtmlContentAllowed()Return HTML rendering setting- Returns:
trueif the caption text is to be rendered as HTML,falseotherwise
-
setHtmlContentAllowed
public void setHtmlContentAllowed(boolean htmlContentAllowed) Set whether the caption text is rendered as HTML or not. You might need to re-theme button to allow higher content than the original text style.If set to true, the captions are passed to the browser as html and the developer is responsible for ensuring no harmful html is used. If set to false, the content is passed to the browser as plain text.
- Parameters:
htmlContentAllowed-trueif caption is rendered as HTML,falseotherwise
-
setIcon
Sets the component's icon and alt text.An alt text is shown when an image could not be loaded, and read by assistive devices.
- Parameters:
icon- the icon to be shown with the component's caption.iconAltText- String to use as alt text
-
isMultiSelect
public boolean isMultiSelect() -
setMultiSelect
public void setMultiSelect(boolean multiSelect) -
getUnableToUploadFileMessage
-
setUnableToUploadFileMessage
-
getProgressWindowCaption
-
setProgressWindowCaption
-
getCancelButtonCaption
-
setCancelButtonCaption
-
getAccept
- Specified by:
getAcceptin interfaceUploadComponent
-
setAccept
Note: this is just a hint for browser, user may select files that do not meet this property- Specified by:
setAcceptin interfaceUploadComponent- Parameters:
accept- mime types, comma separated
-
getPermittedExtensions
-
setPermittedExtensions
-
getFileSizeLimit
public double getFileSizeLimit() -
setFileSizeLimit
public void setFileSizeLimit(long fileSizeLimit) - Parameters:
fileSizeLimit- file size limit in bytes
-
getReceiver
-
setReceiver
-
getDropZone
@Nullable public com.vaadin.ui.Component getDropZone() -
setDropZone
public void setDropZone(@Nullable com.vaadin.ui.Component component) -
setPasteZone
public void setPasteZone(@Nullable com.vaadin.ui.Component component) -
getPasteZone
@Nullable public com.vaadin.ui.Component getPasteZone() -
getDropZonePrompt
-
setDropZonePrompt
-
getStreamVariable
protected com.vaadin.server.StreamVariable getStreamVariable() -
startUpload
protected void startUpload()Go into upload state. This is to prevent double uploading on same component.Warning: this is an internal method used by the framework and should not be used by user of the Upload component. Using it results in the Upload component going in wrong state and not working. It is currently public because it is used by another class.
-
interruptUpload
protected void interruptUpload()Interrupts the upload currently being received. The interruption will be done by the receiving thread so this method will return immediately and the actual interrupt will happen a bit later. -
endUpload
protected void endUpload()Go into state where new uploading can begin.Warning: this is an internal method used by the framework and should not be used by user of the Upload component.
-
paintContent
public void paintContent(com.vaadin.server.PaintTarget target) throws com.vaadin.server.PaintException - Specified by:
paintContentin interfacecom.vaadin.ui.LegacyComponent- Throws:
com.vaadin.server.PaintException
-
changeVariables
- Specified by:
changeVariablesin interfacecom.vaadin.server.VariableOwner
-
fireStarted
-
fireNoInputStream
-
fireNoOutputStream
-
fireUploadInterrupted
-
fireUploadSuccess
-
fireFileSizeLimitExceeded
-
fireFileExtensionNotAllowed
-
fireQueueUploadFinished
protected void fireQueueUploadFinished() -
addStartedListener
-
removeStartedListener
-
addFinishedListener
-
removeFinishedListener
-
addFailedListener
-
removeFailedListener
-
addSucceededListener
-
removeSucceededListener
-
addFileSizeLimitExceededListener
-
addFileExtensionNotAllowedListener
public void addFileExtensionNotAllowedListener(JmixFileUpload.FileExtensionNotAllowedListener listener) -
removeFileExtensionNotAllowedListener
public void removeFileExtensionNotAllowedListener(JmixFileUpload.FileExtensionNotAllowedListener listener) -
removeFileSizeLimitExceededListener
public void removeFileSizeLimitExceededListener(JmixFileUpload.FileSizeLimitExceededListener listener) -
addQueueUploadFinishedListener
-
removeQueueUploadFinishedListener
-
focus
public void focus()- Specified by:
focusin interfacecom.vaadin.ui.Component.Focusable- Overrides:
focusin classcom.vaadin.ui.AbstractComponent
-