if (parent != null)
{
final GroupBody body = parent.getBody();
final GroupDataBody newBody = new GroupDataBody();
parent.setBody(newBody);
return new SectionEditUndoEntry
(parent.getObjectID(), ModelUtility.findIndexOf(parent, newBody), body, newBody);
}
return null;
}
if (data instanceof Group)
{
return performDeleteGroup((Group) data);
}
if (data instanceof Element == false)
{
return null;
}
final Element veElement = (Element) data;
final Section parent = veElement.getParentSection();
if (data instanceof SubReport && parent instanceof AbstractRootLevelBand)
{
final AbstractRootLevelBand re = (AbstractRootLevelBand) parent;
final SubReport report = (SubReport) data;
final int index = ModelUtility.findSubreportIndexOf(re, report);
if (index != -1)
{
re.removeSubreport(report);
}
if (veElement.getParent() == null)
{
// remove was a success ...
return new BandedSubreportEditUndoEntry(re.getObjectID(), index, report, null);
}
}
if (parent instanceof Band)
{
final Band band = (Band) parent;
final int index = ModelUtility.findIndexOf(band, veElement);
band.removeElement(veElement);
return new ElementEditUndoEntry(band.getObjectID(), index, veElement, null);
}
if (data instanceof GroupHeader)
{
final Group g = (Group) parent;
final GroupHeader oldHeader = g.getHeader();
final GroupHeader newHeader = new GroupHeader();
g.setHeader(newHeader);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newHeader), oldHeader, newHeader);
}
if (data instanceof GroupFooter)
{
final Group g = (Group) parent;
final GroupFooter oldFooter = g.getFooter();
final GroupFooter newFooter = new GroupFooter();
g.setFooter(newFooter);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newFooter), oldFooter, newFooter);
}
if (data instanceof ReportFooter)
{
final AbstractReportDefinition g = (AbstractReportDefinition) parent;
final ReportFooter oldFooter = g.getReportFooter();
final ReportFooter newFooter = new ReportFooter();
g.setReportFooter(newFooter);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newFooter), oldFooter, newFooter);
}
if (data instanceof ReportHeader)
{
final AbstractReportDefinition g = (AbstractReportDefinition) parent;
final ReportHeader oldHeader = g.getReportHeader();
final ReportHeader newHeader = new ReportHeader();
g.setReportHeader(newHeader);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newHeader), oldHeader, newHeader);
}
if (data instanceof PageHeader)
{
final AbstractReportDefinition g = (AbstractReportDefinition) parent;
final PageHeader oldHeader = g.getPageHeader();
final PageHeader newHeader = new PageHeader();
g.setPageHeader(newHeader);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newHeader), oldHeader, newHeader);
}
if (data instanceof PageFooter)
{
final AbstractReportDefinition g = (AbstractReportDefinition) parent;
final PageFooter oldFooter = g.getPageFooter();
final PageFooter newFooter = new PageFooter();
g.setPageFooter(newFooter);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newFooter), oldFooter, newFooter);
}
if (data instanceof ItemBand)
{
final GroupDataBody g = (GroupDataBody) parent;
final ItemBand oldBand = g.getItemBand();
final ItemBand newBand = new ItemBand();
g.setItemBand(newBand);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newBand), oldBand, newBand);
}
if (data instanceof NoDataBand)
{
final GroupDataBody g = (GroupDataBody) parent;
final NoDataBand oldBand = g.getNoDataBand();
final NoDataBand newBand = new NoDataBand();
g.setNoDataBand(newBand);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newBand), oldBand, newBand);
}
if (data instanceof DetailsHeader)
{
final GroupDataBody g = (GroupDataBody) parent;
final DetailsHeader oldHeader = g.getDetailsHeader();
final DetailsHeader newHeader = new DetailsHeader();
g.setDetailsHeader(newHeader);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newHeader), oldHeader, newHeader);
}
if (data instanceof DetailsFooter)
{
final GroupDataBody g = (GroupDataBody) parent;
final DetailsFooter oldFooter = g.getDetailsFooter();
final DetailsFooter newFooter = new DetailsFooter();
g.setDetailsFooter(newFooter);
return new SectionEditUndoEntry(g.getObjectID(), ModelUtility.findIndexOf(g, newFooter), oldFooter, newFooter);
}
return null;
}