|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nwoods.jgo.AbstractUndoableEdit
com.nwoods.jgo.JGoDocumentChangedEdit
JGoDocumentChangedEdit is an UndoableEdit that remembers the document it is associated with, the kind of change it represents, and the before and after state (usually a property value) for that kind of change. This class represents a low-level, detailed change. These are collected together in a CompoundEdit by the JGoUndoManager to represent the potentially many changes caused by a user's single logical gesture such as a moving the current selection.
For both the old and the new values, this remembers both an integer and an Object, which is enough for the vast majority of kinds of changes. There are convenience methods for remembering booleans as an integers, and for remembering floats and doubles as Objects. There are also convenience methods, typically called by changeValue, for getting a value based on whether for undo or for redo. In these methods if the undo parameter is true, it returns the old value, otherwise it returns the new value.
This class calls the copyOldValueForUndo, copyNewValueForRedo, and changeValue methods of JGoDocument and (indirectly) JGoObject. The former two methods are used to remember the before and after states of the document or object for the given hint; the latter method is called in order to actually perform the undo or redo.
JGoUndoManager
,
JGoDocument
,
JGoDocumentEvent
,
Serialized FormConstructor Summary | |
JGoDocumentChangedEdit(JGoDocumentEvent e,
JGoUndoManager mgr,
boolean isbefore)
Construct an UndoableEdit that remembers standard information for undoing and redoing JGoDocument (and JGoObject) changes. |
Method Summary | |
boolean |
canRedo()
|
boolean |
canUndo()
|
void |
die()
Clear out any references held by this edit. |
JGoDocumentChangedEdit |
findBeforeChangingEdit()
Return the last BeforeChanging JGoDocumentChangedEdit in the list of UndoableEdits maintained by this Edit's UndoManager. |
JGoDocument |
getDoc()
Return the document associated with this edit. |
int |
getFlags()
Return the JGoDocumentEvent flags or sub-hint associated with this edit. |
int |
getHint()
Return the JGoDocumentEvent hint associated with this edit. |
java.lang.Object |
getNewValue()
Return the Object part of the new state information. |
boolean |
getNewValueBoolean()
Return the integer part of the new state information as a boolean. |
double |
getNewValueDouble()
Return the Object part of the new state information assuming a double. |
int |
getNewValueInt()
Return the integer part of the new state information. |
java.lang.Object |
getObject()
Return the JGoDocumentEvent Object associated with this edit. |
java.lang.Object |
getOldValue()
Return the Object part of the previous state information. |
boolean |
getOldValueBoolean()
Return the integer part of the previous state information as a boolean. |
double |
getOldValueDouble()
Return the Object part of the previous state information assuming a double. |
int |
getOldValueInt()
Return the integer part of the previous state information. |
java.lang.String |
getPresentationName()
|
JGoUndoManager |
getUndoManager()
Return the JGoUndoManager that this Edit is part of |
java.lang.Object |
getValue(boolean undo)
This convenience method returns either getOldValue() if undo is true, or getNewValue() otherwise. |
boolean |
getValueBoolean(boolean undo)
This convenience method returns either getOldValueBoolean() if undo is true, or getNewValueBoolean() otherwise. |
double |
getValueDouble(boolean undo)
This convenience method returns either getOldValueDouble() if undo is true, or getNewValueDouble() otherwise. |
int |
getValueInt(boolean undo)
This convenience method returns either getOldValueInt() if undo is true, or getNewValueInt() otherwise. |
boolean |
isBeforeChanging()
Return true if this Edit resulted from a JGoDocumentEvent whose isBeforeChanging() method returned true. |
void |
redo()
Implement redo by calling changeValue on the document, unless the edit represents an isBeforeChanging() event. |
void |
setNewValue(java.lang.Object x)
Set the Object part of the new state information. |
void |
setNewValueBoolean(boolean b)
Set the integer part of the new state information, assuming zero is false. |
void |
setNewValueDouble(double d)
Set the Object part of the new state information as a Double. |
void |
setNewValueInt(int i)
Set the integer part of the new state information. |
void |
setOldValue(java.lang.Object x)
Set the Object part of the previous state information. |
void |
setOldValueBoolean(boolean b)
Set the integer part of the previous state information, assuming zero is false. |
void |
setOldValueDouble(double d)
Set the Object part of the previous state information as a Double. |
void |
setOldValueInt(int i)
Set the integer part of the previous state information. |
java.lang.String |
toString()
Produce a somewhat human-readable description of this particular change to a document. |
void |
undo()
Implement undo by calling changeValue on the document, unless the edit represents an isBeforeChanging() event. |
Methods inherited from class com.nwoods.jgo.AbstractUndoableEdit |
addEdit, getRedoPresentationName, getUndoPresentationName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public JGoDocumentChangedEdit(JGoDocumentEvent e, JGoUndoManager mgr, boolean isbefore)
Method Detail |
public void die()
die
in interface UndoableEdit
die
in class AbstractUndoableEdit
public java.lang.String toString()
public java.lang.String getPresentationName()
getPresentationName
in interface UndoableEdit
getPresentationName
in class AbstractUndoableEdit
public boolean canUndo()
canUndo
in interface UndoableEdit
canUndo
in class AbstractUndoableEdit
public boolean canRedo()
canRedo
in interface UndoableEdit
canRedo
in class AbstractUndoableEdit
public void undo() throws CannotUndoException
undo
in interface UndoableEdit
undo
in class AbstractUndoableEdit
CannotUndoException
public void redo() throws CannotRedoException
redo
in interface UndoableEdit
redo
in class AbstractUndoableEdit
CannotRedoException
public boolean isBeforeChanging()
public JGoDocumentChangedEdit findBeforeChangingEdit()
public JGoUndoManager getUndoManager()
public JGoDocument getDoc()
public int getHint()
public int getFlags()
public java.lang.Object getObject()
public int getValueInt(boolean undo)
public boolean getValueBoolean(boolean undo)
public java.lang.Object getValue(boolean undo)
public double getValueDouble(boolean undo)
public int getOldValueInt()
public void setOldValueInt(int i)
public boolean getOldValueBoolean()
public void setOldValueBoolean(boolean b)
public java.lang.Object getOldValue()
public void setOldValue(java.lang.Object x)
public double getOldValueDouble()
public void setOldValueDouble(double d)
public int getNewValueInt()
public void setNewValueInt(int i)
public boolean getNewValueBoolean()
public void setNewValueBoolean(boolean b)
public java.lang.Object getNewValue()
public void setNewValue(java.lang.Object x)
public double getNewValueDouble()
public void setNewValueDouble(double d)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |