Class RMUndoer
- java.lang.Object
-
- com.reportmill.base.RMObject
-
- com.reportmill.base.RMUndoer
-
- All Implemented Interfaces:
RMArchiver.Archiving,java.lang.Cloneable
public class RMUndoer extends RMObject
RMUndoer - this object manages undo by keeping copies of changed objects. For objects to be undoable they must do the following:Call: undoer.addDirtyObject(this) - This registers and objects for possible change Implement: undoClone() or clone() - A typical clone implementation should do, except that all relationship objects should be copied deep unless they also register with addDirtyObject(). Objects are copied the first time they are sent to addDirtyObject(). Implement: undoEquals() or equals() - A typical equals implementation should do. At the end of the current event, objects that end up being equal to their registered clone are trimmed to avoid unecessary archival (and no-op undo events). Implement: undoCopy(anObj) or copy(anObj) - This method should restore the state of an object from its registered clone. All relationship objects should be copied deep, unless they also register with addDirtyObject().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRMUndoer.RMUndoEventThis class reprents a distinct "undoable event".
-
Constructor Summary
Constructors Constructor Description RMUndoer()Creates a new undoer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDirtyObject(RMObject anObj)Adds the given object to the current undo record.java.util.ListallUndos()Returns all undos (including the current one, if changes are pending).voiddisable()Disables undoer so it can receive new changes.voidenable()Enables undoer.booleangetCoalesce()Returns whether undoer coalesces changes.intgetDirtyObjectCount()Returns the number of dirty objects in the current undo record.intgetDisabled()Returns whether undoer is disabled.RMUndoer.RMUndoEventgetRecentUndo()Returns most recent undo event.RMUndoer.RMUndoEventgetRedoEvent()Returns the next redo event.RMUndoer.RMUndoEventgetRedoLast()Returns the last redo.java.util.ListgetRedoSelectedObjects()Returns the list of objects that should be selected after current undo is redone.RMUndoer.RMUndoEventgetUndoEvent()Returns the next undo event.RMUndoer.RMUndoEventgetUndoLast()Returns the last undo.java.util.ListgetUndoSelectedObjects()Returns the list of objects that should be selected after current undo is fired.booleanhasUndos()Returns whether undoer has undoable changes stored away.booleanisBenignChange(java.lang.String aString)Returns whether a given change doesn't really effect signficant state change.booleanisDuplicate(java.lang.String aTitle, RMObject anObj)Returns whether given title is title of last undo.voidredo()Pops last redo event off stack and has it update all changed objects it contains.java.util.Listredos()Returns the list of redos.voidreset()Resets the undoer to its initial state (good to do when a document is saved).voidsaveChanges()Pushes current undo record on the stack and opens new one.voidsetCoalesce(boolean aFlag)Sets whether undoer coalesces changes.voidsetDisabled(int aValue)Sets whether undoer is disabled.voidsetRedoSelectedObjects(java.util.List aList)Sets the list of objects that should be selected after current undo is redone.voidsetUndoSelectedObjects(java.util.List aList)Sets the list of objects that should be selected after current undo is fired.voidsetUndoTitle(java.lang.String aString)Sets the title of the current undo.voidundo()Pops last undo event off stack an has it update all changed objects it contains.java.util.Listundos()Returns the list of undos.-
Methods inherited from class com.reportmill.base.RMObject
clone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, initWithArchiver, undoClone, undoCopy, undoEquals
-
-
-
-
Method Detail
-
getDirtyObjectCount
public int getDirtyObjectCount()
Returns the number of dirty objects in the current undo record.
-
addDirtyObject
public void addDirtyObject(RMObject anObj)
Adds the given object to the current undo record.
-
saveChanges
public void saveChanges()
Pushes current undo record on the stack and opens new one.
-
undo
public void undo()
Pops last undo event off stack an has it update all changed objects it contains.
-
redo
public void redo()
Pops last redo event off stack and has it update all changed objects it contains.
-
disable
public void disable()
Disables undoer so it can receive new changes.
-
enable
public void enable()
Enables undoer.
-
getDisabled
public int getDisabled()
Returns whether undoer is disabled.
-
setDisabled
public void setDisabled(int aValue)
Sets whether undoer is disabled.
-
getCoalesce
public boolean getCoalesce()
Returns whether undoer coalesces changes.
-
setCoalesce
public void setCoalesce(boolean aFlag)
Sets whether undoer coalesces changes.
-
getRecentUndo
public RMUndoer.RMUndoEvent getRecentUndo()
Returns most recent undo event.
-
reset
public void reset()
Resets the undoer to its initial state (good to do when a document is saved).
-
isBenignChange
public boolean isBenignChange(java.lang.String aString)
Returns whether a given change doesn't really effect signficant state change.
-
hasUndos
public boolean hasUndos()
Returns whether undoer has undoable changes stored away.
-
getUndoEvent
public RMUndoer.RMUndoEvent getUndoEvent()
Returns the next undo event.
-
getRedoEvent
public RMUndoer.RMUndoEvent getRedoEvent()
Returns the next redo event.
-
setUndoTitle
public void setUndoTitle(java.lang.String aString)
Sets the title of the current undo.
-
undos
public java.util.List undos()
Returns the list of undos.
-
redos
public java.util.List redos()
Returns the list of redos.
-
getUndoLast
public RMUndoer.RMUndoEvent getUndoLast()
Returns the last undo.
-
getRedoLast
public RMUndoer.RMUndoEvent getRedoLast()
Returns the last redo.
-
allUndos
public java.util.List allUndos()
Returns all undos (including the current one, if changes are pending).
-
getUndoSelectedObjects
public java.util.List getUndoSelectedObjects()
Returns the list of objects that should be selected after current undo is fired.
-
setUndoSelectedObjects
public void setUndoSelectedObjects(java.util.List aList)
Sets the list of objects that should be selected after current undo is fired.
-
getRedoSelectedObjects
public java.util.List getRedoSelectedObjects()
Returns the list of objects that should be selected after current undo is redone.
-
setRedoSelectedObjects
public void setRedoSelectedObjects(java.util.List aList)
Sets the list of objects that should be selected after current undo is redone.
-
isDuplicate
public boolean isDuplicate(java.lang.String aTitle, RMObject anObj)Returns whether given title is title of last undo.
-
-