{
// execution order is important here.
// first unlink the old root-group by setting a new one ...
final CrosstabOtherGroup selectedGroup = (CrosstabOtherGroup) selectedElement;
final GroupBody oldGroupBody = selectedGroup.getBody();
final CrosstabOtherGroupBody newGroupBody = new CrosstabOtherGroupBody(newGroup);
selectedGroup.setBody(newGroupBody);
newGroup.setBody(oldGroupBody);
activeContext.getUndo().addChange(ActionMessages.getString("InsertCrosstabOtherGroupAction.UndoName"),
new InsertGroupBodyOnGroupUndoEntry(selectedGroup.getObjectID(), oldGroupBody, newGroupBody));
}
if (selectedElement instanceof CrosstabGroup)
{
final CrosstabGroup selectedGroup = (CrosstabGroup) selectedElement;
final GroupBody oldGroupBody = selectedGroup.getBody();
final CrosstabOtherGroupBody newGroupBody = new CrosstabOtherGroupBody(newGroup);
selectedGroup.setBody(newGroupBody);
newGroup.setBody(oldGroupBody);
activeContext.getUndo().addChange(ActionMessages.getString("InsertCrosstabOtherGroupAction.UndoName"),
new InsertGroupBodyOnGroupUndoEntry(selectedGroup.getObjectID(), oldGroupBody, newGroupBody));