use of au.com.vaadinutils.editors.Recipient in project VaadinUtils by rlsutton1.
the class JasperReportLayout method createFavouriteButton.
private void createFavouriteButton(String buttonHeight, HorizontalLayout buttonContainer) {
favouriteButton = new Button();
Resource favouriteButtonIcon = reportProperties.getFavouriteButtonIconResource();
if (favouriteButtonIcon == null) {
favouriteButtonIcon = new ExternalResource("images/favourite.png");
}
favouriteButton.setDescription("Favourite");
favouriteButton.setIcon(favouriteButtonIcon);
favouriteButton.setWidth("" + BUTTON_WIDTH);
favouriteButton.setDisableOnClick(true);
favouriteButton.setHeight(buttonHeight);
favouriteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
favouriteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
favouriteButton.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
new InputDialog(UI.getCurrent(), "Save Favourite", "Provide a name for the faviourite", new Recipient() {
@Override
public boolean onOK(String input) {
if (StringUtils.length(input) >= 500) {
Notification.show("The name must be less than 500 characters", Type.ERROR_MESSAGE);
return false;
}
Collection<ReportParameter<?>> params = builder.getReportParameters();
ReportSave reportSave = new ReportSave();
reportSave.setReportClass(reportProperties.getReportClass().getName());
reportSave.setUserDescription(input);
reportSave.setUser(reportProperties.getUsername());
reportSave.setSaveType(SaveType.FAVOURITES);
for (ReportParameter<?> param : params) {
for (String pname : param.getParameterNames()) {
if (StringUtils.isNotBlank(param.getLabel(pname))) {
ReportSaveParameter reportSaveparam = new ReportSaveParameter();
reportSaveparam.setParameterName(param.getLabel(pname));
reportSaveparam.setTextualRepresentation(param.getDisplayValue(pname));
reportSaveparam.setParameterValue(param.getValue(pname).toString());
reportSaveparam.setMetaData(param.getSaveMetaData());
reportSaveparam.setMetaDataComment(param.getMetaDataComment());
reportSave.addParameter(reportSaveparam);
JpaBaseDao.getEntityManager().persist(reportSaveparam);
}
}
}
JpaBaseDao.getEntityManager().persist(reportSave);
return true;
}
@Override
public boolean onCancel() {
return true;
}
});
}
});
buttonContainer.addComponent(favouriteButton);
}
Aggregations