Search in sources :

Example 1 with RenderElement

use of org.activityinfo.shared.command.RenderElement in project activityinfo by bedatadriven.

the class ExportDialog method export.

public void export(String filename, ReportElement model, Format format) {
    show();
    bar.updateText(I18N.CONSTANTS.exportProgress());
    bar.auto();
    RenderElement command = new RenderElement(model, format);
    command.setFilename(filename);
    dispatcher.execute(command, new AsyncCallback<UrlResult>() {

        @Override
        public void onFailure(Throwable caught) {
            MessageBox.alert(I18N.CONSTANTS.export(), I18N.CONSTANTS.serverError(), new Listener<MessageBoxEvent>() {

                @Override
                public void handleEvent(MessageBoxEvent be) {
                    ExportDialog.this.hide();
                }
            });
        }

        @Override
        public void onSuccess(UrlResult result) {
            if (!canceled) {
                bar.reset();
                bar.updateProgress(1.0, I18N.CONSTANTS.downloadReady());
                button.setText(I18N.CONSTANTS.close());
                tryStartDownloadWithIframe(result.getUrl());
                downloadLink.getElement().setAttribute("href", result.getUrl());
                downloadLink.setVisible(true);
                layout(true);
            }
        }
    });
}
Also used : MessageBoxEvent(com.extjs.gxt.ui.client.event.MessageBoxEvent) RenderElement(org.activityinfo.shared.command.RenderElement) Listener(com.extjs.gxt.ui.client.event.Listener) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener) UrlResult(org.activityinfo.shared.command.result.UrlResult)

Aggregations

Listener (com.extjs.gxt.ui.client.event.Listener)1 MessageBoxEvent (com.extjs.gxt.ui.client.event.MessageBoxEvent)1 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)1 RenderElement (org.activityinfo.shared.command.RenderElement)1 UrlResult (org.activityinfo.shared.command.result.UrlResult)1