com.itmill.toolkit.ui
Class Upload

java.lang.Object
  extended by com.itmill.toolkit.terminal.Identifiable
      extended by com.itmill.toolkit.ui.AbstractComponent
          extended by com.itmill.toolkit.ui.Upload
All Implemented Interfaces:
MethodEventSource, Paintable, VariableOwner, Component, Component.Focusable, EventListener

public class Upload
extends AbstractComponent
implements Component.Focusable

Component for client file uploading.

Since:
3.0
Version:
4.1.4
Author:
IT Mill Ltd.

Nested Class Summary
 class Upload.FailedEvent
          Upload.Interrupted event is sent when the upload is received, but the reception is interrupted for some reason.
static interface Upload.FailedListener
          Receives events when the uploads are finished, but unsuccessful.
 class Upload.FinishedEvent
          Upload.Received event is sent when the upload receives a file, regardless if the receival was successfull.
static interface Upload.FinishedListener
          Receives the events when the uploads are ready.
static interface Upload.Receiver
          Interface that must be implemented by the upload receivers.
 class Upload.SucceededEvent
          Upload.Success event is sent when the upload is received successfully.
static interface Upload.SucceededListener
          Receives events when the uploads are successfully finished.
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Constructor Summary
Upload(String caption, Upload.Receiver uploadReceiver)
          Creates a new instance of Upload that redirects the uploaded data to given stream.
 
Method Summary
 void addListener(Upload.FailedListener listener)
          Adds the upload interrupted event listener.
 void addListener(Upload.FinishedListener listener)
          Adds the upload received event listener.
 void addListener(Upload.SucceededListener listener)
          Adds the upload success event listener.
 void changeVariables(Object source, Map variables)
          Invoked when the value of a variable has changed.
protected  void fireUploadInterrupted(String filename, String MIMEType, long length)
          Emits the upload interrupted event.
protected  void fireUploadReceived(String filename, String MIMEType, long length)
          Emit upload received event.
protected  void fireUploadSuccess(String filename, String MIMEType, long length)
          Emits the upload success event.
 void focus()
          Sets the focus to this component.
 long getFocusableId()
          Gets the unique ID of focusable.
 Upload.Receiver getReceiver()
          Returns the current receiver.
 int getTabIndex()
          Gets the Tabulator index of this Focusable component.
 String getTag()
          Gets the component type.
 void paintContent(PaintTarget target)
          Paints the content of this component.
 void removeListener(Upload.FailedListener listener)
          Removes the upload interrupted event listener.
 void removeListener(Upload.FinishedListener listener)
          Removes the upload received event listener.
 void removeListener(Upload.SucceededListener listener)
          Removes the upload success event listener.
 void setReceiver(Upload.Receiver receiver)
          Sets the receiver.
 void setTabIndex(int tabIndex)
          Deprecated. Use setTabIndexes()
 int setTabIndexes(int startingIndex)
          Sets the Tabulator indexes for all of the focusable fields within this component, and returns the next available Tabulator index.
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponent
addListener, addListener, addListener, addListener, attach, childRequestedRepaint, dependsOn, detach, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDescription, getDirectDependencies, getErrorMessage, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isReadOnly, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDescription, setEnabled, setIcon, setImmediate, setLocale, setParent, setReadOnly, setStyle, setVisible
 
Methods inherited from class com.itmill.toolkit.terminal.Identifiable
getDebugId, getUIID, setDebugId, setUIID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Upload

public Upload(String caption,
              Upload.Receiver uploadReceiver)
Creates a new instance of Upload that redirects the uploaded data to given stream.

Parameters:
caption -
uploadReceiver -
Method Detail

getTag

public String getTag()
Gets the component type.

Specified by:
getTag in class AbstractComponent
Returns:
Component type as string.

changeVariables

public void changeVariables(Object source,
                            Map variables)
Invoked when the value of a variable has changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class AbstractComponent
Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.
See Also:
AbstractComponent.changeVariables(java.lang.Object, java.util.Map)

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paints the content of this component.

Overrides:
paintContent in class AbstractComponent
Parameters:
target - Target to paint the content on.
Throws:
PaintException - if the paint operation failed.

addListener

public void addListener(Upload.FinishedListener listener)
Adds the upload received event listener.

Parameters:
listener - the Listener to be added.

removeListener

public void removeListener(Upload.FinishedListener listener)
Removes the upload received event listener.

Parameters:
listener - the Listener to be removed.

addListener

public void addListener(Upload.FailedListener listener)
Adds the upload interrupted event listener.

Parameters:
listener - the Listener to be added.

removeListener

public void removeListener(Upload.FailedListener listener)
Removes the upload interrupted event listener.

Parameters:
listener - the Listener to be removed.

addListener

public void addListener(Upload.SucceededListener listener)
Adds the upload success event listener.

Parameters:
listener - the Listener to be added.

removeListener

public void removeListener(Upload.SucceededListener listener)
Removes the upload success event listener.

Parameters:
listener - the Listener to be removed.

fireUploadReceived

protected void fireUploadReceived(String filename,
                                  String MIMEType,
                                  long length)
Emit upload received event.

Parameters:
filename -
MIMEType -
length -

fireUploadInterrupted

protected void fireUploadInterrupted(String filename,
                                     String MIMEType,
                                     long length)
Emits the upload interrupted event.

Parameters:
filename -
MIMEType -
length -

fireUploadSuccess

protected void fireUploadSuccess(String filename,
                                 String MIMEType,
                                 long length)
Emits the upload success event.

Parameters:
filename -
MIMEType -
length -

getReceiver

public Upload.Receiver getReceiver()
Returns the current receiver.

Returns:
the Receiver.

setReceiver

public void setReceiver(Upload.Receiver receiver)
Sets the receiver.

Parameters:
receiver - the receiver to set.

focus

public void focus()
Sets the focus to this component.

Specified by:
focus in interface Component.Focusable
See Also:
Component.Focusable.focus()

getTabIndex

public int getTabIndex()
Gets the Tabulator index of this Focusable component.

Specified by:
getTabIndex in interface Component.Focusable
Returns:
the Positive tab order of this focusable. Negative of zero means unspecified tab order.
See Also:
Component.Focusable.getTabIndex()

setTabIndex

public void setTabIndex(int tabIndex)
Deprecated. Use setTabIndexes()

Sets the Tabulator index of this Focusable component.

Specified by:
setTabIndex in interface Component.Focusable
Parameters:
tabIndex - the Positive tab order of this focusable. Negative of zero means unspecified tab order.
See Also:
Component.Focusable.setTabIndex(int), com.itmill.toolkit.ui.Upload#setTabIndexes()

setTabIndexes

public int setTabIndexes(int startingIndex)
Sets the Tabulator indexes for all of the focusable fields within this component, and returns the next available Tabulator index.

Parameters:
startingIndex -
Returns:
Next available Tabulator index

getFocusableId

public long getFocusableId()
Gets the unique ID of focusable.

Specified by:
getFocusableId in interface Component.Focusable
Returns:
the Unique id of focusable.
See Also:
Component.Focusable.getFocusableId()


Copyright © 2000-2008 IT Mill Ltd. All Rights Reserved.