if (selectedElement == activeContext.getReportDefinition() )
{
// execution order is important here.
// first unlink the old root-group by setting a new one ...
final AbstractReportDefinition report = (AbstractReportDefinition) selectedElement;
final Group rootGroup = report.getRootGroup();
final SubGroupBody body = new SubGroupBody();
newGroup.setBody(body);
report.setRootGroup(newGroup);
// *then* you can set the old-root to the newly inserted group ..
body.setGroup(rootGroup);
activeContext.getUndo().addChange(ActionMessages.getString("InsertGroupAction.UndoName"),
new InsertGroupOnReportUndoEntry(rootGroup, newGroup));
return;
}
if (selectedElement instanceof RelationalGroup == false)
{
return;
}
final RelationalGroup selectedGroup = (RelationalGroup) selectedElement;
final GroupBody bodyElement = selectedGroup.getBody();
if (bodyElement instanceof SubGroupBody)
{
final SubGroupBody subGroupBodyReportElement = (SubGroupBody) bodyElement;
final Group oldBodyContent = subGroupBodyReportElement.getGroup();
final SubGroupBody body = new SubGroupBody();
newGroup.setBody(body);
subGroupBodyReportElement.setGroup(newGroup);
body.setGroup(oldBodyContent);