<p>I have a Report-File CustomView.rptdesing and a Library-File Space.rptlibrary.</p>
<p>The File Space.rptlibrary has as content only one Label.</p>
<p> </p>
<p>The File CustomView.rptdesing has as content only a grid.<br>
I want now to add after this Grid of CustomView.rptdesing the Content of the file Space.rptlibrary.</p>
<p> </p>
<p>This is my corresponding source-code</p>
<pre class="_prettyXprint _lang-">
public class PrintReport {
private final static String BIRT_HOME = "C:/dev/libraries/birt-runtime-4_4_1/ReportEngine";
private final static String LOG_DIR = "./birt/logs/";
private final static String OUTPUT_DIR = "./birt/outputs/";
private final static String RESOURCE_DIR = "./birt/resources/";
private final static String REPORT = "./birt/reports/CustomerView.rptdesign";
private final static String LIBRARY = "./birt/reports/libraries/Space.rptlibrary";
private final static String DATA_SOURCE = "My-Data-Source-01";
private final static String DATA_SET = "My-Data-Set-01";
IDesignEngine designEngine = null;
IDesignEngineFactory designEngineFactory = null;
IReportEngine reportEngine = null;
SessionHandle session = null;
IReportRunnable runnable = null;
LibraryHandle libraryHandleSpace = null;
LibraryHandle libraryHandleOrder = null;
public static void main(String[] args) {
PrintReport printReport;
printReport = new PrintReport();
printReport.generateFile();
} catch (BirtException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
public PrintReport() throws BirtException {
EngineConfig engineConfig = new EngineConfig();
IPlatformContext context = new PlatformFileContext();
engineConfig.setLogConfig(LOG_DIR, Level.FINE);
engineConfig.setEngineContext(context);
try {
Platform.startup(engineConfig);
IReportEngineFactory reportEngineFactory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
reportEngine = reportEngineFactory.createReportEngine(engineConfig);
runnable = reportEngine.openReportDesign(REPORT);
final DesignConfig designConfig = new DesignConfig();
designConfig.setBIRTHome(BIRT_HOME);
designEngineFactory = (IDesignEngineFactory) Platform
.createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY);
designEngine = designEngineFactory.createDesignEngine(designConfig);
session = designEngine.newSessionHandle(ULocale.ENGLISH);
} catch (BirtException e) {
e.printStackTrace();
reportEngine.destroy();
}
}
@SuppressWarnings("deprecation")
private void generateFile() throws EngineException,
SemanticException {
// Add Library
LibraryHandle libraryHandleSpace = null;
ReportDesignHandle reportDesignHandle = (ReportDesignHandle) runnable.getDesignHandle();
ElementFactory elementFactory = reportDesignHandle.getElementFactory();
try {
libraryHandleSpace = session.openLibrary(LIBRARY);
reportDesignHandle.includeLibrary(LIBRARY, "LL");
DesignElementHandle dehSpace = libraryHandleSpace.findElement("Space");
reportDesignHandle.getBody().add(dehSpace);
=> !!!get here the error!!!
</pre>
<p>I get the following error:</p>
<pre class="_prettyXprint _lang-">
org.eclipse.birt.report.model.api.command.ContentException: Element "Label("Space")" is not allowed to be added into the (Body) of "Report Design", for it is already in the design tree.
at org.eclipse.birt.report.model.util.ContentExceptionFactory.createContentException(ContentExceptionFactory.java:43)
at org.eclipse.birt.report.model.command.AbstractContentCommand.add(AbstractContentCommand.java:123)
at org.eclipse.birt.report.model.command.AbstractContentCommand.add(AbstractContentCommand.java:258)
at org.eclipse.birt.report.model.api.SlotHandle.add(SlotHandle.java:126)
at org.eclipse.birt.report.model.api.SlotHandle.add(SlotHandle.java:80)
at org.print.PrintReport.generateFile(PrintReport.java:134)
at org.print.PrintReport.main(PrintReport.java:79)
</pre>
<p>What make i wrong.</p>