Class FileDirectoryManager

java.lang.Object
org.jjazz.filedirectorymanager.api.FileDirectoryManager

public class FileDirectoryManager extends Object
Manage the various directories and file types used by the application.
  • Field Details

  • Constructor Details

    • FileDirectoryManager

      public FileDirectoryManager()
  • Method Details

    • getInstance

      public static FileDirectoryManager getInstance()
    • getSongMixFile

      public File getSongMixFile(File songFile)
      Build the song mix File object for specified song file.

      SongMix file will be located in the same directory than songFile.

      Parameters:
      songFile -
      Returns:
      Return a new file identical to songFile except the extension. If songFile is null returns null.
    • getRhythmMixFile

      public File getRhythmMixFile(String rhythmName, File rhythmFile)
      Get the rhythm mix File object for the specified rhythm.

      Parameters:
      rhythmName -
      rhythmFile - Can be empty (no file) but can not null.
      Returns:
    • getNewSongTemplateMixFile

      public File getNewSongTemplateMixFile()
    • getNewSongTemplateSongFile

      public File getNewSongTemplateSongFile()
    • getJJazzLabUserDirectory

      public File getJJazzLabUserDirectory()
      The directory user.home/DEFAULT_USER_DIR.

      Directory is created if it does not exist.

      Returns:
      Can't be null. Default to user.home property.
    • getInstallationDirectory

      public File getInstallationDirectory()
      Get the Netbeans application installation directory.

      This is the top-level directory which contains subdirectories such as bin, etc, platform, ...

      Returns:
      Can't be null
    • getUserRhythmDirectory

      public File getUserRhythmDirectory()
      Get the user directory for Rhythms files.

      If not set use by default the System property "user.home".

      Returns:
      Can't be null
    • setUserRhythmDirectory

      public void setUserRhythmDirectory(File dir)
      Set the user directory where to find rhythm files.
      Parameters:
      dir -
    • getRhythmMixDirectory

      public File getRhythmMixDirectory()
      Get the directory used for rhythm's default mix files.

      If isUseRhyhtmUserDirAsRhythmDefaultMixDir() is true use the same default value than getUserRhythmDirectory().

      Returns:
      Can't be null.
    • setRhythmMixDirectory

      public void setRhythmMixDirectory(File dir)
      Set the user directory where to find rhythm default mix files.
      Parameters:
      dir -
    • isUseRhyhtmUserDirAsRhythmDefaultMixDir

      public boolean isUseRhyhtmUserDirAsRhythmDefaultMixDir()
    • setUseRhyhtmUserDirAsRhythmDefaultMixDir

      public void setUseRhyhtmUserDirAsRhythmDefaultMixDir(boolean b)
      If b is true getRhythmMixDirectory() will return the same value as getUserRhythmDirectory().
      Parameters:
      b -
    • getAppConfigDirectory

      public File getAppConfigDirectory(String subDirName)
      Get the user specific JJazz configuration directory.

      Use the APP_CONFIG_PREFIX_DIR subdir of the Netbeans user directory, or if not set of the user.home system property. Create the directory if it does not exist.

      Parameters:
      subDirName - An optional extra subdirectory name (APP_CONFIG_PREFIX_DIR/subDir). Ignored if null or empty.
      Returns:
      Could be null if no user directory found.
    • getOldAppConfigFile

      public File getOldAppConfigFile(String oldVersion, String relPath)
      Get the File object corresponding to an existing file (or subdirectory) in the AppConfig directory of an old JJazzLab version.

      For example on Windows, if oldVersion="2.0.1" and relPath="subdir/hello.properties" and this files exists, method returns the File at <WindowsUserDir>/AppData/Roaming/jjazzlab/2.0.1/.jjazz/subdir/hello.properties".

      Parameters:
      relPath - The relative path to the file from the old AppConfig directory. If null returns the AppConfig directory.
      oldVersion - E.g. "2.0.1"
      Returns:
      Null if relPath does not corresponding to an existing file
    • getLastSongDirectory

      public File getLastSongDirectory()
      The last directory used for song open or song save.

      If not set return getJJazzLabUserDirectory() unless it does not exist anymore.

      Returns:
      Can be null
    • setLastSongDirectory

      public void setLastSongDirectory(File dir)
      Set the last song directory.
      Parameters:
      dir -
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener l)