Search in sources :

Example 1 with ReportStatus

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

the class JasperReportLayout method getProgressDialogRefreshListener.

private void getProgressDialogRefreshListener(final WorkingDialog dialog) {
    final Table reportQueue = new Table();
    reportQueue.addContainerProperty("Time", String.class, "");
    reportQueue.addContainerProperty("Report Name", String.class, "");
    reportQueue.addContainerProperty("User", String.class, "");
    reportQueue.addContainerProperty("Status", String.class, "");
    reportQueue.setSizeFull();
    reportQueue.setHeight("150");
    reportQueue.setWidth("100%");
    reportQueue.setColumnWidth("Time", 50);
    reportQueue.setColumnWidth("Report Name", 150);
    reportQueue.setColumnWidth("User", 100);
    // reportQueue.setColumnWidth("Status", 100);
    UI.getCurrent().setPollInterval(500);
    UI.getCurrent().addPollListener(new PollListener() {

        int refreshDivider = 0;

        boolean tableAdded = false;

        private static final long serialVersionUID = -5641305025399715756L;

        @SuppressWarnings("unchecked")
        @Override
        public void poll(PollEvent event) {
            if (manager == null) {
                return;
            }
            ReportStatus status = manager.getStatus();
            dialog.progress(0, 0, status.getStatus());
            if (refreshDivider % 4 == 0) {
                if (status.getEntries().size() > 0) {
                    reportQueue.removeAllItems();
                    for (QueueEntry entry : status.getEntries()) {
                        Object id = reportQueue.addItem();
                        Item item = reportQueue.getItem(id);
                        item.getItemProperty("Time").setValue(entry.getTime());
                        item.getItemProperty("Report Name").setValue(entry.getReportName());
                        item.getItemProperty("User").setValue(entry.getUser());
                        item.getItemProperty("Status").setValue(entry.getStatus());
                    }
                    if (!tableAdded) {
                        dialog.addUserComponent(reportQueue);
                        tableAdded = true;
                    }
                    dialog.setWidth("600");
                    dialog.setHeight("350");
                    dialog.center();
                } else {
                    dialog.removeUserComponent(reportQueue);
                    dialog.setWidth("300");
                    dialog.setHeight("150");
                    dialog.center();
                }
            }
            if (cancelled) {
                printButton.setEnabled(true);
                exportButton.setEnabled(true);
                showButton.setEnabled(true);
                for (ExpanderComponent componet : components) {
                    componet.getComponent().setEnabled(true);
                }
                UI.getCurrent().removePollListener(this);
                UI.getCurrent().setPollInterval(-1);
                dialog.close();
            }
            refreshDivider++;
        }
    });
}
Also used : Table(com.vaadin.ui.Table) ExpanderComponent(au.com.vaadinutils.jasper.filter.ExpanderComponent) PollListener(com.vaadin.event.UIEvents.PollListener) QueueEntry(au.com.vaadinutils.jasper.QueueEntry) PollEvent(com.vaadin.event.UIEvents.PollEvent) Item(com.vaadin.data.Item) JsonObject(elemental.json.JsonObject) ReportStatus(au.com.vaadinutils.jasper.ReportStatus)

Aggregations

QueueEntry (au.com.vaadinutils.jasper.QueueEntry)1 ReportStatus (au.com.vaadinutils.jasper.ReportStatus)1 ExpanderComponent (au.com.vaadinutils.jasper.filter.ExpanderComponent)1 Item (com.vaadin.data.Item)1 PollEvent (com.vaadin.event.UIEvents.PollEvent)1 PollListener (com.vaadin.event.UIEvents.PollListener)1 Table (com.vaadin.ui.Table)1 JsonObject (elemental.json.JsonObject)1