Interface FileUtil


  • public interface FileUtil
    Provides a platform-dependent way to open files. Mainly because Mac would prefer that you use java.awt.FileDialog instead of the Swing FileChooser.

    Module: swing-util-api

    To use this in your app, include the following dependency in your POM:

    <dependency>
        <groupId>org.cytoscape</groupId>
        <artifactId>swing-util-api</artifactId>
    </dependency>

    Cytoscape Backwards Compatibility (API Interface): We expect that this interface will be used but not implemented by developers using this interface. As such, we reserve the right to add methods to the interface as part of minor version upgrades. We will not remove methods for any changes other than major version upgrades.
    • Method Detail

      • getFile

        File getFile​(Component parent,
                     String title,
                     int loadSaveCustom,
                     Collection<FileChooserFilter> filters)
        Returns a File object, this method should be used instead of rolling your own JFileChooser.
        Parameters:
        parent - the parent of the JFileChooser or FileDialog
        title - the title of the dialog box
        loadSaveCustom - a flag for the type of file dialog
        filters - a non-empty collection of file filters
        Returns:
        the location of the selected file
      • getFile

        File getFile​(Component parent,
                     String title,
                     int loadSaveCustom,
                     String startDir,
                     String customApproveText,
                     Collection<FileChooserFilter> filters)
        Returns a File object, this method should be used instead of rolling your own JFileChooser.
        Parameters:
        parent - the parent of the JFileChooser or FileDialog
        title - the title of the dialog box
        loadSaveCustom - a flag for the type of file dialog
        startDir - an alternate start dir, if null the default Cytoscape MUD will be used
        customApproveText - if this is a custom dialog, then custom text should be on the approve button.
        filters - a non-empty collection of file filters
        Returns:
        the location of the selected file
      • getFile

        File getFile​(Component parent,
                     String title,
                     int loadSaveCustom,
                     String startDir,
                     String fileName,
                     String customApproveText,
                     Collection<FileChooserFilter> filters)
        Returns a File object, this method should be used instead of rolling your own JFileChooser.
        Parameters:
        parent - the parent of the JFileChooser or FileDialog
        title - the title of the dialog box
        loadSaveCustom - a flag for the type of file dialog
        startDir - an alternate start dir, if null the default Cytoscape MUD will be used
        fileName - a suggested file name to use
        customApproveText - if this is a custom dialog, then custom text should be on the approve button.
        filters - a non-empty collection of file filters
        Returns:
        the location of the selected file
      • getFiles

        File[] getFiles​(Component parent,
                        String title,
                        int loadSaveCustom,
                        Collection<FileChooserFilter> filters)
        Returns an array of File objects, this method should be used instead of rolling your own JFileChooser.
        Parameters:
        parent - the parent of the JFileChooser or FileDialog
        title - the title of the dialog box
        loadSaveCustom - a flag for the type of file dialog
        filters - a non-empty collection of file filters
        Returns:
        the location of the selected file
      • getFiles

        File[] getFiles​(Component parent,
                        String title,
                        int loadSaveCustom,
                        String startDir,
                        String customApproveText,
                        Collection<FileChooserFilter> filters)
        Returns a list of File objects, this method should be used instead of rolling your own JFileChooser.
        Parameters:
        parent - the parent of the JFileChooser or FileDialog
        title - the title of the dialog box
        loadSaveCustom - a flag for the type of file dialog
        startDir - an alternate start dir, if null the default Cytoscape MUD will be used
        customApproveText - if this is a custom dialog, then custom text should be on the approve button.
        filters - a non-empty collection of file filters
        Returns:
        and array of selected files, or null if none are selected
      • getFiles

        File[] getFiles​(Component parent,
                        String title,
                        int loadSaveCustom,
                        String startDir,
                        String customApproveText,
                        boolean multiselect,
                        Collection<FileChooserFilter> filters)
        Returns a list of File objects, this method should be used instead of rolling your own JFileChooser.
        Parameters:
        parent - the parent of the JFileChooser or FileDialog
        title - the title of the dialog box
        loadSaveCustom - a flag for the type of file dialog
        startDir - an alternate start dir, if null the default cytoscape MUD will be used
        customApproveText - if this is a custom dialog, then custom text should be on the approve button.
        multiselect - Enable selection of multiple files (Macs are still limited to a single file because we use FileDialog there -- is this fixed in Java 1.5?)
        filters - a non-empty collection of file filters
        Returns:
        and array of selected files, or null if none are selected
      • getFiles

        File[] getFiles​(Component parent,
                        String title,
                        int loadSaveCustom,
                        String startDir,
                        String fileName,
                        String customApproveText,
                        boolean multiselect,
                        Collection<FileChooserFilter> filters)
        Returns a list of File objects, this method should be used instead of rolling your own JFileChooser.
        Parameters:
        parent - the parent of the JFileChooser or FileDialog
        title - the title of the dialog box
        loadSaveCustom - a flag for the type of file dialog
        startDir - an alternate start dir, if null the default cytoscape MUD will be used
        fileName - a suggested file name to use
        customApproveText - if this is a custom dialog, then custom text should be on the approve button.
        multiselect - Enable selection of multiple files (Macs are still limited to a single file because we use FileDialog there -- is this fixed in Java 1.5?)
        filters - a non-empty collection of file filters
        Returns:
        and array of selected files, or null if none are selected
      • getFolder

        File getFolder​(Component parent,
                       String title,
                       String startDir)
        Returns a File object representing a folder, this method should be used instead of rolling your own JFileChooser.
        Parameters:
        parent - the parent of the JFileChooser or FileDialog
        title - the title of the dialog box
        startDir - an alternate start dir, if null the default Cytoscape MUD will be used
        Returns:
        the location of the selected folder