Search in sources :

Example 1 with ScheduleIconBuilder

use of au.com.vaadinutils.jasper.scheduler.ScheduleIconBuilder in project VaadinUtils by rlsutton1.

the class JasperReportLayout method createScheduleButton.

private void createScheduleButton(String buttonHeight, HorizontalLayout buttonContainer) {
    scheduleButton = new NativeButton();
    JpaBaseDao<ReportEmailScheduleEntity, Long> dao = JpaBaseDao.getGenericDao(ReportEmailScheduleEntity.class);
    Long count = dao.getCount(ReportEmailScheduleEntity_.JasperReportPropertiesClassName, reportProperties.getReportClass().getCanonicalName());
    ScheduleIconBuilder iconBuilder = new ScheduleIconBuilder();
    String baseIconFileName = "Call Calendar_32";
    String path = VaadinServlet.getCurrent().getServletContext().getRealPath("templates/images/seanau/");
    // then search in the /images/seanau director.
    if (path == null || !new File(path).exists()) {
        path = VaadinServlet.getCurrent().getServletContext().getRealPath("/images/seanau/");
    }
    String targetFileName = baseIconFileName + "-" + count + ".png";
    iconBuilder.buildLogo(count.intValue(), new File(path), baseIconFileName + ".png", targetFileName);
    scheduleButton.setIcon(new ExternalResource("images/seanau/" + targetFileName));
    scheduleButton.setDescription("Schedule");
    scheduleButton.setWidth("50");
    scheduleButton.setHeight(buttonHeight);
    scheduleButton.addClickListener(new ClickEventLogged.ClickListener() {

        private static final long serialVersionUID = 7207441556779172217L;

        @Override
        public void clicked(ClickEvent event) {
            new JasperReportSchedulerWindow(reportProperties, builder.getReportParameters());
        }
    });
    buttonContainer.addComponent(scheduleButton);
}
Also used : NativeButton(com.vaadin.ui.NativeButton) JasperReportSchedulerWindow(au.com.vaadinutils.jasper.scheduler.JasperReportSchedulerWindow) ClickEventLogged(au.com.vaadinutils.listener.ClickEventLogged) ScheduleIconBuilder(au.com.vaadinutils.jasper.scheduler.ScheduleIconBuilder) ClickEvent(com.vaadin.ui.Button.ClickEvent) ReportEmailScheduleEntity(au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity) ExternalResource(com.vaadin.server.ExternalResource) File(java.io.File)

Aggregations

JasperReportSchedulerWindow (au.com.vaadinutils.jasper.scheduler.JasperReportSchedulerWindow)1 ScheduleIconBuilder (au.com.vaadinutils.jasper.scheduler.ScheduleIconBuilder)1 ReportEmailScheduleEntity (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity)1 ClickEventLogged (au.com.vaadinutils.listener.ClickEventLogged)1 ExternalResource (com.vaadin.server.ExternalResource)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 NativeButton (com.vaadin.ui.NativeButton)1 File (java.io.File)1