2

我想在 Eclipse Indigo 中将以前设计的 BIRT 报告呈现为 HTML。我正在使用 BIRT 4.2.1。当我在普通的 Java 应用程序中执行此操作时,它运行良好。但是,当我想从 RCP 应用程序中执行相同操作时,它不会。

这是我的代码:

    IRunAndRenderTask task=null;
    IReportEngine engine=null;
    EngineConfig config = null;
    IReportRunnable design = null;

    try{

        config = new EngineConfig( );

        IReportEngineFactory factory = (IReportEngineFactory) Platform.
        createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );

        engine = factory.createReportEngine( config );
        //use this if the report is in the bundle
        Bundle bundle = org.eclipse.core.runtime.Platform.getBundle("com.accenture.workforceplanning.ui");      
        URL url = FileLocator.find(bundle, new Path("/reports/scenarioAnalysis.rptdesign"), null);
        String rpt = FileLocator.toFileURL(url).getPath();

    //Open the report design
    design = engine.openReportDesign(rpt); 
    task = engine.createRunAndRenderTask(design);


    HTMLRenderOption options = new HTMLRenderOption();      
    options.setImageDirectory("./");
    URL url1 = FileLocator.find(bundle, new Path("/reports"), null);
    String rpt1 = FileLocator.toFileURL(url1).getPath();
    options.setOutputFileName(rpt1 +"/scenarioAnalysis.html");
    options.setOutputFormat("html");

    task.setRenderOption(options);
    task.run();
    task.close();
    engine.destroy();
    }catch( Exception ex){
        ex.printStackTrace();
    }               

当程序到达 task.run() 时,我收到以下错误:

org.eclipse.birt.report.engine.api.UnsupportedFormatException: The output format html is not supported.
    at org.eclipse.birt.report.engine.api.impl.EngineTask.setupRenderOption(EngineTask.java:2047)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:96)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
    at com.accenture.workforceplanning.ui.composites.OutputComposite.reportToHtml(OutputComposite.java:470)
    at com.accenture.workforceplanning.ui.composites.OutputComposite.createReportScenarioAnalysis(OutputComposite.java:410)
    at com.accenture.workforceplanning.ui.composites.OutputComposite.access$6(OutputComposite.java:308)
    at com.accenture.workforceplanning.ui.composites.OutputComposite$4.widgetSelected(OutputComposite.java:214)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at com.accenture.workforceplanning.application.Application.start(Application.java:26)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

对于我要渲染的任何类型的输出格式,它都会发生相同的情况。

知道我做错了什么吗?

谢谢

玉乐溪

4

1 回答 1

2

我已经设法解决了问题。万一有人遇到同样的问题,我就是这样做的: 我手动将所有 BIRT 插件添加到我的 RCP 应用程序产品的依赖项中(由于某种原因,没有添加所需的插件)。我仍然不知道丢失的插件是什么。但该应用程序现在工作正常。

于 2013-01-12T14:57:27.363 回答