use of au.com.vaadinutils.jasper.filter.ExpanderComponent in project VaadinUtils by rlsutton1.
the class JasperReportLayout method getOptionsPanel.
private Component getOptionsPanel() {
VerticalLayout layout = new VerticalLayout();
layout.setId("OptionsPanel");
// layout.setMargin(new MarginInfo(false, false, false, false));
// layout.setSpacing(true);
layout.setSizeFull();
String buttonHeight = "" + 40;
HorizontalLayout buttonBar = new HorizontalLayout();
buttonBar.setSpacing(true);
buttonBar.setStyleName(Reindeer.LAYOUT_BLUE);
buttonBar.setWidth("100%");
buttonBar.setHeight(buttonHeight);
buttonBar.setMargin(new MarginInfo(false, false, false, false));
HorizontalLayout buttonContainer = new HorizontalLayout();
buttonContainer.setSizeFull();
buttonContainer.setWidth("230");
showButton = new NativeButton();
showButton.setIcon(new ExternalResource("images/seanau/Print preview.png"));
showButton.setDescription("Preview");
showButton.setWidth("50");
showButton.setHeight(buttonHeight);
showButton.setDisableOnClick(true);
addButtonListener(showButton, OutputFormat.HTML);
buttonContainer.addComponent(showButton);
printButton = new NativeButton();
printButton.setIcon(new ExternalResource("images/seanau/Print_32.png"));
printButton.setDescription("Print (PDF)");
printButton.setWidth("50");
printButton.setHeight(buttonHeight);
printButton.setDisableOnClick(true);
addButtonListener(printButton, OutputFormat.PDF);
buttonContainer.addComponent(printButton);
exportButton = new NativeButton();
exportButton.setDescription("Export (Excel - CSV)");
exportButton.setIcon(new ExternalResource("images/exporttoexcel.png"));
exportButton.setWidth("50");
exportButton.setDisableOnClick(true);
exportButton.setHeight(buttonHeight);
// exportButton.setStyleName(Reindeer.BUTTON_LINK);
addButtonListener(exportButton, OutputFormat.CSV);
buttonContainer.addComponent(exportButton);
createEmailButton(buttonHeight, buttonContainer);
createScheduleButton(buttonHeight, buttonContainer);
if (reportProperties instanceof JasperReportPopUp) {
// This is disabled because there are serious problems with
// transient (JasperReportProperties is not aware of them)
// parameters in drill
// downs, these can not currently be save or represented in the
// ReportEmailSchedule
emailButton.setEnabled(false);
scheduleButton.setEnabled(false);
}
buttonBar.addComponent(buttonContainer);
layout.addComponent(buttonBar);
components = builder.buildLayout(false);
if (components.size() > 0) {
VerticalLayout filterPanel = new VerticalLayout();
filterPanel.setMargin(new MarginInfo(false, false, true, false));
filterPanel.setSpacing(true);
filterPanel.setSizeFull();
Label filterLabel = new Label("<b>Filters</b>");
filterLabel.setStyleName(Reindeer.LABEL_H2);
filterLabel.setContentMode(ContentMode.HTML);
filterPanel.addComponent(filterLabel);
for (ExpanderComponent componet : components) {
filterPanel.addComponent(componet.getComponent());
if (componet.shouldExpand()) {
filterPanel.setExpandRatio(componet.getComponent(), 1);
}
}
layout.addComponent(filterPanel);
layout.setExpandRatio(filterPanel, 1.0f);
}
// hidden frame for downloading csv
csv = new BrowserFrame();
csv.setVisible(true);
csv.setHeight("1");
csv.setWidth("1");
csv.setImmediate(true);
layout.addComponent(csv);
return layout;
}
use of au.com.vaadinutils.jasper.filter.ExpanderComponent 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