puzzled.dialogs
Class PSFileView

java.lang.Object
  |
  +--javax.swing.filechooser.FileView
        |
        +--puzzled.dialogs.PSFileView

public class PSFileView
extends javax.swing.filechooser.FileView

A convenience implementation of the FileView interface that manages name, icon, traversable, and file type information. This this implemention will work well with file systems that use "dot" extensions to indicate file type. For example: "picture.gif" as a gif image. If the java.io.File ever contains some of this information, such as file type, icon, and hidden file inforation, this implementation may become obsolete. At minimum, it should be rewritten at that time to use any new type information provided by java.io.File Example: JFileChooser chooser = new JFileChooser(); fileView = new ExampleFileView(); fileView.putIcon("jpg", new ImageIcon("images/jpgIcon.jpg")); fileView.putIcon("gif", new ImageIcon("images/gifIcon.gif")); chooser.setFileView(fileView); Modified for Powerflow by Frédéric Demers & Guillaume Gilbert on 21 Nov 98

Version:
1.7 08/26/98
Author:
Jeff Dinkins

Constructor Summary
PSFileView()
           
 
Method Summary
 java.lang.String getDescription(java.io.File f)
          A human readable description of the file.
 java.lang.String getExtension(java.io.File f)
          Conveinience method that returnsa the "dot" extension for the given file.
 javax.swing.Icon getIcon(java.io.File f)
          Icon that reperesents this file.
 java.lang.String getName(java.io.File f)
          The name of the file.
 java.lang.String getTypeDescription(java.io.File f)
          A human readable description of the type of the file.
 java.lang.Boolean isHidden(java.io.File f)
          Whether the file is hidden or not.
 java.lang.Boolean isTraversable(java.io.File f)
          Whether the directory is traversable or not.
 void putDescription(java.io.File f, java.lang.String fileDescription)
          Adds a human readable description of the file.
 void putIcon(java.lang.String extension, javax.swing.Icon icon)
          Adds an icon based on the file type "dot" extension string, e.g: ".gif".
 void putTypeDescription(java.io.File f, java.lang.String typeDescription)
          Adds a human readable type description for files of the type of the passed in file.
 void putTypeDescription(java.lang.String extension, java.lang.String typeDescription)
          Adds a human readable type description for files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PSFileView

public PSFileView()
Method Detail

getName

public java.lang.String getName(java.io.File f)
The name of the file. Do nothing special here. Let the system file view handle this.
Overrides:
getName in class javax.swing.filechooser.FileView
See Also:
getName(java.io.File)

putDescription

public void putDescription(java.io.File f,
                           java.lang.String fileDescription)
Adds a human readable description of the file.

getDescription

public java.lang.String getDescription(java.io.File f)
A human readable description of the file.
Overrides:
getDescription in class javax.swing.filechooser.FileView
See Also:
getDescription(java.io.File)

putTypeDescription

public void putTypeDescription(java.lang.String extension,
                               java.lang.String typeDescription)
Adds a human readable type description for files. Based on "dot" extension strings, e.g: ".gif". Case is ignored.

putTypeDescription

public void putTypeDescription(java.io.File f,
                               java.lang.String typeDescription)
Adds a human readable type description for files of the type of the passed in file. Based on "dot" extension strings, e.g: ".gif". Case is ignored.

getTypeDescription

public java.lang.String getTypeDescription(java.io.File f)
A human readable description of the type of the file.
Overrides:
getTypeDescription in class javax.swing.filechooser.FileView
See Also:
getTypeDescription(java.io.File)

getExtension

public java.lang.String getExtension(java.io.File f)
Conveinience method that returnsa the "dot" extension for the given file.

putIcon

public void putIcon(java.lang.String extension,
                    javax.swing.Icon icon)
Adds an icon based on the file type "dot" extension string, e.g: ".gif". Case is ignored.

getIcon

public javax.swing.Icon getIcon(java.io.File f)
Icon that reperesents this file. Default implementation returns null. You might want to override this to return something more interesting.
Overrides:
getIcon in class javax.swing.filechooser.FileView
See Also:
getIcon(java.io.File)

isHidden

public java.lang.Boolean isHidden(java.io.File f)
Whether the file is hidden or not. This implementation returns true if the filename starts with a "."
See Also:
isHidden(java.io.File)

isTraversable

public java.lang.Boolean isTraversable(java.io.File f)
Whether the directory is traversable or not. Generic implementation returns true for all directories. You might want to subtype ExampleFileView to do somethimg more interesting, such as recognize compound documents directories; in such a case you might return a special icon for the diretory that makes it look like a regular document, and return false for isTraversable to not allow users to descend into the directory.
Overrides:
isTraversable in class javax.swing.filechooser.FileView
See Also:
isTraversable(java.io.File)