use of org.zkoss.util.media.AMedia in project adempiere by adempiere.
the class ZkReportViewer method renderReport.
private void renderReport() throws Exception {
AMedia media = null;
Listitem selected = previewType.getSelectedItem();
if (selected == null || "PDF".equals(selected.getValue())) {
String path = System.getProperty("java.io.tmpdir");
String prefix = makePrefix(m_reportEngine.getName());
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
}
File file = File.createTempFile(prefix, ".pdf", new File(path));
m_reportEngine.createPDF(file);
media = new AMedia(getTitle(), "pdf", "application/pdf", file, true);
} else if ("HTML".equals(previewType.getSelectedItem().getValue())) {
String path = System.getProperty("java.io.tmpdir");
String prefix = makePrefix(m_reportEngine.getName());
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
}
File file = File.createTempFile(prefix, ".html", new File(path));
m_reportEngine.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", this.getUuid()));
media = new AMedia(getTitle(), "html", "text/html", file, false);
} else if ("XLS".equals(previewType.getSelectedItem().getValue())) {
String path = System.getProperty("java.io.tmpdir");
String prefix = makePrefix(m_reportEngine.getName());
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
}
File file = File.createTempFile(prefix, ".xls", new File(path));
m_reportEngine.createXLS(file, AEnv.getLanguage(Env.getCtx()));
media = new AMedia(getTitle(), "xls", "application/vnd.ms-excel", file, true);
}
iframe.setContent(media);
}
use of org.zkoss.util.media.AMedia in project adempiere by adempiere.
the class WCollect method printTicketWeb.
/**
* Print Ticket for Web
* @return void
*/
public void printTicketWeb() {
try {
if (posPanel.isToPrint() && posPanel.hasOrder()) {
ReportCtl.startDocumentPrint(0, posPanel.getC_Order_ID(), false);
ReportEngine m_reportEngine = ReportEngine.get(p_ctx, ReportEngine.ORDER, posPanel.getC_Order_ID());
StringWriter sw = new StringWriter();
m_reportEngine.createCSV(sw, '\t', m_reportEngine.getPrintFormat().getLanguage());
byte[] data = sw.getBuffer().toString().getBytes();
AMedia media = new AMedia(m_reportEngine.getPrintFormat().getName() + ".txt", null, "application/octet-stream", data);
posPanel.printFile(media.getByteData(), posPanel.getC_Order_ID());
}
} catch (Exception e) {
log.severe("PrintTicket - Error Printing Ticket");
}
}
use of org.zkoss.util.media.AMedia in project adempiere by adempiere.
the class WMediaDialog method displayData.
// dispose
/**
* Display gif or jpg in gifPanel
* @param index index
*/
private void displayData() {
// Reset UI
preview.setVisible(false);
bDelete.setEnabled(false);
bSave.setEnabled(false);
if (m_data != null) {
bSave.setEnabled(true);
bDelete.setEnabled(true);
try {
AMedia media = createMedia();
preview.setContent(media);
preview.setVisible(true);
} catch (Exception e) {
log.log(Level.SEVERE, "Failed to preview content", e);
}
}
}
use of org.zkoss.util.media.AMedia in project adempiere by adempiere.
the class WMediaDialog method save.
// getFileName
/**
* download
*/
private void save() {
if (m_data == null)
return;
try {
AMedia media = createMedia();
Filedownload.save(media);
} catch (Exception e) {
log.log(Level.SEVERE, "Failed to export content.", e);
}
}
Aggregations