// handle the event dispatch specially: An event is only
// dispatched if both the head and the tail are attached.
// This rather obnoxious hack is here because edge creation
// is tricky and we can't rerender the edge while we are dragging
// it.
MoMLChangeRequest request = new MoMLChangeRequest(
ActorGraphModel.this, container, moml.toString()) {
protected void _execute() throws Exception {
// If nonEmptyMoML is false, then the MoML code is empty.
// Do not execute it, as this will put spurious empty
// junk on the undo stack.
if (nonEmptyMoML) {
super._execute();
}
link.setHead(newLinkHead);
if (relationNameToAdd != null) {
ComponentRelation relation = container
.getRelation(relationNameToAdd);
if (relation == null) {
throw new InternalErrorException(
"Tried to find relation with name "
+ relationNameToAdd
+ " in context " + container);
}
link.setRelation(relation);
} else {
link.setRelation(null);
}
}
};
// Handle what happens if the mutation fails.
request.addChangeListener(new LinkChangeListener(link, container,
failmoml));
request.setUndoable(true);
container.requestChange(request);
}