if (activeContext == null)
{
return;
}
final CrosstabOtherGroup newGroup = new CrosstabOtherGroup();
try
{
Object selectedElement = null;
if (getSelectionModel().getSelectionCount() > 0)
{
selectedElement = getSelectionModel().getSelectedElement(0);
}
if (selectedElement instanceof CrosstabOtherGroup)
{
// 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));
}
}
catch (Exception ex)
{
UncaughtExceptionsModel.getInstance().addException(ex);