Class RemoteFileSystemView


  • public class RemoteFileSystemView
    extends javax.swing.filechooser.FileSystemView
    Remote file system view. Is programmed asynchronously, i.e. delivers always what it has and then initiates a background search for retrieving current values. When values arrive a refresh operation is used to update the chooser.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map children
      The cache of children files (String parent -> File[] children).
      protected javax.swing.JFileChooser chooser
      The filechooser.
      protected RemoteFile currentdir
      The current directory.
      protected RemoteFile defaultdir
      The default directory.
      protected IExternalAccess exta
      The external access.
      protected RemoteFile homedir
      The home directory.
      protected java.util.Map parents
      The cache of parent files (String child -> File[] parent).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearCache()
      Clear the cache.
      java.io.File createFileObject​(java.io.File dir, java.lang.String filename)
      Returns a File object constructed in dir from the given filename.
      java.io.File createFileObject​(java.lang.String path)
      Returns a File object constructed from the given path string.
      java.io.File createNewFolder​(java.io.File containingDir)
      Creates a new folder with a default folder name.
      java.io.File getCurrentDirectory()
      Get the current directory of the remote VM.
      java.io.File getDefaultDirectory()
      Return the user's default starting directory for the file chooser.
      java.io.File[] getFiles​(java.io.File dir, boolean useFileHiding)
      Gets the list of shown (i.e.
      java.io.File getHomeDirectory()  
      java.io.File getParentDirectory​(java.io.File dir)
      Returns the parent directory of dir.
      java.io.File[] getRoots()
      Returns all root partitions on this system.
      java.lang.String getSystemDisplayName​(java.io.File f)
      Name of a file, directory, or folder as it would be displayed in a system file browser.
      java.lang.String getSystemTypeDescription​(java.io.File f)
      Type description for a file, directory, or folder as it would be displayed in a system file browser.
      IFuture<java.lang.Void> init()
      Initialize the remote file system view such that home, default and current directory as well as roots are available.
      boolean isHiddenFile​(java.io.File f)
      Returns whether a file is hidden or not.
      boolean isParent​(java.io.File folder, java.io.File file)
      On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem.
      java.lang.Boolean isTraversable​(java.io.File f)
      Returns true if the file (directory) can be visited.
      static void main​(java.lang.String[] args)
      Main for testing.
      void setFileChooser​(javax.swing.JFileChooser chooser)
      Set the file chooser.
      • Methods inherited from class javax.swing.filechooser.FileSystemView

        createFileSystemRoot, getChild, getChooserComboBoxFiles, getFileSystemView, getLinkLocation, getSystemIcon, isComputerNode, isDrive, isFileSystem, isFileSystemRoot, isFloppyDrive, isLink, isRoot
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • children

        protected java.util.Map children
        The cache of children files (String parent -> File[] children).
      • parents

        protected java.util.Map parents
        The cache of parent files (String child -> File[] parent).
      • chooser

        protected javax.swing.JFileChooser chooser
        The filechooser.
      • homedir

        protected RemoteFile homedir
        The home directory.
      • defaultdir

        protected RemoteFile defaultdir
        The default directory.
      • currentdir

        protected RemoteFile currentdir
        The current directory.
    • Constructor Detail

      • RemoteFileSystemView

        public RemoteFileSystemView​(IExternalAccess exta)
        Create a new file system view.
    • Method Detail

      • init

        public IFuture<java.lang.Void> init()
        Initialize the remote file system view such that home, default and current directory as well as roots are available.
      • setFileChooser

        public void setFileChooser​(javax.swing.JFileChooser chooser)
        Set the file chooser.
      • isTraversable

        public java.lang.Boolean isTraversable​(java.io.File f)
        Returns true if the file (directory) can be visited. Returns false if the directory cannot be traversed.
        Overrides:
        isTraversable in class javax.swing.filechooser.FileSystemView
        Parameters:
        f - the File
        Returns:
        true if the file/directory can be traversed, otherwise false
        Since:
        1.4
        See Also:
        JFileChooser.isTraversable(java.io.File), FileView.isTraversable(java.io.File)
      • getSystemDisplayName

        public java.lang.String getSystemDisplayName​(java.io.File f)
        Name of a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "M:\" directory displays as "CD-ROM (M:)" The default implementation gets information from the ShellFolder class.
        Overrides:
        getSystemDisplayName in class javax.swing.filechooser.FileSystemView
        Parameters:
        f - a File object
        Returns:
        the file name as it would be displayed by a native file chooser
        Since:
        1.4
        See Also:
        JFileChooser.getName(java.io.File)
      • getSystemTypeDescription

        public java.lang.String getSystemTypeDescription​(java.io.File f)
        Type description for a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "Desktop" folder is desribed as "Desktop". Override for platforms with native ShellFolder implementations.
        Overrides:
        getSystemTypeDescription in class javax.swing.filechooser.FileSystemView
        Parameters:
        f - a File object
        Returns:
        the file type description as it would be displayed by a native file chooser or null if no native information is available.
        Since:
        1.4
        See Also:
        JFileChooser.getTypeDescription(java.io.File)
      • isParent

        public boolean isParent​(java.io.File folder,
                                java.io.File file)
        On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem. Folder could for example be the "Desktop" folder which is not the same as file.getParentFile().
        Overrides:
        isParent in class javax.swing.filechooser.FileSystemView
        Parameters:
        folder - a File object repesenting a directory or special folder
        file - a File object
        Returns:
        true if folder is a directory or special folder and contains file.
        Since:
        1.4
      • createNewFolder

        public java.io.File createNewFolder​(java.io.File containingDir)
                                     throws java.io.IOException
        Creates a new folder with a default folder name.
        Specified by:
        createNewFolder in class javax.swing.filechooser.FileSystemView
        Throws:
        java.io.IOException
      • isHiddenFile

        public boolean isHiddenFile​(java.io.File f)
        Returns whether a file is hidden or not.
        Overrides:
        isHiddenFile in class javax.swing.filechooser.FileSystemView
      • getRoots

        public java.io.File[] getRoots()
        Returns all root partitions on this system. For example, on Windows, this would be the "Desktop" folder, while on DOS this would be the A: through Z: drives.
        Overrides:
        getRoots in class javax.swing.filechooser.FileSystemView
      • getHomeDirectory

        public java.io.File getHomeDirectory()
        Overrides:
        getHomeDirectory in class javax.swing.filechooser.FileSystemView
      • getCurrentDirectory

        public java.io.File getCurrentDirectory()
        Get the current directory of the remote VM.
      • getDefaultDirectory

        public java.io.File getDefaultDirectory()
        Return the user's default starting directory for the file chooser.
        Overrides:
        getDefaultDirectory in class javax.swing.filechooser.FileSystemView
        Returns:
        a File object representing the default starting folder
        Since:
        1.4
      • createFileObject

        public java.io.File createFileObject​(java.io.File dir,
                                             java.lang.String filename)
        Returns a File object constructed in dir from the given filename.
        Overrides:
        createFileObject in class javax.swing.filechooser.FileSystemView
      • createFileObject

        public java.io.File createFileObject​(java.lang.String path)
        Returns a File object constructed from the given path string.
        Overrides:
        createFileObject in class javax.swing.filechooser.FileSystemView
      • getFiles

        public java.io.File[] getFiles​(java.io.File dir,
                                       boolean useFileHiding)
        Gets the list of shown (i.e. not hidden) files.
        Overrides:
        getFiles in class javax.swing.filechooser.FileSystemView
      • getParentDirectory

        public java.io.File getParentDirectory​(java.io.File dir)
        Returns the parent directory of dir.
        Overrides:
        getParentDirectory in class javax.swing.filechooser.FileSystemView
        Parameters:
        dir - the File being queried
        Returns:
        the parent directory of dir, or null if dir is null
      • clearCache

        public void clearCache()
        Clear the cache.
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Main for testing.
        Throws:
        java.lang.Exception