use of io.jmix.ui.download.ByteArrayDataProvider in project jmix by jmix-framework.
the class JsonEmailTemplateEdit method viewHtml.
@Subscribe("viewHtml")
public void viewHtml(Button.ClickEvent event) {
String name = getEditedEntity().getName() != null ? getEditedEntity().getName() : "template";
String html = getEditedEntity().getHtml() != null ? getEditedEntity().getHtml() : "";
downloader.download(new ByteArrayDataProvider(html.getBytes(StandardCharsets.UTF_8), uiProperties.getSaveExportedByteArrayDataThresholdBytes(), coreProperties.getTempDir()), name + ".html");
}
use of io.jmix.ui.download.ByteArrayDataProvider in project jmix by jmix-framework.
the class PivotExcelExporter method export.
protected void export(Downloader downloader) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
wb.write(out);
} catch (IOException e) {
throw new RuntimeException("Unable to write document", e);
}
if (fileName == null) {
fileName = DEFAULT_FILE_NAME;
}
DownloadFormat downloadFormat = exportFormat == ExportFormat.XLS ? DownloadFormat.XLS : DownloadFormat.XLSX;
downloader.download(new ByteArrayDataProvider(out.toByteArray(), uiProperties.getSaveExportedByteArrayDataThresholdBytes(), coreProperties.getTempDir()), fileName + "." + downloadFormat.getFileExt(), downloadFormat);
}
use of io.jmix.ui.download.ByteArrayDataProvider in project jmix by jmix-framework.
the class MBeanOperationResultScreen method exportToFile.
@Subscribe("exportBtn")
public void exportToFile(Button.ClickEvent clickEvent) {
if (result != null || exception != null) {
String exportResult = String.format("JMX Method %s : %s result\n", operation.getMbean().getClassName(), operation.getName());
if (result != null) {
exportResult += AttributeHelper.convertToString(result);
}
if (exception != null) {
exportResult += getExceptionMessage(exception);
}
byte[] bytes = exportResult.getBytes(StandardCharsets.UTF_8);
downloader.download(new ByteArrayDataProvider(bytes, uiProperties.getSaveExportedByteArrayDataThresholdBytes(), coreProperties.getTempDir()), String.format("jmx.%s-%s-%s.log", operation.getMbean().getClassName(), operation.getName(), new SimpleDateFormat("HH:mm:ss").format(timeSource.currentTimestamp())));
} else {
notifications.create().withCaption(messages.getMessage(getClass(), "operationResult.resultIsEmpty")).withType(Notifications.NotificationType.HUMANIZED).show();
}
}
use of io.jmix.ui.download.ByteArrayDataProvider in project jmix by jmix-framework.
the class ImapMessageEdit method downloadAttachment.
@Subscribe("attachmentsTable.download")
public void downloadAttachment(Action.ActionPerformedEvent event) {
attachmentsTable.getSelected().forEach(attachment -> {
byte[] bytes = imapAttachments.loadFile(attachment);
downloader.download(new ByteArrayDataProvider(bytes, uiProperties.getSaveExportedByteArrayDataThresholdBytes(), coreProperties.getTempDir()), attachment.getName());
});
}
use of io.jmix.ui.download.ByteArrayDataProvider in project jmix by jmix-framework.
the class PersistentDashboardEdit method onExportJsonBtnClick.
@Subscribe("exportJsonBtn")
public void onExportJsonBtnClick(Button.ClickEvent event) {
String jsonModel = converter.dashboardToJson(getDashboardModel());
if (isNotBlank(jsonModel)) {
byte[] bytes = jsonModel.getBytes(UTF_8);
String fileName = isNotBlank(getDashboardModel().getTitle()) ? getDashboardModel().getTitle() : "dashboard";
downloader.download(new ByteArrayDataProvider(bytes, uiProperties.getSaveExportedByteArrayDataThresholdBytes(), coreProperties.getTempDir()), format("%s.json", fileName));
}
}
Aggregations