public class UndoContext
extends java.lang.Object
At the end of an element, if the context is undoable, then the undo MoML is generated by taking the main undo MoML StringBuffer, appending the undo MoML for children in the reverse order to the order they were parsed, and finally appending any closing undo MoML that is present.
Constructor and Description |
---|
UndoContext(boolean undoableContext)
Create a new UndoContext which may or may not need undo MoML
generated.
|
Modifier and Type | Method and Description |
---|---|
void |
appendClosingUndoMoML(java.lang.String undoMoML)
Append some MoML to be appended after the undo MoML for child nodes.
|
void |
appendUndoMoML(java.lang.String undoMoML)
Append some MoML to the current buffer.
|
void |
applyRename(java.lang.String newName)
Used to handle the "rename" element.
|
java.lang.String |
generateUndoEntry()
Generate the undo entry by processing children entries and the
closing undo MoML.
|
java.lang.String |
getUndoMoML()
Get the undo MoML for this element as it currently stands.
|
boolean |
hasUndoableChildren()
Return whether or not child nodes need to generate MoML.
|
boolean |
hasUndoMoML()
Return whether or not this context has any undo MoML to be processed.
|
boolean |
isUndoable()
Tells if the current context is undoable or not.
|
static java.lang.String |
moveContextEnd(NamedObj context,
NamedObj containee)
Return the closing element corresponding to the starting element
returned by moveContextStart(), or an empty string if none is
needed.
|
static java.lang.String |
moveContextStart(NamedObj context,
NamedObj containee)
Return the MoML start element to put us in the
context of the immediate container of the containee,
assuming the current context is as given by the
context argument.
|
void |
pushUndoEntry(java.lang.String entry)
Push the passed in MoML onto the stack of element undo entries.
|
void |
setChildrenUndoable(boolean isUndoable)
Set whether or not the child contexts are undoable.
|
void |
setUndoable(boolean isUndoable)
Set whether or not the current context is undoable.
|
java.lang.String |
toString()
Return a string representation of this object.
|
public UndoContext(boolean undoableContext)
undoableContext
- Whether or not undo MoML is required for this
contextpublic void appendClosingUndoMoML(java.lang.String undoMoML)
undoMoML
- The MoMl to be appended after any child nodespublic void appendUndoMoML(java.lang.String undoMoML)
undoMoML
- The undo MoML to append to the current buffer.public void applyRename(java.lang.String newName) throws IllegalActionException
newName
- the value to give to the value of the name attribute.IllegalActionException
- if there is currently no undo MoML at
this level, or if there is no name attribute present.public java.lang.String generateUndoEntry()
public java.lang.String getUndoMoML()
public boolean hasUndoMoML()
public boolean hasUndoableChildren()
public boolean isUndoable()
public static java.lang.String moveContextEnd(NamedObj context, NamedObj containee)
For example, if the containee is not already immediately contained, and the container is an entity, the </entity> is appended to the model.
context
- The current context.containee
- The containee whose immediate context we want.moveContextStart(NamedObj, NamedObj)
public static java.lang.String moveContextStart(NamedObj context, NamedObj containee)
For example, if the context has full name ".top" and the containee has full name ".top.a.b.c.d", then MoML to move down the model such as the following is returned: <entity name="a.b.c" >
context
- The current context.containee
- The containee whose immediate context we want.moveContextEnd(NamedObj, NamedObj)
public void pushUndoEntry(java.lang.String entry)
entry
- Description of Parameterpublic void setChildrenUndoable(boolean isUndoable)
isUndoable
- the new statepublic void setUndoable(boolean isUndoable)
isUndoable
- the new statepublic java.lang.String toString()
toString
in class java.lang.Object