简体   繁体   English

如何在 Eclipse RCP 中集成 JRViewer

[英]How to integrate JRViewer in Eclipse RCP

I have an RCP application, and it has worked fine ...until now.我有一个 RCP 应用程序,它运行良好......直到现在。

I have to upgrade some modules that read and write xlsm and xlsx files, so I upgrade poi.我要升级一些读写xlsm和xlsx文件的模块,所以我升级了poi。

But it breaks my JasperReport reports, the version was very old, 2.0.3, so I try to upgraded also, to 6.1.0, which contains the version of poi that I need.但它打破了我的 JasperReport 报告,版本很旧,2.0.3,所以我也尝试升级到 6.1.0,其中包含我需要的 poi 版本。

But I can't make it work inside the viewpart.但我不能让它在 viewpart 内工作。

This is how it look now, with jasperreports2.0.3这就是它现在的样子,使用 jasperreports2.0.3

现在的样子

The export /save as button doesn't work, with this error:导出/另存为按钮不起作用,出现以下错误:

net.sf.jasperreports.engine.JRPrintHyperlink.getHyperlinkType()

googled and I got the hint to upgrade and use JRViewer.用谷歌搜索,我得到了升级和使用 JRViewer 的提示。

I tried to follow this question: how to print jasper report in Eclipse RCP using its print option?我试图遵循这个问题: 如何使用其打印选项在 Eclipse RCP 中打印 jasper 报告? but I didn't get it work.但我没有得到它的工作。

Can someone give me some clues?有人可以给我一些线索吗?

I got it!我知道了! ... Modified CreatePartControl... ... 修改 CreatePartControl...

public void createPartControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FillLayout(SWT.HORIZONTAL));
//viewerComposite = new ViewerComposite(container,SWT.BORDER);
//viewerComposite.setLayoutData(new GridData(GridData.FILL,GridData.FILL,true,true));

//desde aca
//add the SWT_AWT compposite for SWING contents of GUI              
final Composite swtAwtComposite = new Composite(container, SWT.EMBEDDED);
swtAwtComposite.setBounds(10, 0, 767, 600);

Frame frame = SWT_AWT.new_Frame(swtAwtComposite);

Panel panel = new Panel();
frame.add(panel);
panel.setLayout(new BorderLayout(0, 0));

JRootPane rootPane = new JRootPane();
rootPane.setSize(767, 600);
panel.add(rootPane);

//Define a container yourself
c = rootPane.getContentPane();


super.setPartName("Reportes");

} }

I pass the JasperPrint object from other View, so I created a void method...我从其他视图传递 JasperPrint 对象,所以我创建了一个 void 方法......

public void setJasperPrint(JasperPrint jrPrint){
    this.jrPrint = jrPrint;
    //
    jasperviewer = new JRViewer(jrPrint);

    //Add the JRViewer object onto the container to render in GUI
    c.add(jasperviewer);

} }

works like a charm!奇迹般有效!

新造型 !但它有效

new look!新造型! But it works!但它有效!

Best Regards此致

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM