Search in sources :

Example 1 with CancelListener

use of au.com.vaadinutils.listener.CancelListener in project VaadinUtils by rlsutton1.

the class JasperReportLayout method generateReport.

private void generateReport(final JasperManager.OutputFormat outputFormat, final Collection<ReportParameter<?>> params) {
    streamConnected = false;
    streamReady = false;
    splitPanel.setSecondComponent(splash);
    manager = null;
    boolean validParams = true;
    // manager for the selected report.
    for (ReportParameter<?> p : params) {
        if (p instanceof ReportChooser) {
            ReportChooser chooser = (ReportChooser) p;
            manager = new JasperManager(chooser.getReportProperties(reportProperties));
            Preconditions.checkNotNull(manager, "chooser returned a NULL JasperManager.");
        } else {
            validParams &= p.validate();
        }
    }
    if (!validParams) {
        Notification.show("Please correct your filters and try again", Type.ERROR_MESSAGE);
        printButton.setEnabled(true);
        exportButton.setEnabled(true);
        showButton.setEnabled(true);
        for (ExpanderComponent componet : components) {
            componet.getComponent().setEnabled(true);
        }
        return;
    }
    if (manager == null) {
        this.manager = new JasperManager(reportProperties);
    }
    CancelListener cancelListener = getProgressDialogCancelListener();
    final WorkingDialog dialog = new WorkingDialog("Generating report, please be patient", "Please wait", cancelListener);
    dialog.setHeight("150");
    UI.getCurrent().addWindow(dialog);
    getProgressDialogRefreshListener(dialog);
    getStreamConnectorRefreshListener(outputFormat);
    JasperProgressListener listener = getJasperManagerProgressListener(UI.getCurrent(), dialog, outputFormat);
    manager.exportAsync(outputFormat, params, listener);
}
Also used : JasperProgressListener(au.com.vaadinutils.jasper.JasperProgressListener) WorkingDialog(au.com.vaadinutils.ui.WorkingDialog) ExpanderComponent(au.com.vaadinutils.jasper.filter.ExpanderComponent) ReportChooser(au.com.vaadinutils.jasper.parameter.ReportChooser) JasperManager(au.com.vaadinutils.jasper.JasperManager) CancelListener(au.com.vaadinutils.listener.CancelListener)

Example 2 with CancelListener

use of au.com.vaadinutils.listener.CancelListener in project VaadinUtils by rlsutton1.

the class JasperReportLayout method getProgressDialogCancelListener.

private CancelListener getProgressDialogCancelListener() {
    cancelled = false;
    CancelListener cancelListener = new CancelListener() {

        @Override
        public void cancel() {
            manager.cancelPrint();
            cancelled = true;
            // change to the splash page as the report may still complete
            splitPanel.setSecondComponent(splash);
        }
    };
    return cancelListener;
}
Also used : CancelListener(au.com.vaadinutils.listener.CancelListener)

Aggregations

CancelListener (au.com.vaadinutils.listener.CancelListener)2 JasperManager (au.com.vaadinutils.jasper.JasperManager)1 JasperProgressListener (au.com.vaadinutils.jasper.JasperProgressListener)1 ExpanderComponent (au.com.vaadinutils.jasper.filter.ExpanderComponent)1 ReportChooser (au.com.vaadinutils.jasper.parameter.ReportChooser)1 WorkingDialog (au.com.vaadinutils.ui.WorkingDialog)1