use of au.com.vaadinutils.jasper.JasperProgressListener in project VaadinUtils by rlsutton1.
the class JasperReportLayout method getJasperManagerProgressListener.
private JasperProgressListener getJasperManagerProgressListener(final UI ui, final WorkingDialog dialog, final OutputFormat outputFormat) {
JasperProgressListener listener = new JasperProgressListener() {
@Override
public void outputStreamReady() {
// flag that the stream is ready, and on the next
// "Refresher call" it will connect to the stream
streamReady = true;
}
@Override
public void failed(String string) {
// show the error message
Notification.show(string, Type.ERROR_MESSAGE);
reportFinished();
}
private void reportFinished() {
// re-enable fields after report finished.
printButton.setEnabled(true);
exportButton.setEnabled(true);
showButton.setEnabled(true);
for (ExpanderComponent componet : components) {
componet.getComponent().setEnabled(true);
}
dialog.close();
}
@Override
public void completed() {
ui.access(new Runnable() {
@Override
public void run() {
reportFinished();
JasperReportLayout.this.readyToPrint(outputFormat);
}
});
}
};
return listener;
}
use of au.com.vaadinutils.jasper.JasperProgressListener 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);
}
Aggregations