public class UndoStackAttribute extends 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
NamedObj.ContainedObjectsIterator
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
UndoStackAttribute(NamedObj container,
java.lang.String name)
Construct an attribute with the given name contained by the
specified container.
|
Modifier and Type | Method and Description |
---|---|
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.
|
setContainer
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
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.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.