}
protected void writeTable(TableComponent table, ComponentKey componentKey,
final JRXmlWriter reportWriter) throws IOException
{
final JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper();
XmlNamespace namespace = new XmlNamespace(
ComponentsExtensionsRegistryFactory.NAMESPACE,
componentKey.getNamespacePrefix(),
ComponentsExtensionsRegistryFactory.XSD_LOCATION);
writer.startElement("table", namespace);
reportWriter.writeDatasetRun(table.getDatasetRun());
ColumnVisitor<Void> columnWriter = new ColumnVisitor<Void>()
{
public Void visitColumn(Column column)
{
try
{
writer.startElement("column");
writer.addAttribute("width", column.getWidth());
writer.writeExpression(JRXmlConstants.ELEMENT_printWhenExpression,
JRXmlWriter.JASPERREPORTS_NAMESPACE,
column.getPrintWhenExpression(), false);
writeTableCell(column.getTableHeader(), "tableHeader", reportWriter);
writeTableCell(column.getTableFooter(), "tableFooter", reportWriter);
writeGroupCells(column.getGroupHeaders(), "groupHeader", reportWriter);
writeGroupCells(column.getGroupFooters(), "groupFooter", reportWriter);
writeTableCell(column.getColumnHeader(), "columnHeader", reportWriter);
writeTableCell(column.getColumnFooter(), "columnFooter", reportWriter);
writeTableCell(column.getDetailCell(), "detailCell", reportWriter);
writer.closeElement();
}
catch (IOException e)
{
throw new JRRuntimeException(e);
}
return null;
}
public Void visitColumnGroup(ColumnGroup columnGroup)
{
try
{
writer.startElement("columnGroup");
writer.addAttribute("width", columnGroup.getWidth());
writer.writeExpression(JRXmlConstants.ELEMENT_printWhenExpression,
JRXmlWriter.JASPERREPORTS_NAMESPACE,
columnGroup.getPrintWhenExpression(), false);
writeTableCell(columnGroup.getTableHeader(), "tableHeader", reportWriter);
writeTableCell(columnGroup.getTableFooter(), "tableFooter", reportWriter);
writeGroupCells(columnGroup.getGroupHeaders(), "groupHeader", reportWriter);
writeGroupCells(columnGroup.getGroupFooters(), "groupFooter", reportWriter);
writeTableCell(columnGroup.getColumnHeader(), "columnHeader", reportWriter);
writeTableCell(columnGroup.getColumnFooter(), "columnFooter", reportWriter);
// deep
for (BaseColumn column : columnGroup.getColumns())
{
column.visitColumn(this);
}
writer.closeElement();
}
catch (IOException e)
{
throw new JRRuntimeException(e);
}
return null;
}
};
for (BaseColumn column : table.getColumns())
{
column.visitColumn(columnWriter);
}
writer.closeElement();
}