wjhk.jupload2.gui
Class JUploadFileView

java.lang.Object
  extended by javax.swing.filechooser.FileView
      extended by wjhk.jupload2.gui.JUploadFileView
All Implemented Interfaces:
PropertyChangeListener, ThreadFactory, EventListener

public class JUploadFileView
extends FileView
implements PropertyChangeListener, ThreadFactory

This class provides the icon view for the file selector.

Author:
etienne_sf

Field Summary
static ImageIcon emptyIcon
          An empty icon, having the good file size.
(package private)  ExecutorService executorService
          This executor will crate icons from files, one at a time.
(package private)  JFileChooser fileChooser
          The current file chooser.
(package private)  ConcurrentHashMap<String,IconWorker> hashMap
          This map will contain all instances of IconWorker.
(package private)  ThreadGroup iconWorkerThreadGroup
          This thread group is used to contain all icon worker threads.
(package private)  UploadPolicy uploadPolicy
          The current upload policy.
 
Constructor Summary
JUploadFileView(UploadPolicy uploadPolicy, JFileChooser fileChooser)
          Creates a new instance.
 
Method Summary
(package private)  void execute(IconWorker iconWorker)
           
 String getDescription(File f)
          #see javax.swing.filechooser.FileView#getDescription(File))
 Icon getIcon(File file)
          The fileChooserIconFromFileContent applet parameter defies which icon is to be returned here.
 String getName(File f)
          #see FileView.getName(File)
 String getTypeDescription(File f)
          #see FileView.getTypeDescription(File)
 Boolean isTraversable(File f)
          #see FileView.isTraversable(File)
 Thread newThread(Runnable runnable)
          Implementation of ThreadFactory.
 void propertyChange(PropertyChangeEvent e)
          Waiting for JFileChooser events.
 void shutdownNow()
          Stop all current and to come thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iconWorkerThreadGroup

ThreadGroup iconWorkerThreadGroup
This thread group is used to contain all icon worker threads. Its priority is the MIN_PRIORITY, to try to minimize CPU footprint. Its thread max priority is set in the JUploadFileView(UploadPolicy, JFileChooser) constructor.


uploadPolicy

UploadPolicy uploadPolicy
The current upload policy.


fileChooser

JFileChooser fileChooser
The current file chooser.


hashMap

ConcurrentHashMap<String,IconWorker> hashMap
This map will contain all instances of IconWorker.


executorService

ExecutorService executorService
This executor will crate icons from files, one at a time. It is used to create these icon asynchronously.

See Also:
execute(IconWorker)

emptyIcon

public static ImageIcon emptyIcon
An empty icon, having the good file size.

Constructor Detail

JUploadFileView

public JUploadFileView(UploadPolicy uploadPolicy,
                       JFileChooser fileChooser)
Creates a new instance.

Parameters:
uploadPolicy - The upload policy to apply.
fileChooser - The desired file chooser to use.
Method Detail

execute

void execute(IconWorker iconWorker)

shutdownNow

public void shutdownNow()
Stop all current and to come thread. To be called when the file chooser is closed.


propertyChange

public void propertyChange(PropertyChangeEvent e)
Waiting for JFileChooser events. Currently managed: DIRECTORY_CHANGED_PROPERTY, to stop the to be loaded icons.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
e -

getDescription

public String getDescription(File f)
#see javax.swing.filechooser.FileView#getDescription(File))

Overrides:
getDescription in class FileView

getIcon

public Icon getIcon(File file)
The fileChooserIconFromFileContent applet parameter defies which icon is to be returned here.

Overrides:
getIcon in class FileView
See Also:
FileView.getIcon(java.io.File), UploadPolicy.PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT

getName

public String getName(File f)
#see FileView.getName(File)

Overrides:
getName in class FileView

getTypeDescription

public String getTypeDescription(File f)
#see FileView.getTypeDescription(File)

Overrides:
getTypeDescription in class FileView

isTraversable

public Boolean isTraversable(File f)
#see FileView.isTraversable(File)

Overrides:
isTraversable in class FileView

newThread

public Thread newThread(Runnable runnable)
Implementation of ThreadFactory. Creates a thread in the iconWorkerThreadGroup thread group. This thread group has the lower available priority.

Specified by:
newThread in interface ThreadFactory
Parameters:
runnable - The runnable instance to start.
Returns:
The newly created thread