com.ibm.as400.access

Class IFSSystemView



  • public class IFSSystemView
    extends FileSystemView
    Provides a gateway to the IBM i integrated file system, for use when constructing javax.swing.JFileChooser objects.

    JFileChooser is a standard Java way to build dialogs for navigating and choosing files.

    The following example demonstrates the use of IFSSystemView.

     
     import com.ibm.as400.access.AS400;
     import com.ibm.as400.access.IFSJavaFile;
     import com.ibm.as400.access.IFSSystemView;
     import javax.swing.JFileChooser;
     import java.awt.Frame;
     
     // Work with directory /Dir on the system myAS400.
     AS400 system = new AS400("myAS400");
     IFSJavaFile dir = new IFSJavaFile(system, "/Dir");
     JFileChooser chooser = new JFileChooser(dir, new IFSSystemView(system));
     Frame parent = new Frame();
     int returnVal = chooser.showOpenDialog(parent);
     if (returnVal == JFileChooser.APPROVE_OPTION) {
        IFSJavaFile chosenFile = (IFSJavaFile)(chooser.getSelectedFile());
        System.out.println("You selected the file named " +
                            chosenFile.getName());
     }
     
    See Also:
    IFSJavaFile
    • Constructor Detail

      • IFSSystemView

        public IFSSystemView(AS400 system)
        Constructs an IFSSystemView object.
        Parameters:
        system - The system that contains the file.

    • Method Detail

      • createFileObject

        public File createFileObject(File containingDir,
                            String name)
        Returns a File object constructed in directory from the given filename.
        Note: This method does not create an actual file in the file system.
        Overrides:
        createFileObject in class FileSystemView
        Parameters:
        containingDir - The directory in which to create the file.
        containingDir is assumed to represent an existing directory on the system. If null, it is ignored.
        name - The file name.
        Returns:
        a File object representing the new file.
      • createFileObject

        public File createFileObject(String path)
        Returns a File object constructed from the given path string.
        Note: This method does not create an actual file in the file system.
        Overrides:
        createFileObject in class FileSystemView
        Parameters:
        path - The file path name.
        Returns:
        the File object.
      • createNewFolder

        public File createNewFolder(File containingDir)
                             throws IOException
        Creates a new folder with a default name.
        Note: In the context of this class, "folder" is synonymous with "directory".
        Specified by:
        createNewFolder in class FileSystemView
        Parameters:
        containingDir - The parent directory in which to create the folder.
        containingDir is assumed to represent an existing directory on the system.
        Returns:
        a File object representing the new folder.
        Throws:
        IOException
      • getDefaultDirectory

        public File getDefaultDirectory()
        Returns the user's default starting directory for the file chooser. This will represent the 'root' directory on the system.
        Overrides:
        getDefaultDirectory in class FileSystemView
        Returns:
        A File object representing the default starting folder.
      • getFiles

        public File[] getFiles(File directory,
                      boolean useFileHiding)
        Gets the list of shown (that is, not hidden) files in the directory.
        Overrides:
        getFiles in class FileSystemView
        Parameters:
        directory - The directory to search.
        useFileHiding - This parameter is ignored.
        Returns:
        The list of files.
      • getHomeDirectory

        public File getHomeDirectory()
        Returns the home directory.
        The IBM i integrated file system has one home directory, the "/" directory.
        Overrides:
        getHomeDirectory in class FileSystemView
        Returns:
        the home directory.
      • getParentDirectory

        public File getParentDirectory(File dir)
        Returns the parent directory of dir.
        Overrides:
        getParentDirectory in class FileSystemView
        Parameters:
        dir - The directory being queried.
        dir is assumed to represent an existing directory on the system.
        Returns:
        the parent directory of dir, or null if dir is null.
      • getRoots

        public File[] getRoots()
        Returns all root partitions on this system.
        The IBM i integrated file system has one root partition, the "/" directory.
        Overrides:
        getRoots in class FileSystemView
        Returns:
        all root partitions on this system.
      • getSystemDisplayName

        public String getSystemDisplayName(File f)
        Returns the name of a file, directory, or folder as it would be displayed in a system file browser.
        Overrides:
        getSystemDisplayName in class FileSystemView
        Parameters:
        f - A File object.
        Returns:
        The file name as it would be displayed by a native file chooser.
      • getSystemTypeDescription

        public String getSystemTypeDescription(File f)
        Returns a type description for a file, directory, or folder as it would be displayed in a system file browser.
        Overrides:
        getSystemTypeDescription in class 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.
      • isFileSystemRoot

        public boolean isFileSystemRoot(File f)
        Returns true if f represents the root directory on the system ("/"), and false otherwise.
        Overrides:
        isFileSystemRoot in class FileSystemView
        Parameters:
        f - A File object representing a directory.
        Returns:
        true if f is a root of a filesystem
      • isRoot

        public boolean isRoot(File file)
        Determines if the given file is a root in the navigatable tree(s).
        The IBM i integrated file system has one root, the "/" directory.
        Overrides:
        isRoot in class FileSystemView
        Parameters:
        file - A File object representing a directory.
        Returns:
        true if file is a root in the navigatable tree.