org.pentaho.reporting.engine.classic.core.Element Java Examples
The following examples show how to use
org.pentaho.reporting.engine.classic.core.Element.
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: MoveUpAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); if ( visualElements.isEmpty() ) { return; } final MassElementStyleUndoEntryBuilder builder = new MassElementStyleUndoEntryBuilder( visualElements ); final MoveDragOperation mop = new MoveDragOperation ( visualElements, new Point(), EmptySnapModel.INSTANCE, EmptySnapModel.INSTANCE ); mop.update( new Point( 0, -5 ), 1 ); mop.finish(); final MassElementStyleUndoEntry massElementStyleUndoEntry = builder.finish(); getActiveContext().getUndo() .addChange( ActionMessages.getString( "MoveUpAction.UndoName" ), massElementStyleUndoEntry ); }
Example #2
Source File: WatermarkElementWriteHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Writes a single element as XML structure. * * @param bundle * the bundle to which to write to. * @param state * the current write-state. * @param xmlWriter * the xml writer. * @param element * the element. * @throws IOException * if an IO error occured. * @throws BundleWriterException * if an Bundle writer. */ public void writeElement( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter xmlWriter, final Element element ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } if ( xmlWriter == null ) { throw new NullPointerException(); } if ( element == null ) { throw new NullPointerException(); } final AttributeList attList = createMainAttributes( element, xmlWriter ); xmlWriter.writeTag( BundleNamespaces.LAYOUT, "watermark", attList, XmlWriterSupport.OPEN ); writeElementBody( bundle, state, element, xmlWriter ); writeChildElements( bundle, state, xmlWriter, (Band) element ); xmlWriter.writeCloseTag(); }
Example #3
Source File: IndexElementWriteHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void writeElement( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter xmlWriter, final Element element ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } if ( xmlWriter == null ) { throw new NullPointerException(); } if ( element == null ) { throw new NullPointerException(); } writeSubReport( bundle, state, xmlWriter, (IndexElement) element ); }
Example #4
Source File: TocElementWriteHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void writeElement( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter xmlWriter, final Element element ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } if ( xmlWriter == null ) { throw new NullPointerException(); } if ( element == null ) { throw new NullPointerException(); } writeSubReport( bundle, state, xmlWriter, (TocElement) element ); }
Example #5
Source File: AbstractElementRenderer.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public Element[] getElementsAt( final double x, final double y ) { if ( logicalPageDrawable == null ) { return new Element[ 0 ]; } final RenderNode[] nodes = logicalPageDrawable.getNodesAt( x, y, null, null ); if ( nodes.length == 0 ) { return new Element[ 0 ]; } final LinkedHashSet<Element> elements = new LinkedHashSet<Element>( nodes.length ); for ( int i = 0; i < nodes.length; i++ ) { final RenderNode node = nodes[ i ]; final Element reportElement = elementsById.get( node.getInstanceId() ); if ( reportElement != null ) { elements.add( reportElement ); } } return elements.toArray( new Element[ elements.size() ] ); }
Example #6
Source File: AbstractRenderComponent.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void leadSelectionChanged( final ReportSelectionEvent event ) { if ( event.getModel().getSelectionCount() != 1 ) { return; } final Object raw = event.getElement(); if ( raw instanceof Element == false ) { return; } Element e = (Element) raw; while ( e != null && e instanceof RootLevelBand == false ) { e = e.getParent(); } if ( e == getRootBand() ) { setFocused( true ); repaintConditionally(); SwingUtilities.invokeLater( new AsyncChangeNotifier() ); } else { setFocused( false ); repaintConditionally(); SwingUtilities.invokeLater( new AsyncChangeNotifier() ); } }
Example #7
Source File: CrosstabEditSupport.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private static String findTitle( final String field, final Band titleHeader ) { final MatcherContext context = new MatcherContext(); context.setMatchSubReportChilds( false ); NodeMatcher m = new AndMatcher( new ElementMatcher( LabelType.INSTANCE ), new AttributeMatcher( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, field ) ); ReportElement match = ReportStructureMatcher.match( context, titleHeader, m ); if ( match == null ) { if ( titleHeader.getElementCount() > 0 ) { Element e = titleHeader.getElement( 0 ); if ( e.getElementType() instanceof LabelType ) { return e.getAttributeTyped( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, String.class ); } } return null; } return match.getAttributeTyped( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, String.class ); }
Example #8
Source File: TextAlignmentCenterAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); for ( Element element : visualElements ) { final ElementStyleSheet styleSheet = element.getStyle(); undos.add( StyleEditUndoEntry.createConditional( element, ElementStyleKeys.ALIGNMENT, ElementAlignment.CENTER ) ); styleSheet.setStyleProperty( ElementStyleKeys.ALIGNMENT, ElementAlignment.CENTER ); element.notifyNodePropertiesChanged(); } getActiveContext().getUndo().addChange( ActionMessages.getString( "TextAlignmentCenterAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example #9
Source File: SimpleStyleRuleMatcher.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private ReportElement getPreviousReportElement( final ReportElement e ) { final Section parentSection = e.getParentSection(); if ( parentSection == null ) { return null; } final int count = parentSection.getElementCount(); for ( int i = 0; i < count; i += 1 ) { final Element element = parentSection.getElement( i ); if ( e == element ) { if ( i == 0 ) { return null; } else { return parentSection.getElement( i - 1 ); } } } return null; }
Example #10
Source File: CrosstabGroupElementWriteHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Writes a single element as XML structure. * * @param bundle * the bundle to which to write to. * @param state * the current write-state. * @param xmlWriter * the xml writer. * @param element * the element. * @throws IOException * if an IO error occured. * @throws BundleWriterException * if an Bundle writer. */ public void writeElement( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter xmlWriter, final Element element ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } if ( xmlWriter == null ) { throw new NullPointerException(); } if ( element == null ) { throw new NullPointerException(); } final AttributeList attList = createMainAttributes( element, xmlWriter ); xmlWriter.writeTag( BundleNamespaces.LAYOUT, "crosstab", attList, XmlWriterSupport.OPEN ); writeElementBody( bundle, state, element, xmlWriter ); writeChildElements( bundle, state, xmlWriter, (Section) element ); xmlWriter.writeCloseTag(); }
Example #11
Source File: TextAlignmentCenterAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void updateSelection() { super.updateSelection(); final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); if ( visualElements.isEmpty() ) { setSelected( false ); return; } final Element element = visualElements.get( 0 ); final ElementStyleSheet styleSheet = element.getStyle(); setSelected( ElementAlignment.CENTER.equals( styleSheet.getStyleProperty( ElementStyleKeys.ALIGNMENT ) ) ); }
Example #12
Source File: ResourceMessageElementWriteHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Writes a single element as XML structure. * * @param bundle * the bundle to which to write to. * @param state * the current write-state. * @param xmlWriter * the xml writer. * @param element * the element. * @throws IOException * if an IO error occured. * @throws BundleWriterException * if an Bundle writer. */ public void writeElement( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter xmlWriter, final Element element ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } if ( xmlWriter == null ) { throw new NullPointerException(); } if ( element == null ) { throw new NullPointerException(); } final AttributeList attList = createMainAttributes( element, xmlWriter ); xmlWriter.writeTag( BundleNamespaces.LAYOUT, "resource-message", attList, XmlWriterSupport.OPEN ); writeElementBody( bundle, state, element, xmlWriter ); xmlWriter.writeCloseTag(); }
Example #13
Source File: StrikethroughAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); Boolean value = null; for ( Element element : visualElements ) { final ElementStyleSheet styleSheet = element.getStyle(); if ( value == null ) { if ( styleSheet.getBooleanStyleProperty( TextStyleKeys.STRIKETHROUGH ) ) { value = Boolean.FALSE; } else { value = Boolean.TRUE; } } undos.add( StyleEditUndoEntry.createConditional( element, TextStyleKeys.STRIKETHROUGH, value ) ); styleSheet.setStyleProperty( TextStyleKeys.STRIKETHROUGH, value ); element.notifyNodePropertiesChanged(); } getActiveContext().getUndo().addChange( ActionMessages.getString( "StrikethroughAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example #14
Source File: ElementEditUndoEntry.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public ElementEditUndoEntry( final InstanceID target, final int position, final Element oldElement, final Element newElement ) { if ( position < 0 ) { throw new IllegalArgumentException(); } if ( target == null ) { throw new NullPointerException(); } this.target = target; this.position = position; this.oldElement = oldElement; this.newElement = newElement; }
Example #15
Source File: TextTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testWhitespaceCollapse() { final DefaultRenderableTextFactory textFactory = new DefaultRenderableTextFactory( new HtmlOutputProcessorMetaData( HtmlOutputProcessorMetaData.PAGINATION_NONE ) ); textFactory.startText(); CodePointBuffer buffer = Utf16LE.getInstance().decodeString( "T T T T", null ); //$NON-NLS-1$ final int[] data = buffer.getBuffer(); final Element element = new Element(); final int length = buffer.getLength(); element.getStyle().setStyleProperty( TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.DISCARD ); final RenderNode[] renderNodes = textFactory.createText( data, 0, length, SimpleStyleResolver.resolveOneTime( element ), LegacyType.INSTANCE, new InstanceID(), ReportAttributeMap.EMPTY_MAP ); final RenderNode[] finishNodes = textFactory.finishText(); }
Example #16
Source File: HtmlRichTextConverter.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private void configureBand( final javax.swing.text.Element textElement, final Band band ) { final HTML.Tag tag = findTag( textElement.getAttributes() ); if ( tag == null ) { if ( "paragraph".equals( textElement.getName() ) || "section".equals( textElement.getName() ) ) { band.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "block" ); band.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float( -100 ) ); band.setName( textElement.getName() ); } else { band.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "inline" ); band.setName( textElement.getName() ); } return; } if ( BLOCK_ELEMENTS.contains( tag ) ) { band.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "block" ); band.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float( -100 ) ); band.setName( String.valueOf( tag ) ); } else { band.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "inline" ); band.setName( String.valueOf( tag ) ); } }
Example #17
Source File: AbstractElementWriteHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void writeStyleExpressions( final WriteableDocumentBundle bundle, final BundleWriterState state, final Element element, final XmlWriter writer ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } if ( element == null ) { throw new NullPointerException(); } if ( writer == null ) { throw new NullPointerException(); } // write style expressions. final Map<StyleKey, Expression> styleExpressions = element.getStyleExpressions(); for ( final Map.Entry<StyleKey, Expression> entry : styleExpressions.entrySet() ) { final StyleKey key = entry.getKey(); final Expression ex = entry.getValue(); ExpressionWriterUtility.writeStyleExpression( bundle, state, ex, writer, key, BundleNamespaces.LAYOUT, "style-expression" ); } }
Example #18
Source File: PageFooterElementWriteHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Writes a single element as XML structure. * * @param bundle * the bundle to which to write to. * @param state * the current write-state. * @param xmlWriter * the xml writer. * @param element * the element. * @throws IOException * if an IO error occured. * @throws BundleWriterException * if an Bundle writer. */ public void writeElement( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter xmlWriter, final Element element ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } if ( xmlWriter == null ) { throw new NullPointerException(); } if ( element == null ) { throw new NullPointerException(); } final AttributeList attList = createMainAttributes( element, xmlWriter ); xmlWriter.writeTag( BundleNamespaces.LAYOUT, "page-footer", attList, XmlWriterSupport.OPEN ); writeElementBody( bundle, state, element, xmlWriter ); writeChildElements( bundle, state, xmlWriter, (Band) element ); xmlWriter.writeCloseTag(); }
Example #19
Source File: EditLegacyChartAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void updateSelection() { if ( isSingleElementSelection() == false ) { setEnabled( false ); return; } final Object selectedElement = getSelectionModel().getSelectedElement( 0 ); if ( selectedElement instanceof Section ) { setEnabled( false ); return; } if ( selectedElement instanceof Element ) { final Element element = (Element) selectedElement; setEnabled( element.getElementType() instanceof LegacyChartType ); } else { setEnabled( false ); } }
Example #20
Source File: EditContentRefAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void actionPerformed( final ActionEvent e ) { if ( isSingleElementSelection() == false ) { return; } final Object o = getSelectionModel().getLeadSelection(); if ( o instanceof Element == false ) { return; } final Element element = (Element) o; final AttributeMetaData data = element.getElementType().getMetaData().getAttributeDescription ( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE ); if ( data == null ) { return; } if ( "Resource".equals( data.getValueRole() ) == false ) // NON-NLS { return; } final CustomPropertyEditorDialog editorDialog; final Component window = getReportDesignerContext().getView().getParent(); if ( window instanceof Frame ) { editorDialog = new CustomPropertyEditorDialog( (Frame) window ); } else if ( window instanceof Dialog ) { editorDialog = new CustomPropertyEditorDialog( (Dialog) window ); } else { editorDialog = new CustomPropertyEditorDialog(); } editorDialog.setTitle( ActionMessages.getString( "EditContentRefAction.Text" ) ); final ResourcePropertyEditor propertyEditor = new ResourcePropertyEditor( getActiveContext() ); propertyEditor.setValue ( element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE ) ); if ( editorDialog.performEdit( propertyEditor ) ) { element.setAttribute ( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, propertyEditor.getValue() ); } }
Example #21
Source File: DateFieldElementFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a new TextElement containing a date filter structure. * * @param name * the name of the new element * @param bounds * the bounds of the new element * @param paint * the text color of this text element * @param alignment * the horizontal text alignment. * @param valign * the vertical text alignment * @param font * the font for this element * @param nullString * the text used when the value of this element is null * @param format * the SimpleDateFormat used to format the date * @param field * the fieldname to retrieve values from * @return a report element for displaying a java.util.Date value. * @throws NullPointerException * if bounds, name, format or field are null * @throws IllegalArgumentException * if the given alignment is invalid * @deprecated Use a more fine-grained approach to define this element by using the element-factory directly. */ public static Element createDateElement( final String name, final Rectangle2D bounds, final Color paint, final ElementAlignment alignment, final ElementAlignment valign, final FontDefinition font, final String nullString, final DateFormat format, final String field ) { final DateFieldElementFactory factory = new DateFieldElementFactory(); factory.setX( new Float( bounds.getX() ) ); factory.setY( new Float( bounds.getY() ) ); factory.setMinimumWidth( new Float( bounds.getWidth() ) ); factory.setMinimumHeight( new Float( bounds.getHeight() ) ); factory.setName( name ); factory.setColor( paint ); factory.setHorizontalAlignment( alignment ); factory.setVerticalAlignment( valign ); if ( font != null ) { factory.setFontName( font.getFontName() ); factory.setFontSize( new Integer( font.getFontSize() ) ); factory.setBold( ElementFactory.getBooleanValue( font.isBold() ) ); factory.setItalic( ElementFactory.getBooleanValue( font.isItalic() ) ); factory.setEncoding( font.getFontEncoding( font.getFontEncoding( null ) ) ); factory.setUnderline( ElementFactory.getBooleanValue( font.isUnderline() ) ); factory.setStrikethrough( ElementFactory.getBooleanValue( font.isStrikeThrough() ) ); factory.setEmbedFont( ElementFactory.getBooleanValue( font.isEmbeddedFont() ) ); } factory.setNullString( nullString ); factory.setFormat( format ); factory.setFieldname( field ); return factory.createElement(); }
Example #22
Source File: TreeSelectionHelper.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static TreePath getPathForNode( final ReportStructureTreeModel treeModel, final Object currentSelection ) { if ( currentSelection instanceof Element ) { return getBasePathForNode( (Element) currentSelection, treeModel.getReport() ); } if ( currentSelection instanceof DataFactory ) { final DataFactory params = treeModel.getDataFactoryElement(); if ( treeModel.getIndexOfChild( params, currentSelection ) < 0 ) { return null; } return new TreePath( new Object[] { treeModel.getRoot(), params, currentSelection } ); } return null; }
Example #23
Source File: DefaultReportSelectionModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private Object computeKey( final Object o ) { if ( o instanceof Element ) { final Element e = (Element) o; return e.getObjectID(); } else { return System.identityHashCode( o ); } }
Example #24
Source File: VisualAttributeTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private Expression computeExpressionValue( final AttributeMetaData metaData, final int row ) { final AttributeDataBackend dataBackend1 = getAttributeDataBackend(); final Object[] expressionValues = dataBackend1.getExpressionValues(); final Object o = expressionValues[ row ]; if ( o == NULL_INDICATOR ) { return null; } if ( o != null ) { return (Expression) o; } if ( metaData.isDesignTimeValue() ) { expressionValues[ row ] = NULL_INDICATOR; return null; } Expression lastElement = null; final Element[] elements = dataBackend1.getData(); if ( elements.length > 0 ) { final Element element = elements[ 0 ]; lastElement = element.getAttributeExpression( metaData.getNameSpace(), metaData.getName() ); } if ( lastElement != null ) { expressionValues[ row ] = lastElement; } else { expressionValues[ row ] = NULL_INDICATOR; } return lastElement; }
Example #25
Source File: LegacyType.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns the unformated raw value. Whether that raw value is useable for the export is beyond the scope of this API * definition, but providing access to {@link Number} or {@link java.util.Date} objects is a good idea. * * @param runtime * the expression runtime that is used to evaluate formulas and expressions when computing the value of this * filter. * @param element * @return the raw data. */ public Object getRawValue( final ExpressionRuntime runtime, final ReportElement element ) { if ( !( element instanceof Element ) ) { return null; } final Element e = (Element) element; final DataSource source = e.getDataSource(); if ( source instanceof RawDataSource ) { final RawDataSource rds = (RawDataSource) source; return rds.getRawValue( runtime, element ); } return e.getDataSource().getValue( runtime, element ); }
Example #26
Source File: AutoGeneratorUtility.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static Element generateHeaderElement( final String fieldName ) { final Element headerElement = new Element(); headerElement.getStyle().setStyleProperty( ElementStyleKeys.DYNAMIC_HEIGHT, Boolean.TRUE ); headerElement.setElementType( new LabelType() ); headerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, fieldName ); headerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING, Boolean.TRUE ); headerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES, Boolean.TRUE ); return headerElement; }
Example #27
Source File: Prd3159IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testLoadSave() throws Exception { final ResourceKey key = createImageKey(); final Element element = new Element(); element.setElementType( new ContentType() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, key ); // first, create the report with an embedded resource in it. final MasterReport report = new MasterReport(); report.getReportHeader().addElement( element ); // .. save it. saveReport( report, new File( "bin/test-tmp/prd-3159-load-save-1.prpt" ) ); // load it to establish the context in all resource-keys .. final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); final Resource resource = mgr.createDirectly( new File( "bin/test-tmp/prd-3159-load-save-1.prpt" ), MasterReport.class ); // save it once, that changes the bundle ... final MasterReport report2 = (MasterReport) resource.getResource(); saveReport( report2, new File( "bin/test-tmp/prd-3159-load-save-2.prpt" ) ); // save it twice, that triggers the crash... saveReport( report2, new File( "bin/test-tmp/prd-3159-load-save-2.prpt" ) ); final ProcessingContext processingContext = new DefaultProcessingContext(); final DebugExpressionRuntime runtime = new DebugExpressionRuntime( new DefaultTableModel(), 0, processingContext ); final Element reportElement = (Element) report2.getReportHeader().getElement( 0 ); final Object designValue = reportElement.getElementType().getDesignValue( runtime, reportElement ); final DefaultImageReference image = (DefaultImageReference) designValue; assertEquals( 20, image.getImageWidth() ); assertEquals( 20, image.getImageHeight() ); }
Example #28
Source File: CrosstabColumnGroupElementWriteHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Writes a single element as XML structure. * * @param bundle * the bundle to which to write to. * @param state * the current write-state. * @param xmlWriter * the xml writer. * @param element * the element. * @throws IOException * if an IO error occured. * @throws BundleWriterException * if an Bundle writer. */ public void writeElement( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter xmlWriter, final Element element ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } if ( xmlWriter == null ) { throw new NullPointerException(); } if ( element == null ) { throw new NullPointerException(); } final AttributeList attList = createMainAttributes( element, xmlWriter ); xmlWriter.writeTag( BundleNamespaces.LAYOUT, "crosstab-column-group", attList, XmlWriterSupport.OPEN ); final CrosstabColumnGroup group = (CrosstabColumnGroup) element; if ( group.getField() != null ) { xmlWriter.writeTag( BundleNamespaces.LAYOUT, "field", XmlWriterSupport.OPEN ); xmlWriter.writeTextNormalized( group.getField(), false ); xmlWriter.writeCloseTag(); } writeElementBody( bundle, state, element, xmlWriter ); writeChildElements( bundle, state, xmlWriter, (Section) element ); xmlWriter.writeCloseTag(); }
Example #29
Source File: RichTextRenderingIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static Element createDataItem( final String text, final float width, final float height ) { final Element label = new Element(); label.setName( "Label" ); label.setElementType( LabelType.INSTANCE ); label.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text ); label.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, width ); label.getStyle().setStyleProperty( ElementStyleKeys.MAX_WIDTH, width ); label.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, height ); label.getStyle().setStyleProperty( ElementStyleKeys.MAX_HEIGHT, height ); return label; }
Example #30
Source File: CrosstabMultiFactDataIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
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; }