de.schlichtherle.io.swing
Class FileSystemView

java.lang.Object
  extended by javax.swing.filechooser.FileSystemView
      extended by de.schlichtherle.io.swing.FileSystemView

public class FileSystemView
extends FileSystemView

A custom file system view required to browse archive files like (virtual) directories with a JFileChooser. This class is also used by FileTreeCellRenderer to render files and directories in a JFileTree.

Version:
TrueZIP 6.7
Author:
Christian Schlichtherle

Method Summary
 File createFileObject(File file)
          Creates a ZIP enabled file where necessary only, otherwise the blueprint is simply returned.
 File createFileObject(File dir, String str)
          Creates a ZIP enabled file where necessary only, otherwise the file system view delegate is used to create the file.
 File createFileObject(String str)
          Creates a ZIP enabled file where necessary only, otherwise the file system view delegate is used to create the file.
protected  File createFileSystemRoot(File f)
          Forwards the call to createFileSystemRootImpl(java.io.File).
 File createFileSystemRootImpl(File f)
          Creates a new File object for f with correct behavior for a file system root directory.
 File createNewFolder(File parent)
           
 ArchiveDetector getArchiveDetector()
          Returns a valid archive detector to use with this class.
 File getChild(File parent, String child)
           
 File getDefaultDirectory()
           
 FileSystemView getDelegate()
          Returns the file system view to be decorated - never null.
 File[] getFiles(File dir, boolean useFileHiding)
           
static FileSystemView getFileSystemView()
           
static FileSystemView getFileSystemView(ArchiveDetector archiveDetector)
           
 File getHomeDirectory()
           
 File getParentDirectory(File file)
           
 File[] getRoots()
           
 String getSystemDisplayName(File file)
           
 Icon getSystemIcon(File file)
           
 String getSystemTypeDescription(File file)
           
 boolean isComputerNode(File file)
           
 boolean isDrive(File file)
           
 boolean isFileSystem(File file)
           
 boolean isFileSystemRoot(File file)
           
 boolean isFloppyDrive(File file)
           
 boolean isHiddenFile(File file)
           
 boolean isParent(File folder, File file)
           
 boolean isRoot(File file)
           
 Boolean isTraversable(File file)
           
 void setArchiveDetector(ArchiveDetector archiveDetector)
          Sets the archive detector to use within this class.
 void setDelegate(FileSystemView delegate)
          Sets the file system view to be decorated.
protected  File unwrap(File file)
          Unwraps the delegate of a possibly archive enabled file.
protected  File wrap(File file)
          Wraps the given file in an archive enabled file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFileSystemView

public static final FileSystemView getFileSystemView()

getFileSystemView

public static final FileSystemView getFileSystemView(ArchiveDetector archiveDetector)

getArchiveDetector

public ArchiveDetector getArchiveDetector()
Returns a valid archive detector to use with this class. If no archive detector has been explicitly set for this file system view or the archive detector has been set to null, then File.getDefaultArchiveDetector() is returned.


setArchiveDetector

public void setArchiveDetector(ArchiveDetector archiveDetector)
Sets the archive detector to use within this class.

Parameters:
archiveDetector - The archive detector to use. May be null to indicate that File.getDefaultArchiveDetector() should be used.

wrap

protected File wrap(File file)
Wraps the given file in an archive enabled file.


unwrap

protected File unwrap(File file)
Unwraps the delegate of a possibly archive enabled file.


createFileObject

public File createFileObject(File file)
Creates a ZIP enabled file where necessary only, otherwise the blueprint is simply returned.


isRoot

public boolean isRoot(File file)

isTraversable

public Boolean isTraversable(File file)

getSystemDisplayName

public String getSystemDisplayName(File file)

getSystemTypeDescription

public String getSystemTypeDescription(File file)

getSystemIcon

public Icon getSystemIcon(File file)

isParent

public boolean isParent(File folder,
                        File file)

getChild

public File getChild(File parent,
                     String child)

isFileSystem

public boolean isFileSystem(File file)

createNewFolder

public File createNewFolder(File parent)
                     throws IOException
Throws:
IOException

isHiddenFile

public boolean isHiddenFile(File file)

isFileSystemRoot

public boolean isFileSystemRoot(File file)

isDrive

public boolean isDrive(File file)

isFloppyDrive

public boolean isFloppyDrive(File file)

isComputerNode

public boolean isComputerNode(File file)

createFileObject

public File createFileObject(File dir,
                             String str)
Creates a ZIP enabled file where necessary only, otherwise the file system view delegate is used to create the file.


createFileObject

public File createFileObject(String str)
Creates a ZIP enabled file where necessary only, otherwise the file system view delegate is used to create the file.


getFiles

public File[] getFiles(File dir,
                       boolean useFileHiding)

getParentDirectory

public File getParentDirectory(File file)

getDelegate

public FileSystemView getDelegate()
Returns the file system view to be decorated - never null.


setDelegate

public void setDelegate(FileSystemView delegate)
Sets the file system view to be decorated.

Throws:
NullPointerException - If delegate is null.
IllegalArgumentException - If delegate is this instance.

getRoots

public File[] getRoots()
Overrides:
getRoots in class FileSystemView

getHomeDirectory

public File getHomeDirectory()
Overrides:
getHomeDirectory in class FileSystemView

getDefaultDirectory

public File getDefaultDirectory()
Overrides:
getDefaultDirectory in class FileSystemView

createFileSystemRoot

protected final File createFileSystemRoot(File f)
Forwards the call to createFileSystemRootImpl(java.io.File).

Overrides:
createFileSystemRoot in class FileSystemView

createFileSystemRootImpl

public File createFileSystemRootImpl(File f)
Creates a new File object for f with correct behavior for a file system root directory. If the delegate is an instance of this class, then this method forwards the call to the delegate like all other methods in this class. Otherwise, the super class implementation of the method FileSystemView.createFileSystemRoot(java.io.File) is called.