Class SongEditorManager

java.lang.Object
org.jjazz.songeditormanager.api.SongEditorManager
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class SongEditorManager extends Object implements PropertyChangeListener
The central place where all song editors are created (from scratch, loaded from file, etc.) and managed.

You can register to get some change events (opened, saved, closed) from any song managed by this object.

  • Field Details

    • PROP_SONG_OPENED

      public static final String PROP_SONG_OPENED
      This property change event is fired when a song is opened.

      NewValue is the song object.

      See Also:
    • PROP_SONG_CLOSED

      public static final String PROP_SONG_CLOSED
      This property change event is fired when a song is closed.

      NewValue is the song object. Note that a Song object also fires a Closed event when it is closed by the SongEditorManager.

      See Also:
    • PROP_SONG_SAVED

      public static final String PROP_SONG_SAVED
      This property change event is fired when a song is saved.

      NewValue is the song object. This is just a forward of a Song Saved event.

      See Also:
  • Constructor Details

    • SongEditorManager

      public SongEditorManager()
  • Method Details

    • getInstance

      public static SongEditorManager getInstance()
    • closeSong

      public boolean closeSong(Song song, boolean enforce)
      Programmatically close all the editors associated to a song.
      Parameters:
      song -
      enforce - If true, close the song unconditionnaly (disable user prompt if song is not saved)
      Returns:
      True if all editors were successfully closed, false if user blocked the closing due to unsaved song
    • showSong

      public void showSong(Song song, boolean makeActive, boolean savable)
      Do what's required to show a song in the application.

      Creates undomanager, creates and shows editors. Opens the possible links in song memo is makeActive is true. Opens the PianoRollEditor if there is a user track.

      If song is already shown in an editor, just makes its TopComponent active.

      Parameters:
      song -
      makeActive - If true try to make the song musically active, see ActiveSongManager.
      savable - If true, song will appear as modified/savable (save button enabled).
    • showSong

      public Song showSong(File f, boolean makeActive, boolean updateLastSongDirectory) throws SongCreationException
      Load a song from a file and show it.

      Load the song from file, fix the MidiMix if required, and call showSong(song, makeActive).

      Parameters:
      f -
      makeActive -
      updateLastSongDirectory - If true and the file is not already shown, update the LastSongDirectory in FileDirectoryManager.
      Returns:
      The created song from file f
      Throws:
      SongCreationException
    • showPianoRollEditor

      public PianoRollEditorTopComponent showPianoRollEditor(Song song)
      Show the PianoRollEditorTopComponent for the specified song.

      Song must be already edited. Create the PianoRollEditorTopComponent at the appropriate position, or just activate it.

      Parameters:
      song -
      Returns:
    • showPianoRollEditorForUserTrack

      public PianoRollEditorTopComponent showPianoRollEditorForUserTrack(Song song, MidiMix midiMix, UserRhythmVoice userRhythmVoice)
      Open (or show) the song's PianoRollEditor and set it up to edit a user track associated to userRhythmVoice.
      Parameters:
      song -
      midiMix -
      userRhythmVoice -
      Returns:
    • showPianoRollEditorForSptCustomPhrase

      public PianoRollEditorTopComponent showPianoRollEditorForSptCustomPhrase(Song song, MidiMix midiMix, SongPart spt, RhythmVoice rv, Phrase p)
      Open (or show) the song's PianoRollEditor and set it up to edit a custom phrase of a SongPart.
      Parameters:
      song -
      spt - The SongPart for which a phrase is customized
      rv - The RhythmVoice for which we customize the phrase
      p - The customized phrase
      Returns:
    • getOpenedSongs

      public List<Song> getOpenedSongs()
    • getEditors

      public SongEditorManager.Editors getEditors(Song s)
      Get the editors which show song s.
      Parameters:
      s -
      Returns:
      Can be null.
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener l)
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener