public class MoMLChangeRequest extends ChangeRequest
If a context is given to the constructor, then the MoML will be executed in that context. If that context has other objects that defer their MoML definitions to it (i.e., it is a class definition and there are instances of the class), then the MoML will also be executed in the context of those objects that defer to it. Thus, the change to a class will propagate to instances. If the context is (deeply) contained by another object that has objects that defer their MoML definitions to it, then the changes are also propagated to those objects. Thus, even when class definitions are nested within class definitions, a change within a class definition will propagate to all instances of the class(es).
The parser used to implement the change will be the parser contained by a ParserAttribute of the top-level element of the context. If no context is given, or there is no ParserAttribute in its top level, then a new parser is created, and a new ParserAttribute is placed in the top level.
Note that if a context is specified that is above a class definition, and a change within the class definition is made by referencing the contents of the class definition using dotted names, then the change will not propagate. Thus, changes should be made in the most specific context (lowest level in the hierarchy) possible.
Constructor and Description |
---|
MoMLChangeRequest(java.lang.Object originator,
NamedObj context,
java.lang.String request)
Construct a mutation request to be executed in the specified context.
|
MoMLChangeRequest(java.lang.Object originator,
NamedObj context,
java.lang.String request,
boolean structural)
Construct a mutation request to be executed in the specified context.
|
MoMLChangeRequest(java.lang.Object originator,
NamedObj context,
java.lang.String request,
java.net.URL base)
Construct a mutation request to be executed in the specified context.
|
MoMLChangeRequest(java.lang.Object originator,
java.lang.String request)
Construct a mutation request.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_execute()
Execute the change by evaluating the request and propagating
the request if appropriate.
|
protected void |
_postParse(MoMLParser parser)
Do nothing.
|
protected void |
_preParse(MoMLParser parser)
Do nothing.
|
NamedObj |
getContext()
Return the context specified in the constructor, or null if none
was specified.
|
static NamedObj |
getDeferredToParent(NamedObj object)
Deprecated.
No longer needed; just use the specified object as
a context.
|
void |
setMergeWithPreviousUndo(boolean mergeWithPrevious)
Set whether or not the undo from this change should be merged with
the previous undoable change.
|
void |
setReportErrorsToHandler(boolean report)
Specify whether or not to report errors via the handler that
is registered with the parser.
|
void |
setUndoable(boolean undoable)
Set whether or not this change is undoable.
|
addChangeListener, execute, getDescription, getLocality, getSource, isErrorReported, isPersistent, isStructuralChange, removeChangeListener, setDescription, setErrorReported, setListeners, setPersistent, waitForCompletion
public MoMLChangeRequest(java.lang.Object originator, java.lang.String request)
originator
- The originator of the change request.request
- The mutation request in MoML.public MoMLChangeRequest(java.lang.Object originator, NamedObj context, java.lang.String request)
originator
- The originator of the change request.context
- The context in which to execute the MoML.request
- The mutation request in MoML.public MoMLChangeRequest(java.lang.Object originator, NamedObj context, java.lang.String request, java.net.URL base)
originator
- The originator of the change request.context
- The context in which to execute the MoML.request
- The mutation request in MoML.base
- The URL relative to which external references should
be resolved.public MoMLChangeRequest(java.lang.Object originator, NamedObj context, java.lang.String request, boolean structural)
originator
- The originator of the change request.context
- The context in which to execute the MoML.request
- The mutation request in MoML.structural
- Whether or not this is a structural change.public NamedObj getContext()
@Deprecated public static NamedObj getDeferredToParent(NamedObj object)
object
- The NamedObj to which other objects defer their MoML
definitions.public void setUndoable(boolean undoable)
undoable
- whether or not this change should be treated
as an incremental change that is undoablepublic void setMergeWithPreviousUndo(boolean mergeWithPrevious)
mergeWithPrevious
- whether or not this change should be mergedpublic void setReportErrorsToHandler(boolean report)
report
- False to disable error reporting.ErrorHandler
protected void _execute() throws java.lang.Exception
_execute
in class ChangeRequest
java.lang.Exception
- If an exception is thrown
while evaluating the request.protected void _postParse(MoMLParser parser)
parser
- The parserprotected void _preParse(MoMLParser parser)
parser
- The parser