itemBand.setVisible( true ); itemBand.setLayout( BandStyleKeys.LAYOUT_AUTO ); groupData.setItemBand( itemBand ); group.setBody( groupData ); report.setRootGroup( group );
public void setElementAt( final int position, final Element element ) { switch ( position ) { case 0: setDetailsHeader( (DetailsHeader) element ); break; case 1: setItemBand( (ItemBand) element ); break; case 2: setNoDataBand( (NoDataBand) element ); break; case 3: setDetailsFooter( (DetailsFooter) element ); break; default: throw new IndexOutOfBoundsException(); } }
@Test( expected = NullPointerException.class ) public void testSetItemBandException() { body.setItemBand( null ); }
@Test public void testSetItemBand() { ItemBand itemBand = mock( ItemBand.class ); body.setItemBand( itemBand ); assertThat( body.getItemBand(), is( equalTo( itemBand ) ) ); assertThat( (GroupDataBody) body.getItemBand().getParentSection(), is( equalTo( body ) ) ); ItemBand band = new ItemBand(); band.setParent( body ); body.setItemBand( band ); assertThat( body.getItemBand(), is( equalTo( itemBand ) ) ); }
@Test public void testRemoveElement() { ItemBand itemBand = mock( ItemBand.class ); NoDataBand band = mock( NoDataBand.class ); DetailsHeader header = mock( DetailsHeader.class ); DetailsFooter footer = mock( DetailsFooter.class ); body.setItemBand( itemBand ); body.setNoDataBand( band ); body.setDetailsHeader( header ); body.setDetailsFooter( footer ); body.removeElement( itemBand ); assertThat( itemBand.getParentSection(), is( nullValue() ) ); assertThat( body.getItemBand(), is( not( equalTo( itemBand ) ) ) ); assertThat( (GroupDataBody) body.getItemBand().getParentSection(), is( equalTo( body ) ) ); body.removeElement( band ); assertThat( band.getParentSection(), is( nullValue() ) ); assertThat( body.getNoDataBand(), is( not( equalTo( band ) ) ) ); assertThat( (GroupDataBody) body.getNoDataBand().getParentSection(), is( equalTo( body ) ) ); body.removeElement( header ); assertThat( header.getParentSection(), is( nullValue() ) ); assertThat( body.getDetailsHeader(), is( not( equalTo( header ) ) ) ); assertThat( (GroupDataBody) body.getDetailsHeader().getParentSection(), is( equalTo( body ) ) ); body.removeElement( footer ); assertThat( footer.getParentSection(), is( nullValue() ) ); assertThat( body.getDetailsFooter(), is( not( equalTo( footer ) ) ) ); assertThat( (GroupDataBody) body.getDetailsFooter().getParentSection(), is( equalTo( body ) ) ); }
/** * Done parsing. * * @throws SAXException * if there is a parsing error. */ protected void doneParsing() throws SAXException { super.doneParsing(); final GroupDataBody body = getElement(); if ( noDataBandReadHandler != null ) { body.setNoDataBand( noDataBandReadHandler.getElement() ); } if ( itemBandReadHandler != null ) { body.setItemBand( itemBandReadHandler.getElement() ); } if ( detailsFooterBandReadHandler != null ) { body.setDetailsFooter( detailsFooterBandReadHandler.getElement() ); } if ( detailsHeaderBandReadHandler != null ) { body.setDetailsHeader( detailsHeaderBandReadHandler.getElement() ); } } }
public void installIntoReport( final AbstractReportDefinition report ) throws ParseException { final GroupDataBody originalGroupDataBody = (GroupDataBody) report.getChildElementByType( GroupDataBodyType.INSTANCE ); if ( originalGroupDataBody == null ) { throw new ParseException( "The report is not a relational report, cannot install relational detail sections here" ); } final ItemBand ib = originalGroupDataBody.getItemBand(); final NoDataBand nd = originalGroupDataBody.getNoDataBand(); final DetailsHeader detailsHeader = originalGroupDataBody.getDetailsHeader(); final DetailsFooter detailsFooter = originalGroupDataBody.getDetailsFooter(); final Group newRootGroup = constructRootGroup(); if ( report.getRootGroup() == newRootGroup ) { return; } report.setRootGroup( newRootGroup ); final GroupDataBody groupDataBody = (GroupDataBody) newRootGroup.getChildElementByType( GroupDataBodyType.INSTANCE ); if ( groupDataBody == null ) { return; } groupDataBody.setDetailsFooter( detailsFooter ); groupDataBody.setDetailsHeader( detailsHeader ); groupDataBody.setItemBand( ib ); groupDataBody.setNoDataBand( nd ); } }