简体   繁体   中英

How to integrate JRViewer in Eclipse RCP

I have an RCP application, and it has worked fine ...until now.

I have to upgrade some modules that read and write xlsm and xlsx files, so I upgrade 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.

But I can't make it work inside the viewpart.

This is how it look now, with 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.

I tried to follow this question: how to print jasper report in Eclipse RCP using its print option? but I didn't get it work.

Can someone give me some clues?

I got it! ... Modified 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...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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