de.esprit.common.gui.comp

## Class AbstractFileIO

- java.lang.Object
- - de.esprit.common.gui.comp.AbstractFileIO

- Direct Known Subclasses:
    FileInput, FileOutput

      public abstract class AbstractFileIO
      extends java.lang.Object

  This class manages a current working directory as well as a current filename. It pops up a JFileChooser for file browsing. The default current working directory is the home directory of the user.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractFileIO(java.awt.Component hook, int fileChooserType, CurrentFileHolder fileHolder, javax.swing.filechooser.FileFilter fileFilt)`
    `AbstractFileIO(java.awt.Component hook, int fileChooserType, java.io.File startDirectory, javax.swing.filechooser.FileFilter fileFilt)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDefaultFileFilters()` Adds a default set of FileFilters which are ZFileFilter.getAllFilters()
    `void` | `addFileFilter(javax.swing.filechooser.FileFilter filter)` Adds the given FileFilter to the list of FileFilters
    `void` | `addFileFilters(javax.swing.filechooser.FileFilter[] filters)` Adds the given set of FileFilters to the list of FileFilters
    `void` | `clearFileFilters()` Clears all FileFilters and adds ZFileFilter.FILTER_ALL as the only one
    `javax.swing.filechooser.FileFilter` | `getCurrentFileFilter()` Returns the selected FileFilter which actually filters the filenames
    `java.io.File` | `getDirectory()` Returns the current base directory, if any
    `java.io.File` | `getFile()` Returns the current file, if any
    `ZFileChooser` | `getFileChooser()`
    `javax.swing.filechooser.FileFilter[]` | `getFileFilters()` Returns the FileFilters currently in use
    `java.io.File` | `getHomeDir()` Returns the homeDir of the user
    `java.io.File` | `getStartDir()` Returns the startDir which was used to construct this FileIO object.
    `boolean` | `hasFileFilter(javax.swing.filechooser.FileFilter filter)` Checks whether the given FileFilter is available in the current list of FileFilters
    `void` | `setCurrentFileFilter(javax.swing.filechooser.FileFilter filter)` Selects the FileFilter which actually filters the filenames.
    `void` | `setDirectory(java.io.File dir)` Sets the current base directory
    `void` | `setDirectory(java.lang.String dir)` Sets the current base directory
    `void` | `setFile(java.io.File file)` Sets both the current base directory and the current fileName
    `void` | `setFileFilter(javax.swing.filechooser.FileFilter filter)` Removes all existing FileFilters and adds only the given one and also makes it the currently selected one.
    `void` | `setFileName(java.lang.String fileName)` Sets a current fileName which is displayed in the file input textfield of the FileChooser
    `int` | `showOpenDialog()`
    `int` | `showSaveDialog()`
    `java.lang.String` | `toString()`
    `ToString` | `toString(ToString s)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractFileIO

          public AbstractFileIO(java.awt.Component hook,
                        int fileChooserType,
                        CurrentFileHolder fileHolder,
                        javax.swing.filechooser.FileFilter fileFilt)

    - #### AbstractFileIO

          public AbstractFileIO(java.awt.Component hook,
                        int fileChooserType,
                        java.io.File startDirectory,
                        javax.swing.filechooser.FileFilter fileFilt)

  - ### Method Detail

    - #### getStartDir

          public java.io.File getStartDir()

      Returns the startDir which was used to construct this FileIO object. The startDir is used as the initial baseDir. When a file is being selected in a different directory then that one will become the current baseDir.
      Note that pressing the CNTRL-key when popping up the FileChooser will reset the current baseDir to the initial startDir.

    - #### getHomeDir

          public java.io.File getHomeDir()

      Returns the homeDir of the user

    - #### setFileFilter

          public void setFileFilter(javax.swing.filechooser.FileFilter filter)

      Removes all existing FileFilters and adds only the given one and also makes it the currently selected one.

    - #### clearFileFilters

          public void clearFileFilters()

      Clears all FileFilters and adds ZFileFilter.FILTER_ALL as the only one

    - #### addDefaultFileFilters

          public void addDefaultFileFilters()

      Adds a default set of FileFilters which are ZFileFilter.getAllFilters()

    - #### addFileFilter

          public void addFileFilter(javax.swing.filechooser.FileFilter filter)

      Adds the given FileFilter to the list of FileFilters

    - #### addFileFilters

          public void addFileFilters(javax.swing.filechooser.FileFilter[] filters)

      Adds the given set of FileFilters to the list of FileFilters

    - #### getFileFilters

          public javax.swing.filechooser.FileFilter[] getFileFilters()

      Returns the FileFilters currently in use

    - #### getCurrentFileFilter

          public javax.swing.filechooser.FileFilter getCurrentFileFilter()

      Returns the selected FileFilter which actually filters the filenames

    - #### setCurrentFileFilter

          public void setCurrentFileFilter(javax.swing.filechooser.FileFilter filter)

      Selects the FileFilter which actually filters the filenames. If the given FileFilter does not exist yet in the list of available FileFilters it is appended automatically.

    - #### hasFileFilter

          public boolean hasFileFilter(javax.swing.filechooser.FileFilter filter)

      Checks whether the given FileFilter is available in the current list of FileFilters

    - #### getFile

          public java.io.File getFile()

      Returns the current file, if any

    - #### getDirectory

          public java.io.File getDirectory()

      Returns the current base directory, if any

    - #### setFileName

          public void setFileName(java.lang.String fileName)

      Sets a current fileName which is displayed in the file input textfield of the FileChooser

    - #### setFile

          public void setFile(java.io.File file)

      Sets both the current base directory and the current fileName

    - #### setDirectory

          public void setDirectory(java.lang.String dir)

      Sets the current base directory

    - #### setDirectory

          public void setDirectory(java.io.File dir)

      Sets the current base directory

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### toString

          public ToString toString(ToString s)

    - #### getFileChooser

          public ZFileChooser getFileChooser()

    - #### showOpenDialog

          public int showOpenDialog()

    - #### showSaveDialog

          public int showSaveDialog()

Copyright © 2014 EsprIT-Systems. All Rights Reserved.