if (position == -1)
{
if (insertElement instanceof SubReport && parent instanceof RootLevelBand)
{
final SubReport subReport = (SubReport) insertElement;
final RootLevelBand arb = (RootLevelBand) parent;
final int subreportPosition = ModelUtility.findSubreportIndexOf(arb, subReport);
if (subreportPosition == -1)
{
throw new IllegalStateException("A newly inserted section must have a position within its parent.");
}
else
{
undos.add(new BandedSubreportEditUndoEntry(parent.getObjectID(), arb.getSubReportCount(), null, subReport));
}
}
else
{
throw new IllegalStateException("A newly inserted section must have a position within its parent.");