wjhk.jupload2.gui
Class IconWorker

java.lang.Object
  extended by wjhk.jupload2.gui.IconWorker
All Implemented Interfaces:
Runnable

 class IconWorker
extends Object
implements Runnable

The IconWorker class loads a icon from a file. It's called from a backup thread created by the JUploadFileView class. This allows to load/calculate icons in background. This prevent the applet to be freezed while icons are loading.
Instances of this class can have the following status, in this order:

  • STATUS_NOT_LOADED: This icon is not loaded, and its loading is not requested. This status is the default one, on creation.
  • STATUS_TO_BE_LOADED: This icon is on the list of icon to load. This status is written by the JUploadFileView#execute(IconWorker) method.
  • STATUS_LOADING: Indicates the IconWorker#loadIcon() has been called, but is not finished.
  • STATUS_LOADED: The icon is loaded, and ready to be displayed.
  • STATUS_ERROR_WHILE_LOADING: Too bad, the applet could not load the icon. It won't be tried again.

  • Field Summary
    (package private)  File file
              The file whose icon must be loaded.
    (package private)  JFileChooser fileChooser
              The current file chooser.
    (package private)  JUploadFileView fileView
              The current file view
    (package private)  Icon icon
              The icon for this file.
    (package private)  int status
              Current loading status for this worker
    (package private) static int STATUS_ERROR_WHILE_LOADING
              Indicates that an error occurs, during the icon creation
    (package private) static int STATUS_LOADED
              Indicates that the icon for this file has been loaded
    (package private) static int STATUS_LOADING
              Indicated that the creation of the icon for this file has started.
    (package private) static int STATUS_NOT_LOADED
              Indicates the loading of the icon for this file is not currently requested.
    (package private) static int STATUS_TO_BE_LOADED
              Indicates the loading of the icon for this file has been requested, but has not started yet.
    (package private)  UploadPolicy uploadPolicy
              The current upload policy
     
    Constructor Summary
    IconWorker(UploadPolicy uploadPolicy, JFileChooser fileChooser, JUploadFileView fileView, File file)
              The constructor only stores the file.
     
    Method Summary
    (package private)  Icon getIcon()
              Returns the currently loaded icon for this file.
    (package private)  void loadIcon()
              Get the icon from the current upload policy, for this file.
     void run()
              Implementation of the Runnable interface
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    STATUS_ERROR_WHILE_LOADING

    static final int STATUS_ERROR_WHILE_LOADING
    Indicates that an error occurs, during the icon creation

    See Also:
    Constant Field Values

    STATUS_LOADED

    static final int STATUS_LOADED
    Indicates that the icon for this file has been loaded

    See Also:
    Constant Field Values

    STATUS_LOADING

    static final int STATUS_LOADING
    Indicated that the creation of the icon for this file has started. But it is not ready yet.

    See Also:
    Constant Field Values

    STATUS_TO_BE_LOADED

    static final int STATUS_TO_BE_LOADED
    Indicates the loading of the icon for this file has been requested, but has not started yet.

    See Also:
    Constant Field Values

    STATUS_NOT_LOADED

    static final int STATUS_NOT_LOADED
    Indicates the loading of the icon for this file is not currently requested. The loading may have been requested, then cancelled, for instance of the user changes the current directory or closes the file chooser.

    See Also:
    Constant Field Values

    uploadPolicy

    UploadPolicy uploadPolicy
    The current upload policy


    fileChooser

    JFileChooser fileChooser
    The current file chooser.


    fileView

    JUploadFileView fileView
    The current file view


    file

    File file
    The file whose icon must be loaded.


    icon

    Icon icon
    The icon for this file.


    status

    int status
    Current loading status for this worker

    Constructor Detail

    IconWorker

    IconWorker(UploadPolicy uploadPolicy,
               JFileChooser fileChooser,
               JUploadFileView fileView,
               File file)
    The constructor only stores the file. The background thread will call the loadIcon method.

    Parameters:
    file - The file whose icon must be loaded/calculated.
    Method Detail

    getIcon

    Icon getIcon()
    Returns the currently loaded icon for this file.

    Returns:
    The Icon to be displayed for this file.

    loadIcon

    void loadIcon()
    Get the icon from the current upload policy, for this file. This methods does something only if the current status for the icon is STATUS_TO_BE_LOADED. If not, this method does nothing.


    run

    public void run()
    Implementation of the Runnable interface

    Specified by:
    run in interface Runnable