moml.append("</group>\n");
failmoml.append("</group>\n");
final String relationNameToAdd = relationName;
MoMLChangeRequest request = new MoMLChangeRequest(
FSMGraphModel.this, container, moml.toString()) {
protected void _execute() throws Exception {
super._execute();
link.setHead(newArcHead);
if (relationNameToAdd != null) {
ComponentRelation relation = ((CompositeEntity) getPtolemyModel())
.getRelation(relationNameToAdd);
link.setRelation(relation);
}
}
};
// Handle what happens if the mutation fails.
request.addChangeListener(new ChangeListener() {
public void changeFailed(ChangeRequest change,
Exception exception) {
// If we fail here, then we remove the link entirely.
_linkSet.remove(link);
link.setHead(null);
link.setTail(null);
link.setRelation(null);
// and queue a new change request to clean up the model
// Note: JDK1.2.2 requires that this variable not be
// called request or we get a compile error.
MoMLChangeRequest requestChange = new MoMLChangeRequest(
FSMGraphModel.this, container, failmoml.toString());
// Fail moml execution not undoable
container.requestChange(requestChange);
}