Search in sources :

Example 6 with ExpanderComponent

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;
}
Also used : NativeButton(com.vaadin.ui.NativeButton) ExpanderComponent(au.com.vaadinutils.jasper.filter.ExpanderComponent) BrowserFrame(com.vaadin.ui.BrowserFrame) MarginInfo(com.vaadin.shared.ui.MarginInfo) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) ExternalResource(com.vaadin.server.ExternalResource) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 7 with ExpanderComponent

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);
            }
        }
    });
}
Also used : ExpanderComponent(au.com.vaadinutils.jasper.filter.ExpanderComponent) Label(com.vaadin.ui.Label) JsonObject(elemental.json.JsonObject) PollListener(com.vaadin.event.UIEvents.PollListener) PollEvent(com.vaadin.event.UIEvents.PollEvent) JsonArray(elemental.json.JsonArray) JavaScriptFunction(com.vaadin.ui.JavaScriptFunction) VerticalLayout(com.vaadin.ui.VerticalLayout) List(java.util.List) LinkedList(java.util.LinkedList) ReportParameterConstant(au.com.vaadinutils.jasper.parameter.ReportParameterConstant)

Aggregations

ExpanderComponent (au.com.vaadinutils.jasper.filter.ExpanderComponent)7 JasperProgressListener (au.com.vaadinutils.jasper.JasperProgressListener)2 PollEvent (com.vaadin.event.UIEvents.PollEvent)2 PollListener (com.vaadin.event.UIEvents.PollListener)2 Label (com.vaadin.ui.Label)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 JsonObject (elemental.json.JsonObject)2 JasperManager (au.com.vaadinutils.jasper.JasperManager)1 QueueEntry (au.com.vaadinutils.jasper.QueueEntry)1 ReportStatus (au.com.vaadinutils.jasper.ReportStatus)1 ReportChooser (au.com.vaadinutils.jasper.parameter.ReportChooser)1 ReportParameterConstant (au.com.vaadinutils.jasper.parameter.ReportParameterConstant)1 ReportEmailScheduleEntity (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity)1 CancelListener (au.com.vaadinutils.listener.CancelListener)1 ClickEventLogged (au.com.vaadinutils.listener.ClickEventLogged)1 WorkingDialog (au.com.vaadinutils.ui.WorkingDialog)1 Item (com.vaadin.data.Item)1 InvalidValueException (com.vaadin.data.Validator.InvalidValueException)1 ExternalResource (com.vaadin.server.ExternalResource)1 MarginInfo (com.vaadin.shared.ui.MarginInfo)1