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
Modifier and TypeClassDescriptionstatic class
JmixFileUpload.FailedEvent event is sent when the upload is received, but the reception is interrupted for some reason.static interface
Receives events when the uploads are finished, but unsuccessful.static class
static interface
Receives events when the file extension is not included ingetPermittedExtensions()
.static class
static interface
Receives events when the file size is greater thangetFileSizeLimit()
.static class
JmixFileUpload.FinishedEvent is sent when the upload receives a file, regardless of whether the reception was successful or failed.static interface
Receives the events when the uploads are ready.static class
FailedEvent that indicates that an input stream could not be obtained.static class
FailedEvent that indicates that an output stream could not be obtained.static class
JmixFileUpload.StartedEvent event is sent when the queue upload is finished.static interface
static interface
Interface that must be implemented by the upload receivers to provide the JmixFileUpload component an output stream to write the uploaded data.static class
JmixFileUpload.StartedEvent event is sent when the upload is started to received.static interface
Receives the events when the upload starts.static class
JmixFileUpload.SucceededEvent event is sent when the upload is received successfully.static interface
Receives events when the uploads are successfully finished.Nested classes/interfaces inherited from class com.vaadin.server.AbstractClientConnector
com.vaadin.server.AbstractClientConnector.IncorrectConcurrentAccessHandler
Nested 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.DetachListener
Nested 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.Listener
Nested classes/interfaces inherited from interface com.vaadin.ui.Component.HasContextHelp
com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickEvent, com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickListener
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
com.vaadin.server.Sizeable.Unit
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected boolean
protected boolean
protected JmixFileUpload.Receiver
The output of the upload is redirected to this receiver.protected com.vaadin.server.StreamVariable
Fields inherited from class com.vaadin.ui.AbstractComponent
componentErrorProvider, DESIGN_ATTR_PLAIN_TEXT, requiredError
Fields 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
void
void
void
void
changeVariables
(Object source, Map<String, Object> variables) protected void
Go into state where new uploading can begin.protected void
fireFileExtensionNotAllowed
(String fileName) protected void
fireFileSizeLimitExceeded
(String fileName) protected void
fireNoInputStream
(String fileName, String MIMEType, long length) protected void
fireNoOutputStream
(String fileName, String MIMEType, long length) protected void
protected void
fireStarted
(String fileName, String MIMEType) protected void
fireUploadInterrupted
(String fileName, String MIMEType, long length, Exception e) protected void
fireUploadSuccess
(String fileName, String MIMEType, long length) void
focus()
com.vaadin.ui.Component
double
Returns the icon's alt text.com.vaadin.ui.Component
protected JmixFileUploadState
getState()
protected JmixFileUploadState
getState
(boolean markAsDirty) protected com.vaadin.server.StreamVariable
int
protected void
Interrupts the upload currently being received.boolean
Return HTML rendering settingboolean
void
paintContent
(com.vaadin.server.PaintTarget target) void
void
void
void
void
void
void
protected void
void
Note: this is just a hint for browser, user may select files that do not meet this propertyvoid
setCancelButtonCaption
(String cancelButtonCaption) void
setDropZone
(com.vaadin.ui.Component component) void
setDropZonePrompt
(String dropZonePrompt) void
setFileSizeLimit
(long fileSizeLimit) void
setHtmlContentAllowed
(boolean htmlContentAllowed) Set whether the caption text is rendered as HTML or not.void
Sets the component's icon and alt text.void
setIconAlternateText
(String iconAltText) void
setMultiSelect
(boolean multiSelect) void
setPasteZone
(com.vaadin.ui.Component component) void
setPermittedExtensions
(Set<String> permittedExtensions) void
setProgressWindowCaption
(String progressWindowCaption) void
setReceiver
(JmixFileUpload.Receiver receiver) void
setTabIndex
(int tabIndex) void
setUnableToUploadFileMessage
(String message) protected void
protected void
Go 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, writeDesign
Methods 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, updateDiffstate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods 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, setErrorHandler
Methods 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, writeDesign
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
Methods inherited from interface com.vaadin.ui.LegacyComponent
markAsDirty
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
Methods inherited from interface io.jmix.ui.widget.UploadComponent
setDescription
Methods 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:
getState
in classcom.vaadin.ui.AbstractComponent
-
getState
- Overrides:
getState
in classcom.vaadin.ui.AbstractComponent
-
getTabIndex
public int getTabIndex()- Specified by:
getTabIndex
in interfacecom.vaadin.ui.Component.Focusable
-
setTabIndex
public void setTabIndex(int tabIndex) - Specified by:
setTabIndex
in 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:
true
if the caption text is to be rendered as HTML,false
otherwise
-
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
-true
if caption is rendered as HTML,false
otherwise
-
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:
getAccept
in interfaceUploadComponent
-
setAccept
Note: this is just a hint for browser, user may select files that do not meet this property- Specified by:
setAccept
in 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:
paintContent
in interfacecom.vaadin.ui.LegacyComponent
- Throws:
com.vaadin.server.PaintException
-
changeVariables
- Specified by:
changeVariables
in 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:
focus
in interfacecom.vaadin.ui.Component.Focusable
- Overrides:
focus
in classcom.vaadin.ui.AbstractComponent
-