com.frinika.sequencer.model
Class EditHistoryContainer

java.lang.Object
  extended by com.frinika.sequencer.model.EditHistoryContainer

public class EditHistoryContainer
extends java.lang.Object

The EditHistoryContainer monitors all edits on a EditHistoryRecorders. By setting a marking pont using the mark method - it will be possible to roll back to the state at the marking point at a later stage. It's also possible to roll back and roll forward again. This gives undo/redo features to a EditHistoryRecorder. How to use? Simply call the mark method before any action or series of actions on the sequence. Set the markstring according to a description of what can be undone. Remember that all actions on a EditHistoryRecordable has to be either add or remove - also meaning that if you're just going to change a MidiEvent you should always remove it - change it - and then add it to the track again. If you have undo/redo menuitems reference them with the setMenuItem methods, so that they're constantly updated according to the undo/redo marks. You can also reuse your undo/redo menuitems in other windows. Do this by adding a the undo/redo menuitems from this EditHistoryContainer rather than creating them yourself.

Author:
Peter Johan Salomonsen

Constructor Summary
EditHistoryContainer()
           
 
Method Summary
 void addEditHistoryListener(EditHistoryListener editHistoryListener)
          Add an editHistory listener to this edithistorycontainer
 void disableRecording()
          Use during undo/redo operations so that these are not recorded in the EditHistory
 void enableRecording()
          Use after undo/redo operations to reenable edithistory recording
 java.lang.String getNextRedoMarkString()
          Get the descriptive string of the actions that will be redone on the next redo
 java.lang.String getNextUndoMarkString()
          Get the descriptive string of the actions that will be rolled back on the next undo
 javax.swing.JMenuItem getRedoMenuItem()
           
 javax.swing.JMenuItem getUndoMenuItem()
           
 boolean hasChanges()
          Tell if there has been any edits on this history container
 boolean isRecordingEnabled()
           
 void mark(java.lang.String markString)
          Call the mark method before any action or series of actions on the sequence.
 void notifyEditHistoryListeners()
          Clients should call this method when done with a marked action, in order to notify listeners for changes.
 void push(EditHistoryAction editHistoryAction)
          Push a generic editHistoryAction onto the recording
 void push(EditHistoryRecorder recorder, int edit_history_type, EditHistoryRecordable event)
          Called by the FrinikaTrackWrapper add and remove methods when there are changes to the track.
 void redo()
          Redo actions up to the next mark
 void removeEditHistoryListener(EditHistoryListener editHistoryListener)
          Remove an editHistory listener from this edithistorycontainer
 void setRedoMenuItem(javax.swing.JMenuItem redoMenuItem)
          Use to give a menuitem reference to the EditHistoryContainer so that it can update the menuitem text
 void setUndoMenuItem(javax.swing.JMenuItem undoMenuItem)
          Use to give a menuitem reference to the EditHistoryContainer so that it can update the menuitem text
 void undo()
          Undo actions back to the previous mark
 void updateMenuItems()
          Update undo/redo menuitems so that they show info according to the undo/redo marks.
 void updateSavedPosition()
          Called by the ProjectContainer when saving the project so that hasChanges() will return false as long as there are no changes after the save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EditHistoryContainer

public EditHistoryContainer()
Method Detail

push

public void push(EditHistoryRecorder recorder,
                 int edit_history_type,
                 EditHistoryRecordable event)
Called by the FrinikaTrackWrapper add and remove methods when there are changes to the track.

Parameters:
edit_history_type -
track -
event -

push

public void push(EditHistoryAction editHistoryAction)
Push a generic editHistoryAction onto the recording

Parameters:
editHistoryAction -

mark

public void mark(java.lang.String markString)
Call the mark method before any action or series of actions on the sequence. Set the markstring according to a description of what can be undone.

Parameters:
markString -

notifyEditHistoryListeners

public void notifyEditHistoryListeners()
Clients should call this method when done with a marked action, in order to notify listeners for changes.


addEditHistoryListener

public void addEditHistoryListener(EditHistoryListener editHistoryListener)
Add an editHistory listener to this edithistorycontainer

Parameters:
editHistoryListener -

removeEditHistoryListener

public void removeEditHistoryListener(EditHistoryListener editHistoryListener)
Remove an editHistory listener from this edithistorycontainer

Parameters:
editHistoryListener -

redo

public void redo()
Redo actions up to the next mark


getNextUndoMarkString

public java.lang.String getNextUndoMarkString()
Get the descriptive string of the actions that will be rolled back on the next undo

Returns:

getNextRedoMarkString

public java.lang.String getNextRedoMarkString()
Get the descriptive string of the actions that will be redone on the next redo

Returns:

undo

public void undo()
Undo actions back to the previous mark


updateMenuItems

public void updateMenuItems()
Update undo/redo menuitems so that they show info according to the undo/redo marks. Eventually disable them if there's nothing to undo or redo


getRedoMenuItem

public javax.swing.JMenuItem getRedoMenuItem()
Returns:
Returns the redoMenuItem.

getUndoMenuItem

public javax.swing.JMenuItem getUndoMenuItem()
Returns:
Returns the undoMenuItem.

setRedoMenuItem

public void setRedoMenuItem(javax.swing.JMenuItem redoMenuItem)
Use to give a menuitem reference to the EditHistoryContainer so that it can update the menuitem text

Parameters:
redoMenuItem -

setUndoMenuItem

public void setUndoMenuItem(javax.swing.JMenuItem undoMenuItem)
Use to give a menuitem reference to the EditHistoryContainer so that it can update the menuitem text

Parameters:
redoMenuItem -

hasChanges

public boolean hasChanges()
Tell if there has been any edits on this history container

Returns:

isRecordingEnabled

public boolean isRecordingEnabled()
Returns:
Returns the recordingEnabled.

disableRecording

public void disableRecording()
Use during undo/redo operations so that these are not recorded in the EditHistory


enableRecording

public void enableRecording()
Use after undo/redo operations to reenable edithistory recording


updateSavedPosition

public void updateSavedPosition()
Called by the ProjectContainer when saving the project so that hasChanges() will return false as long as there are no changes after the save