Java Code Examples for org.pentaho.reporting.engine.classic.core.Element#setElementType()

The following examples show how to use org.pentaho.reporting.engine.classic.core.Element#setElementType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HtmlRichTextProcessingTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testRichTextParsing() {
  HtmlRichTextConverter richTextConverter = new HtmlRichTextConverter();
  final Element element = new Element();
  element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, RICHTEXT );
  element.setElementType( new LabelType() );
  final Object o = richTextConverter.convert( element, RICHTEXT );
  final Element elementlist = new Element();
  elementlist.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, RICHTEXT );
  elementlist.setElementType( new LabelType() );

  final SimpleStyleResolver styleResolver = new SimpleStyleResolver( true );
  final ResolverStyleSheet resolverTarget = new ResolverStyleSheet();
  styleResolver.resolve( element, resolverTarget );
  elementlist.setComputedStyle( new SimpleStyleSheet( resolverTarget ) );

  final Band o2 = (Band) richTextConverter.convert( elementlist, LISTTEXT );
  ReportElement[] re = o2.getChildElementsByName( "point" );

  assertTrue( re.length == 13 );
  System.out.println( re.length );
  System.out.println( o );
}
 
Example 2
Source File: HtmlRichTextProcessingTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testCSSConversionDefault() {
  final Element element = new Element();
  final Element elementlist = new Element();
  elementlist.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, RICHTEXT );
  elementlist.setElementType( new LabelType() );

  final SimpleStyleResolver styleResolver = new SimpleStyleResolver( true );
  final ResolverStyleSheet resolverTarget = new ResolverStyleSheet();
  styleResolver.resolve( element, resolverTarget );

  RichTextHtmlStyleBuilderFactory richTextBuilder = new RichTextHtmlStyleBuilderFactory();
  String codeCss = richTextBuilder.produceTextStyle( null, new SimpleStyleSheet( resolverTarget ) ).toString();

  String expected = "color: black; font-size: 10pt; font-family: serif; font-weight: normal; font-style: normal; "
          + "text-decoration: none; text-align: left; word-spacing: 0pt; letter-spacing: 0pt; white-space: pre";
  assertEquals( expected, codeCss );
}
 
Example 3
Source File: CrosstabBuilder.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected Element createLabel( final String text, final String labelFor, final boolean splitArea ) {
  final Element element = new Element();
  element.setElementType( LabelType.INSTANCE );
  element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text );
  element.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, split( splitArea, minimumWidth ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, minimumHeight );
  element.getStyle().setStyleProperty( ElementStyleKeys.WIDTH, split( splitArea, prefWidth ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.HEIGHT, prefHeight );
  element.getStyle().setStyleProperty( ElementStyleKeys.MAX_WIDTH, split( splitArea, maximumWidth ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.MAX_HEIGHT, maximumHeight );
  element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING,
      allowMetaDataStyling );
  if ( StringUtils.isEmpty( labelFor ) ) {
    element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES,
        allowMetaDataAttributes );
  } else {
    element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES, true );
  }
  element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, labelFor );
  return element;
}
 
Example 4
Source File: MessageFieldElementFactory.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates the message text element based on the defined settings. Undefined properties will not be set in the
 * generated element.
 *
 * @return the generated numeric text element
 * @see org.pentaho.reporting.engine.classic.core.elementfactory.ElementFactory#createElement()
 */
public Element createElement() {
  final Element element = new Element();
  applyElementName( element );
  applyStyle( element.getStyle() );

  element.setElementType( new MessageType() );
  element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE, getNullString() );
  element
      .setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.MESSAGE_NULL_VALUE, getMessageNullString() );
  element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getFormatString() );
  return element;
}
 
Example 5
Source File: PentahoServlet.java    From pentaho-8-reporting-for-java-developers with Apache License 2.0 5 votes vote down vote up
public static Element createDataItem ( 
   String text)
 { 
   Element label = new Element(); 
label.setElementType( LabelType.INSTANCE ); 
label.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text ); 
label.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH,  100f ); 
label.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 20f ); 
return label; 
 }
 
Example 6
Source File: AutoGeneratorUtility.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Element generateDetailsElement( final String fieldName, final ElementType targetType ) {
  final Element detailsElement = new Element();
  detailsElement.getStyle().setStyleProperty( ElementStyleKeys.DYNAMIC_HEIGHT, Boolean.TRUE );
  detailsElement.setElementType( targetType );
  detailsElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, fieldName );
  detailsElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING,
      Boolean.TRUE );
  detailsElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES,
      Boolean.TRUE );
  return detailsElement;
}
 
Example 7
Source File: CrosstabMultiFactDataIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Element createDataItem( final String text ) {
  final Element label = new Element();
  label.setElementType( LabelType.INSTANCE );
  label.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text );
  label.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 100f );
  label.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 100f );
  return label;
}
 
Example 8
Source File: RelationalReportBuilder.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Element createFieldItem( final String fieldName, final Class aggregationType, final Color background ) {
  final ElementType targetType;
  if ( dataSchemaModel != null ) {
    final DataAttributeContext context = dataSchemaModel.getDataAttributeContext();
    final DataAttributes attributes = dataSchemaModel.getDataSchema().getAttributes( fieldName );
    targetType = AutoGeneratorUtility.createFieldType( attributes, context );
  } else {
    targetType = TextFieldType.INSTANCE;
  }

  final Element element = new Element();
  element.setAttributeExpression( "test-run", "test-value", new CopyValueAsTextExpression( fieldName ) );
  element.setElementType( targetType );
  element.getElementType().configureDesignTimeDefaults( element, Locale.getDefault() );
  element.getStyle().setStyleProperty( ElementStyleKeys.BACKGROUND_COLOR, background );

  if ( targetType instanceof NumberFieldType ) {
    element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING, "0.00;-0.00" );
  }

  element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, fieldName );
  element.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 80f );
  element.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 20f );
  element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_TYPE, aggregationType );
  element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING, Boolean.FALSE );
  return element;
}
 
Example 9
Source File: Prd3514IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testLineBreaksOnStart() throws ReportProcessingException, ContentProcessingException {
  Element textField = new Element();
  textField.setName( "textField" );
  textField.getStyle().setStyleProperty( TextStyleKeys.FONT, "Arial" );
  textField.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, 14 );
  textField.getStyle().setStyleProperty( TextStyleKeys.TEXT_WRAP, TextWrap.NONE );
  textField.getStyle().setStyleProperty( TextStyleKeys.TRIM_TEXT_CONTENT, false );
  textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 97f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 20f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 0f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );
  textField.setElementType( LabelType.INSTANCE );
  textField.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "\nClassic Cars" );

  final MasterReport report = new MasterReport();
  report.getReportHeader().addElement( textField );
  report.setCompatibilityLevel( null );
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, report.getReportHeader(), false, false );
  ModelPrinter.INSTANCE.print( logicalPageBox );

  RenderNode textFieldBox = MatchFactory.findElementByName( logicalPageBox, "textField" );
  assertNotNull( textFieldBox );

  assertEquals( 0, textFieldBox.getY() );

  // box only contains one line, and min-size is set to 8, max size = 20, so the line-height of 14.024 is used.
  assertEquals( StrictGeomUtility.toInternalValue( 28 ), textFieldBox.getHeight() );
}
 
Example 10
Source File: Prd2974IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Element createLabel( final String text ) {
  final Element element = new Element();
  element.setElementType( LabelType.INSTANCE );
  element.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, new Float( 20 ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float( 200 ) );
  element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text );
  return element;
}
 
Example 11
Source File: Prd3688IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Element createDataItem( final String text ) {
  final Element label = new Element();
  label.setElementType( LabelType.INSTANCE );
  label.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text );
  label.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 100f );
  label.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f );
  return label;
}
 
Example 12
Source File: CrosstabDataIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Element createDataItem( final String text ) {
  final Element label = new Element();
  label.setElementType( LabelType.INSTANCE );
  label.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text );
  label.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 100f );
  label.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f );
  return label;
}
 
Example 13
Source File: VerticalLineElementFactory.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a new drawable field element based on the defined properties.
 *
 * @return the generated elements
 * @throws IllegalStateException
 *           if the field name is not set.
 * @see ElementFactory#createElement()
 */
public Element createElement() {
  final Element element = new Element();
  applyElementName( element );
  applyStyle( element.getStyle() );

  element.setElementType( new VerticalLineType() );
  return element;
}
 
Example 14
Source File: CrosstabBuilder.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected Element createFieldItem( final String fieldName,
    final Class<? extends AggregationFunction> aggregationType, final boolean split ) {
  final ElementType targetType;
  if ( dataSchemaModel != null ) {
    final DataAttributeContext context = dataSchemaModel.getDataAttributeContext();
    final DataAttributes attributes = dataSchemaModel.getDataSchema().getAttributes( fieldName );
    targetType = AutoGeneratorUtility.createFieldType( attributes, context );
  } else {
    targetType = TextFieldType.INSTANCE;
  }

  final Element element = new Element();
  element.setElementType( targetType );
  element.getElementType().configureDesignTimeDefaults( element, Locale.getDefault() );

  if ( targetType instanceof NumberFieldType ) {
    element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING, "0.00;-0.00" );
  }

  element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, fieldName );
  element.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, split( split, minimumWidth ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, minimumHeight );
  element.getStyle().setStyleProperty( ElementStyleKeys.WIDTH, split( split, prefWidth ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.HEIGHT, prefHeight );
  element.getStyle().setStyleProperty( ElementStyleKeys.MAX_WIDTH, split( split, maximumWidth ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.MAX_HEIGHT, maximumHeight );
  element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_TYPE, aggregationType );
  element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING,
      allowMetaDataStyling );
  return element;
}
 
Example 15
Source File: RectangleElementReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public RectangleElementReadHandler() {
  element = new Element();
  element.setElementType( new RectangleType() );
  element.getStyle().setStyleProperty( ElementStyleKeys.SCALE, Boolean.TRUE );

}
 
Example 16
Source File: StaticImageReportElementReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public StaticImageReportElementReadHandler() {
  element = new Element();
  element.setElementType( new ContentType() );
  element.getStyle().setStyleProperty( ElementStyleKeys.SCALE, Boolean.TRUE );
}
 
Example 17
Source File: RichTextLineBreakingIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void testWeirdTocLayoutComplex() throws ReportProcessingException, ContentProcessingException {

  if ( !DebugReportRunner.isSafeToTestComplexText() ) {
    return;
  }

  Element textField = new Element();
  textField.setName( "textField" );
  textField.getStyle().setStyleProperty( TextStyleKeys.FONT, "Arial" );
  textField.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, 14 );
  textField.getStyle().setStyleProperty( TextStyleKeys.TEXT_WRAP, TextWrap.NONE );
  textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 97f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 20f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 0f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );
  textField.setElementType( LabelType.INSTANCE );
  textField.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "Classic Cars\n" );

  Element dotField = new Element();
  dotField.setName( "dotField" );
  dotField.getStyle().setStyleProperty( TextStyleKeys.FONT, "Arial" );
  dotField.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, 14 );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.ALIGNMENT, ElementAlignment.RIGHT );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.VALIGNMENT, ElementAlignment.TOP );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 97f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 628.463f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 20f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.WIDTH, 100f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.MAX_WIDTH, 100f );
  dotField.setElementType( LabelType.INSTANCE );
  dotField.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, " Some more data" );

  Band band = new Band();
  band.setName( "outer-box" );
  band.setLayout( "inline" );
  band.getStyle().setStyleProperty( ElementStyleKeys.BOX_SIZING, BoxSizing.CONTENT_BOX );
  band.getStyle().setStyleProperty( ElementStyleKeys.OVERFLOW_X, false );
  band.getStyle().setStyleProperty( ElementStyleKeys.DYNAMIC_HEIGHT, true );
  band.getStyle().setStyleProperty( ElementStyleKeys.OVERFLOW_Y, false );
  band.getStyle().setStyleProperty( TextStyleKeys.LINEHEIGHT, 1f );
  band.getStyle().setStyleProperty( TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.PRESERVE_BREAKS );
  band.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 708f );
  band.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 12f );
  band.getStyle().setStyleProperty( ElementStyleKeys.MAX_HEIGHT, 20f );
  band.addElement( textField );
  band.addElement( dotField );

  final MasterReport report = new MasterReport();
  report.getReportHeader().addElement( band );
  report.setCompatibilityLevel( null );
  report.getReportConfiguration()
      .setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "true" );
  report.getStyle().setStyleProperty( TextStyleKeys.WORDBREAK, true );

  LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, report.getReportHeader(), false, false );

  ParagraphRenderBox outerBox = (ParagraphRenderBox) MatchFactory.findElementByName( logicalPageBox, "outer-box" );
  assertNotNull( outerBox );
  assertEquals( 0, outerBox.getY() );
  assertTrue( outerBox.getHeight() > StrictGeomUtility.toInternalValue( 14 ) );
  assertTrue( outerBox.isComplexParagraph() );

  BlockRenderBox pool = (BlockRenderBox) outerBox.getLineboxContainer();
  assertTrue( pool.getFirstChild() != pool.getLastChild() );
  assertTrue( pool.getFirstChild().getNext() == pool.getLastChild() );
  assertStructure( (RenderBox) pool.getFirstChild() );
  assertStructure( (RenderBox) pool.getLastChild() );

}
 
Example 18
Source File: NumberFieldReportElementReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public NumberFieldReportElementReadHandler() {
  final Element element = new Element();
  element.setElementType( new NumberFieldType() );
  setElement( element );
}
 
Example 19
Source File: WizardProcessor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void configureRelationalGroupFooter( final RelationalGroup group, final GroupDefinition groupDefinition,
                                               final int index )
  throws ReportProcessingException {
  final RootBandDefinition footerDefinition = groupDefinition.getFooter();
  if ( footerDefinition.isVisible() == false ) {
    return;
  }

  if ( groupDefinition.getAggregationFunction() == null && ( groupDefinition.getGroupTotalsLabel() == null
    || groupDefinition.getGroupTotalsLabel().length() == 0 ) ) {
    return;
  }

  final GroupFooter footer = group.getFooter();
  final Boolean repeat = footerDefinition.getRepeat();
  if ( repeat != null ) {
    footer.setRepeat( repeat.booleanValue() );
  }

  final Band content = AutoGeneratorUtility.findGeneratedContent( footer );
  if ( content == null ) {
    return;
  }

  final Class aggFunctionClass = groupDefinition.getAggregationFunction();
  final Element footerValueElement = AutoGeneratorUtility.generateFooterElement
    ( aggFunctionClass, computeElementType( groupDefinition ),
      groupDefinition.getGroupName(), groupDefinition.getField() );

  final Element footerLabelElement = new Element();
  footerLabelElement.setElementType( new LabelType() );
  if ( groupDefinition.getGroupTotalsLabel() != null ) {
    footerLabelElement.setAttribute
      ( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, groupDefinition.getGroupTotalsLabel() );
  } else {
    footerLabelElement.setAttribute
      ( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, groupDefinition.getField() );
    footerLabelElement.setAttribute
      ( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, groupDefinition.getField() );
    footerLabelElement.setAttribute( AttributeNames.Wizard.NAMESPACE,
      AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES, Boolean.TRUE );
  }

  final Band footerElement = new Band();
  footerElement.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_INLINE );
  footerElement.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float( -100 ) );
  footerElement.getStyle().setStyleProperty( ElementStyleKeys.DYNAMIC_HEIGHT, Boolean.TRUE );
  footerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING,
    Boolean.TRUE );
  footerElement.setAttribute
    ( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, groupDefinition.getField() );
  footerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.CACHED_WIZARD_FORMAT_DATA,
    footerDefinition );
  footerElement
    .setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.CACHED_WIZARD_FIELD_DATA, groupDefinition );
  footerElement.addElement( footerLabelElement );
  footerElement.addElement( footerValueElement );

  content.clear();
  content.addElement( footerElement );
}
 
Example 20
Source File: WizardProcessor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void configureRelationalGroupHeader( final RelationalGroup group,
                                               final GroupDefinition groupDefinition,
                                               final int index ) {
  final RootBandDefinition headerDefinition = groupDefinition.getHeader();
  if ( headerDefinition.isVisible() ) {
    final GroupHeader header = group.getHeader();
    final Boolean repeat = headerDefinition.getRepeat();
    if ( repeat != null ) {
      header.setRepeat( repeat.booleanValue() );
    }

    final Band content = AutoGeneratorUtility.findGeneratedContent( header );
    if ( content == null ) {
      return;
    }

    final Element headerLabelElement = new Element();
    headerLabelElement.setElementType( new LabelType() );
    if ( groupDefinition.getDisplayName() != null ) {
      headerLabelElement.setAttribute
        ( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, groupDefinition.getDisplayName() );
    } else {
      headerLabelElement.setAttribute
        ( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, groupDefinition.getField() );
      headerLabelElement.setAttribute
        ( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, groupDefinition.getField() );
      headerLabelElement.setAttribute( AttributeNames.Wizard.NAMESPACE,
        AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES, Boolean.TRUE );
    }

    final Element headerValueElement =
      AutoGeneratorUtility
        .generateDetailsElement( groupDefinition.getField(), computeElementType( groupDefinition ) );
    headerValueElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE, "-" );

    final Band headerElement = new Band();
    headerElement.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_INLINE );
    headerElement.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float( -100 ) );
    headerElement.getStyle().setStyleProperty( ElementStyleKeys.DYNAMIC_HEIGHT, Boolean.TRUE );
    headerElement.setAttribute( AttributeNames.Wizard.NAMESPACE,
      AttributeNames.Wizard.ALLOW_METADATA_STYLING, Boolean.TRUE );
    headerElement.setAttribute
      ( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, groupDefinition.getField() );
    headerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.CACHED_WIZARD_FORMAT_DATA,
      headerDefinition );
    headerElement.addElement( headerLabelElement );
    headerElement.addElement( headerValueElement );
    content.clear();
    content.addElement( headerElement );
  }
}