|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.kernel.util.SingletonAttribute
ptolemy.kernel.undo.UndoStackAttribute
public class UndoStackAttribute
This attribute holds the undo/redo information for a model. This attribute is not persistent, so undo/redo information disappears when the model is closed. It is also a singleton, meaning that it will replace any previous attribute that has the same name and is an instance of the same base class, SingletonAttribute.
Two stacks of information are maintained - one for undo information and one for redo information. Normally, a push onto this stack puts the undo information in the undo stack. However, if the push occurs during the execution of an undo, then the information is put on the redo stack. The entries on the stack implement the UndoAction interface.
NOTE: the information in the redo stack is emptied when a new undo action is pushed onto the undo stack that was not the result of a redo being requested. This situation arises when a user requests a series of undo and redo operations, and then performs some normal undoable action. At this point the information in the redo stack is not relevant to the state of the model and so must be cleared.
UndoAction
,
Serialized Form
Red (cxh) |
Yellow (eal) |
Nested Class Summary | |
---|---|
private static class |
UndoStackAttribute.MergeUndoActions
An undo or redo action on the stack. |
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
private int |
_inRedo
|
private int |
_inUndo
|
private java.util.Stack |
_redoEntries
|
private java.util.Stack |
_undoEntries
|
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary | |
---|---|
UndoStackAttribute(NamedObj container,
java.lang.String name)
Construct an attribute with the given name contained by the specified container. |
Method Summary | |
---|---|
static UndoStackAttribute |
getUndoInfo(NamedObj object)
Get the UndoStackAttribute associated with the given object. |
void |
mergeTopTwo()
Merge the top two undo entries into a single action, unless we are in either a redo or an undo, in which case the merge happens automatically and need not be explicitly requested by the client. |
void |
push(UndoAction action)
Push an action to the undo stack, or if we are executing an undo, onto the redo stack. |
void |
redo()
Remove the top redo action and execute it. |
void |
undo()
Remove the top undo action and execute it. |
Methods inherited from class ptolemy.kernel.util.SingletonAttribute |
---|
setContainer |
Methods inherited from class ptolemy.kernel.util.Attribute |
---|
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int _inRedo
private int _inUndo
private java.util.Stack _redoEntries
private java.util.Stack _undoEntries
Constructor Detail |
---|
public UndoStackAttribute(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this attribute.
IllegalActionException
- If the attribute is not of an
acceptable class for the container, or if the name contains a
period.
NameDuplicationException
- If the name coincides with an
attribute already in the container.Method Detail |
---|
public static UndoStackAttribute getUndoInfo(NamedObj object)
object
- The model for which an undo stack is required
(must not be null or a NullPointerException will the thrown).
public void mergeTopTwo()
public void push(UndoAction action)
action
- The undo action.public void redo() throws java.lang.Exception
java.lang.Exception
- If something goes wrong.public void undo() throws java.lang.Exception
java.lang.Exception
- If something goes wrong.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |