info.magnolia.ui.form.field.upload.basic
Class BasicUploadField<D extends BasicFileItemWrapper>

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractField<T>
              extended by com.vaadin.ui.CustomField<Byte[]>
                  extended by info.magnolia.ui.form.field.upload.AbstractUploadField<D>
                      extended by info.magnolia.ui.form.field.upload.basic.BasicUploadField<D>
Type Parameters:
D - FileItemWrapper implemented class.
All Implemented Interfaces:
com.vaadin.data.Buffered, com.vaadin.data.BufferedValidatable, com.vaadin.data.Property<Byte[]>, com.vaadin.data.Property.Editor, com.vaadin.data.Property.ReadOnlyStatusChangeListener, com.vaadin.data.Property.ReadOnlyStatusChangeNotifier, com.vaadin.data.Property.ValueChangeListener, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.data.Property.Viewer, com.vaadin.data.Validatable, com.vaadin.event.Action.ShortcutNotifier, com.vaadin.event.dd.DropHandler, com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Sizeable, com.vaadin.shared.Connector, com.vaadin.ui.Component, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Field<Byte[]>, com.vaadin.ui.HasComponents, com.vaadin.ui.Upload.FailedListener, com.vaadin.ui.Upload.FinishedListener, com.vaadin.ui.Upload.ProgressListener, com.vaadin.ui.Upload.StartedListener, UploadField, Serializable, Iterable<com.vaadin.ui.Component>

public class BasicUploadField<D extends BasicFileItemWrapper>
extends AbstractUploadField<D>

Basic implementation of AbstractUploadField.
Define the Layout components for

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class info.magnolia.ui.form.field.upload.AbstractUploadField
AbstractUploadField.InterruptionReason
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField
com.vaadin.ui.AbstractField.FocusShortcut, com.vaadin.ui.AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener
 
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.Listener
 
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.server.Sizeable
com.vaadin.server.Sizeable.Unit
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
com.vaadin.ui.Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
com.vaadin.data.Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
com.vaadin.data.Property.Editor, com.vaadin.data.Property.ReadOnlyException, com.vaadin.data.Property.ReadOnlyStatusChangeListener, com.vaadin.data.Property.ReadOnlyStatusChangeNotifier, com.vaadin.data.Property.Transactional<T>, com.vaadin.data.Property.ValueChangeListener, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.data.Property.Viewer
 
Field Summary
protected  String captionExtension
          Caption section.
protected  String deleteCaption
           
protected  String dropZoneCaption
           
protected  String errorNoteCaption
           
protected  String fileDetailFormatCaption
           
protected  String fileDetailHeaderCaption
           
protected  String fileDetailNameCaption
           
protected  String fileDetailSizeCaption
           
protected  String fileDetailSourceCaption
           
protected  ImageProvider imageProvider
           
protected  String inProgressCaption
           
protected  String inProgressRatioCaption
           
protected  String selectAnotherCaption
           
protected  String selectNewCaption
           
protected  String successNoteCaption
           
protected  UiContext uiContext
           
protected  String warningNoteCaption
           
 
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
BasicUploadField(D fileWrapper, File tmpUploadDirectory, ImageProvider imageProvider, UiContext uiContext, BasicUploadFieldDefinition definition, info.magnolia.i18nsystem.SimpleTranslator i18n)
           
 
Method Summary
 void attach()
          Initialize the root component.
protected  void buildCompletedLayout()
          Main entry point to create the Completed Layout.
protected  void buildEmptyLayout()
          Main entry point to create the Empty Layout.
protected  void buildInProgressLayout(String uploadedFileMimeType)
          Main entry point to create the In Progress Layout.
protected  com.vaadin.ui.Layout createCompletedActionLayout()
          Build the Completed Action Layout.
protected  com.vaadin.ui.Button createDeleteButton()
          Create Delete button.
protected  String createIconStyleName(FileItemWrapper fileWrapper)
          Create the Icon related to a File.
protected  com.vaadin.ui.Component createThumbnailComponent()
           
protected  void displayUploadFailedNote(String fileName)
           
protected  void displayUploadFinishedNote(String fileName)
           
protected  void displayUploadInterruptNote(AbstractUploadField.InterruptionReason reason)
           
protected  String getCaption(String caption, String[] args)
           
 com.vaadin.ui.CssLayout getCssLayout()
          For test cases.
protected  com.vaadin.ui.Component getFileDetailFileFormat()
          Add File Format.
If editFileFormat is true, display an Input Text Field.
protected  com.vaadin.ui.Component getFileDetailFileName()
          Add File Name.
If editFileName is true, display an Input Text Field.
protected  com.vaadin.ui.Component getFileDetailHeader()
          Add Title.
protected  com.vaadin.ui.Component getFileDetailSize()
          Add File Info.
protected  com.vaadin.ui.Component initContent()
           
protected  boolean isEmpty()
           
protected  void populateFromDefinition(BasicUploadFieldDefinition definition)
          Configure Field based on the definition.
protected  void refreshInProgressLayout(long readBytes, long contentLength, String fileName)
          Update the in Progress Layout.
protected  void setCaptionExtension(String mimeType)
           
 void setDeteteCaption(String deleteCaption)
           
 void setDropZoneCaption(String dropZoneCaption)
           
 void setEditFileFormat(boolean editFileFormat)
           
 void setEditFileName(boolean editFileName)
           
 void setErrorNoteCaption(String errorNoteCaption)
           
 void setFileDetailFormatCaption(String fileDetailFormatCaption)
           
 void setFileDetailHeaderCaption(String fileDetailHeaderCaption)
           
 void setFileDetailNameCaption(String fileDetailNameCaption)
           
 void setFileDetailSizeCaption(String fileDetailSizeCaption)
           
 void setFileDetailSourceCaption(String fileDetailSourceCaption)
           
 void setInProgressCaption(String inProgressCaption)
           
 void setInProgressRatioCaption(String inProgressRatioCaption)
           
 void setReadOnly(boolean readOnly)
           
 void setSelectAnotherCaption(String selectAnotherCaption)
           
 void setSelectNewCaption(String selectNewCaption)
           
 void setSizeInterruption(String sizeInterruption)
           
 void setSuccessNoteCaption(String successNoteCaption)
           
 void setTypeInterruption(String typeInterruption)
           
 void setUserInterruption(String userInterruption)
           
 void setWarningNoteCaption(String warningNoteCaption)
           
 
Methods inherited from class info.magnolia.ui.form.field.upload.AbstractUploadField
createDropZone, detach, drop, getAcceptCriterion, getDropZone, getFileWrapper, getRootLayout, getType, getUpload, interruptUpload, isValidFile, setAllowedMimeTypePattern, setMaxUploadSize, setRootLayout, updateDisplay, updateProgress, uploadFailed, uploadFinished, uploadStarted
 
Methods inherited from class com.vaadin.ui.CustomField
getContent, iterator, setHeight, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addReadOnlyStatusChangeListener, addValidator, addValueChangeListener, beforeClientResponse, commit, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getErrorMessage, getInternalValue, getModelType, getPropertyDataSource, getRequiredError, getState, getState, getTabIndex, getValidators, getValue, isBuffered, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isRequired, isValid, isValidationVisible, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setLocale, setPropertyDataSource, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, setValue, shouldHideErrors, toString, validate, validate, valueChange
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isConnectorEnabled, isEnabled, isImmediate, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setIcon, setId, setImmediate, setParent, setPrimaryStyleName, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hasListeners, isAttached, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setSizeFull, setSizeUndefined, setWidth
 
Methods inherited from interface com.vaadin.event.Action.ShortcutNotifier
addShortcutListener, removeShortcutListener
 

Field Detail

imageProvider

protected final ImageProvider imageProvider

uiContext

protected UiContext uiContext

captionExtension

protected String captionExtension
Caption section.


selectNewCaption

protected String selectNewCaption

selectAnotherCaption

protected String selectAnotherCaption

deleteCaption

protected String deleteCaption

dropZoneCaption

protected String dropZoneCaption

inProgressCaption

protected String inProgressCaption

inProgressRatioCaption

protected String inProgressRatioCaption

fileDetailHeaderCaption

protected String fileDetailHeaderCaption

fileDetailNameCaption

protected String fileDetailNameCaption

fileDetailSizeCaption

protected String fileDetailSizeCaption

fileDetailFormatCaption

protected String fileDetailFormatCaption

fileDetailSourceCaption

protected String fileDetailSourceCaption

successNoteCaption

protected String successNoteCaption

warningNoteCaption

protected String warningNoteCaption

errorNoteCaption

protected String errorNoteCaption
Constructor Detail

BasicUploadField

public BasicUploadField(D fileWrapper,
                        File tmpUploadDirectory,
                        ImageProvider imageProvider,
                        UiContext uiContext,
                        BasicUploadFieldDefinition definition,
                        info.magnolia.i18nsystem.SimpleTranslator i18n)
Method Detail

attach

public void attach()
Initialize the root component. Build the initial layout: - Empty Layout if the incoming Item is empty. - Completed Layout with the Item Informations if this Item is not empty.

Specified by:
attach in interface com.vaadin.server.ClientConnector
Specified by:
attach in interface com.vaadin.ui.Component
Overrides:
attach in class com.vaadin.ui.CustomField<Byte[]>

buildEmptyLayout

protected void buildEmptyLayout()
Main entry point to create the Empty Layout. This Basic implementation of Empty layout is composed of
- An Upload button
- A Label inviting to Drag files

Specified by:
buildEmptyLayout in class AbstractUploadField<D extends BasicFileItemWrapper>

buildInProgressLayout

protected void buildInProgressLayout(String uploadedFileMimeType)
Main entry point to create the In Progress Layout. This Basic implementation of In Progress is composed of
- A Progress Bar
- A Cancel Button

Specified by:
buildInProgressLayout in class AbstractUploadField<D extends BasicFileItemWrapper>

refreshInProgressLayout

protected void refreshInProgressLayout(long readBytes,
                                       long contentLength,
                                       String fileName)
Description copied from class: AbstractUploadField
Update the in Progress Layout.

Specified by:
refreshInProgressLayout in class AbstractUploadField<D extends BasicFileItemWrapper>

buildCompletedLayout

protected void buildCompletedLayout()
Main entry point to create the Completed Layout. This Basic implementation of Completed Layout is composed of
- An Icon representing the File type
- A Detail text information
- An Action bar: UploadNew and Delete Actions
Override
getFileInfo() In order to change the Displayed Text
createIconStyleName() In order to change the Icon Style displayed.

Specified by:
buildCompletedLayout in class AbstractUploadField<D extends BasicFileItemWrapper>

createCompletedActionLayout

protected com.vaadin.ui.Layout createCompletedActionLayout()
Build the Completed Action Layout.


createDeleteButton

protected com.vaadin.ui.Button createDeleteButton()
Create Delete button.


getFileDetailHeader

protected com.vaadin.ui.Component getFileDetailHeader()
Add Title.


getFileDetailFileName

protected com.vaadin.ui.Component getFileDetailFileName()
Add File Name.
If editFileName is true, display an Input Text Field.
Else display a simple label.


getFileDetailSize

protected com.vaadin.ui.Component getFileDetailSize()
Add File Info.


getFileDetailFileFormat

protected com.vaadin.ui.Component getFileDetailFileFormat()
Add File Format.
If editFileFormat is true, display an Input Text Field.
Else display a simple label.


createThumbnailComponent

protected com.vaadin.ui.Component createThumbnailComponent()
Returns:
Thumbnail Component.

createIconStyleName

protected String createIconStyleName(FileItemWrapper fileWrapper)
Create the Icon related to a File.
Override this method in order to change the Displayed Icon .

Parameters:
fileWrapper -
Returns:

initContent

protected com.vaadin.ui.Component initContent()
Specified by:
initContent in class com.vaadin.ui.CustomField<Byte[]>

populateFromDefinition

protected void populateFromDefinition(BasicUploadFieldDefinition definition)
Configure Field based on the definition.


setCaptionExtension

protected void setCaptionExtension(String mimeType)

getCaption

protected String getCaption(String caption,
                            String[] args)

setSelectNewCaption

public void setSelectNewCaption(String selectNewCaption)

setSelectAnotherCaption

public void setSelectAnotherCaption(String selectAnotherCaption)

setDropZoneCaption

public void setDropZoneCaption(String dropZoneCaption)

setInProgressCaption

public void setInProgressCaption(String inProgressCaption)

setInProgressRatioCaption

public void setInProgressRatioCaption(String inProgressRatioCaption)

setFileDetailHeaderCaption

public void setFileDetailHeaderCaption(String fileDetailHeaderCaption)

setFileDetailNameCaption

public void setFileDetailNameCaption(String fileDetailNameCaption)

setFileDetailSizeCaption

public void setFileDetailSizeCaption(String fileDetailSizeCaption)

setFileDetailFormatCaption

public void setFileDetailFormatCaption(String fileDetailFormatCaption)

setFileDetailSourceCaption

public void setFileDetailSourceCaption(String fileDetailSourceCaption)

setSuccessNoteCaption

public void setSuccessNoteCaption(String successNoteCaption)

setWarningNoteCaption

public void setWarningNoteCaption(String warningNoteCaption)

setErrorNoteCaption

public void setErrorNoteCaption(String errorNoteCaption)

setDeteteCaption

public void setDeteteCaption(String deleteCaption)

setSizeInterruption

public void setSizeInterruption(String sizeInterruption)

setTypeInterruption

public void setTypeInterruption(String typeInterruption)

setUserInterruption

public void setUserInterruption(String userInterruption)

displayUploadInterruptNote

protected void displayUploadInterruptNote(AbstractUploadField.InterruptionReason reason)
Specified by:
displayUploadInterruptNote in class AbstractUploadField<D extends BasicFileItemWrapper>

displayUploadFinishedNote

protected void displayUploadFinishedNote(String fileName)
Specified by:
displayUploadFinishedNote in class AbstractUploadField<D extends BasicFileItemWrapper>

displayUploadFailedNote

protected void displayUploadFailedNote(String fileName)
Specified by:
displayUploadFailedNote in class AbstractUploadField<D extends BasicFileItemWrapper>

setEditFileName

public void setEditFileName(boolean editFileName)

setEditFileFormat

public void setEditFileFormat(boolean editFileFormat)

getCssLayout

public com.vaadin.ui.CssLayout getCssLayout()
For test cases.


isEmpty

protected boolean isEmpty()
Overrides:
isEmpty in class com.vaadin.ui.AbstractField<Byte[]>

setReadOnly

public void setReadOnly(boolean readOnly)
Specified by:
setReadOnly in interface com.vaadin.data.Property<Byte[]>
Specified by:
setReadOnly in interface com.vaadin.ui.Component
Overrides:
setReadOnly in class com.vaadin.ui.AbstractField<Byte[]>


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.