use of au.com.vaadinutils.jasper.parameter.ReportParameterConstant in project VaadinUtils by rlsutton1.
the class JasperReportLayout method initScreen.
protected void initScreen(SplitPanel panel) {
this.setSizeFull();
splitPanel = panel;
this.addComponent(splitPanel.getComponent());
splitPanel.setFirstComponent((AbstractComponent) getOptionsPanel());
splash = new VerticalLayout();
splash.setMargin(true);
Label titleLabel = new Label("<h1>" + reportProperties.getReportTitle() + "</h1>");
titleLabel.setContentMode(ContentMode.HTML);
splash.addComponent(titleLabel);
Label splashLabel = new Label("<font size='4' >Set the desired filters and click a print button to generate a report</font>");
splashLabel.setContentMode(ContentMode.HTML);
splitPanel.setSecondComponent(splash);
// generate the report immediately if there are no visible filters
if (!builder.hasFilters()) {
splashLabel = new Label("<font size='4' >Please wait whilst we generate your report</font>");
splashLabel.setContentMode(ContentMode.HTML);
// disable the buttons and any filters
printButton.setEnabled(false);
exportButton.setEnabled(false);
showButton.setEnabled(false);
for (ExpanderComponent componet : components) {
componet.getComponent().setEnabled(false);
}
// what follows is a horrible hack...
// if we create the progress dialog at the same time as the popup
// report window the progress dialog will be behind the popup report
// window.
// so I've created a refresher, and 1 seconds after the popup report
// window opens we kick of the report generation which creates the
// progress dialog then, which allows it to be in front.
UI.getCurrent().setPollInterval(500);
UI.getCurrent().addPollListener(new PollListener() {
private static final long serialVersionUID = 1L;
@Override
public void poll(PollEvent event) {
try {
UI.getCurrent().setPollInterval(-1);
UI.getCurrent().removePollListener(this);
generateReport(reportProperties.getDefaultFormat(), JasperReportLayout.this.builder.getReportParameters());
} catch (Exception e) {
logger.catching(e);
Notification.show("Error", e.getMessage(), Type.ERROR_MESSAGE);
}
}
});
}
splash.addComponent(splashLabel);
JavaScript.getCurrent().addFunction("au.com.noojee.reportDrillDown", new JavaScriptFunction() {
// expected syntax of a call to this javascript hook method
//
// window.parent.au.com.noojee.reportDrillDown(
// {
// 'reportFileName':
// 'CallDetailsPerTeamAgentPerHour_CallDetails.jasper',
// 'reportTitle': 'Call Details Per Team Agent Per Hour'
// },
// {
// 'ReportParameterStartDate'='$P{StartDate}',
// 'ReportParameterEndDate'='$P{EndDate}',
// 'ReportParameterExtension'='$F{loginid}',
// 'ReportParameterTeamId'='$P{TeamId}',
// 'ReportParameterHour'='$F{Day}.toString()'
// }
//
// );
private static final long serialVersionUID = 1L;
@Override
public void call(JsonArray arguments) {
try {
JsonObject args = arguments.getObject(0);
String subReportFileName = args.getString("ReportFileName");
String subTitle = args.getString("ReportTitle");
JsonObject params = arguments.getObject(1);
List<ReportParameter<?>> subFilters = new LinkedList<>();
boolean insitue = false;
String[] itr = params.keys();
for (String key : itr) {
if (key.equalsIgnoreCase("ReportParameterInsitue")) {
insitue = true;
} else {
subFilters.add(new ReportParameterConstant<>(key, params.getString(key), key, params.getString(key)));
}
}
if (!insitue) {
new JasperReportPopUp(new ChildJasperReportProperties(reportProperties, subTitle, subReportFileName, subFilters));
} else {
generateReport(OutputFormat.HTML, subFilters);
}
} catch (Exception e) {
logger.error(arguments.toString());
logger.error(e, e);
}
}
});
}
Aggregations