use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class WBrowserListItemRenderer method newListitem.
/* (non-Javadoc)
* @see org.zkoss.zul.ListitemRendererExt#newListitem(org.zkoss.zul.Listbox)
*/
public Listitem newListitem(Listbox listbox) {
ListItem item = new ListItem();
item.applyProperties();
return item;
}
use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class ZkReportViewer method exportFile.
// cmd_export
private void exportFile() {
try {
ListItem li = cboType.getSelectedItem();
if (li == null || li.getValue() == null) {
FDialog.error(m_WindowNo, winExportFile, "FileInvalidExtension");
return;
}
String ext = li.getValue().toString();
byte[] data = null;
File inputFile = null;
if (ext.equals("pdf")) {
data = m_reportEngine.createPDFData();
} else if (ext.equals("ps")) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
m_reportEngine.createPS(baos);
data = baos.toByteArray();
} else if (ext.equals("xml")) {
StringWriter sw = new StringWriter();
m_reportEngine.createXML(sw);
data = sw.getBuffer().toString().getBytes();
} else if (ext.equals("csv") || ext.equals("ssv")) {
StringWriter sw = new StringWriter();
m_reportEngine.createCSV(sw, ',', m_reportEngine.getPrintFormat().getLanguage());
data = sw.getBuffer().toString().getBytes();
} else if (ext.equals("txt")) {
StringWriter sw = new StringWriter();
m_reportEngine.createCSV(sw, '\t', m_reportEngine.getPrintFormat().getLanguage());
data = sw.getBuffer().toString().getBytes();
} else if (ext.equals("html") || ext.equals("htm")) {
StringWriter sw = new StringWriter();
m_reportEngine.createHTML(sw, false, m_reportEngine.getPrintFormat().getLanguage());
data = sw.getBuffer().toString().getBytes();
} else if (ext.equals("xls")) {
inputFile = File.createTempFile("Export", ".xls");
m_reportEngine.createXLS(inputFile, m_reportEngine.getPrintFormat().getLanguage());
} else {
FDialog.error(m_WindowNo, winExportFile, "FileInvalidExtension");
return;
}
winExportFile.onClose();
AMedia media = null;
if (data != null)
media = new AMedia(m_reportEngine.getPrintFormat().getName() + "." + ext, null, "application/octet-stream", data);
else
media = new AMedia(m_reportEngine.getPrintFormat().getName() + "." + ext, null, "application/octet-stream", inputFile, true);
Filedownload.save(media, m_reportEngine.getPrintFormat().getName() + "." + ext);
} catch (Exception e) {
log.log(Level.SEVERE, "Failed to export content.", e);
}
}
use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class ZkReportViewer method cmd_report.
/**
* Report Combo - Start other Report or create new one
* @param isSummaryChanged for when the check Is Summary is changed
*/
private void cmd_report(boolean isSummaryChanged) {
ListItem li = comboReport.getSelectedItem();
if (li == null || li.getValue() == null)
return;
Object pp = li.getValue();
if (pp == null)
return;
//
MPrintFormat pf = null;
int AD_PrintFormat_ID = Integer.valueOf(pp.toString());
// create new
if (AD_PrintFormat_ID == -1) {
int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID();
if (AD_ReportView_ID != 0) {
String name = m_reportEngine.getName();
int index = name.lastIndexOf('_');
if (index != -1)
name = name.substring(0, index);
pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name);
} else {
int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID);
}
if (pf != null)
fillComboReport(pf.get_ID());
else
return;
} else if (AD_PrintFormat_ID == -2) {
MPrintFormat current = m_reportEngine.getPrintFormat();
if (current != null) {
pf = MPrintFormat.copyToClient(m_ctx, current.getAD_PrintFormat_ID(), Env.getAD_Client_ID(m_ctx));
if (pf != null)
fillComboReport(pf.get_ID());
else
return;
} else
return;
} else
pf = MPrintFormat.get(Env.getCtx(), AD_PrintFormat_ID, true);
// FR [ 238 ]
if (pf == null)
return;
//
if (!isSummaryChanged) {
summary.setSelected(pf.isSummary());
}
// Set Summary for report
m_reportEngine.setSummary(summary.isSelected());
// Get Language from previous - thanks Gunther Hoppe
if (m_reportEngine.getPrintFormat() != null) {
// needs to be re-set - otherwise viewer will be blank
pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage());
pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage());
}
// FR [ 237 ]
Listitem reportView = (Listitem) comboReportView.getSelectedItem();
if (reportView != null) {
m_reportEngine.setAD_ReportView_ID((int) reportView.getValue());
}
m_reportEngine.setPrintFormat(pf);
//
try {
renderReport();
} catch (Exception e) {
throw new AdempiereException("Failed to render report", e);
}
revalidate();
}
use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class WArchiveViewer method cmd_query.
// query
/**************************************************************************
* Create Query
*/
private void cmd_query() {
boolean reports = reportField.isChecked();
ListItem listitem = processField.getSelectedItem();
KeyNamePair process = null;
if (listitem != null)
process = (KeyNamePair) listitem.getValue();
listitem = tableField.getSelectedItem();
KeyNamePair table = null;
if (listitem != null)
table = (KeyNamePair) listitem.getValue();
Integer C_BPartner_ID = (Integer) bPartnerField.getValue();
String name = nameQField.getText();
String description = descriptionQField.getText();
String help = helpQField.getText();
listitem = createdByQField.getSelectedItem();
KeyNamePair createdBy = null;
if (listitem != null)
createdBy = (KeyNamePair) listitem.getValue();
Date date = null;
Timestamp createdFrom = null;
if (createdQFrom.getValue() != null) {
date = createdQFrom.getValue();
createdFrom = new Timestamp(date.getTime());
}
Timestamp createdTo = null;
if (createdQTo.getValue() != null) {
date = createdQTo.getValue();
createdTo = new Timestamp(date.getTime());
}
cmd_query(reports, process, table, C_BPartner_ID, name, description, help, createdBy, createdFrom, createdTo);
// Display
tabbox.setSelectedIndex(1);
m_index = 1;
updateVDisplay(false);
}
use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class WCreateFromInvoiceUI method onEvent.
/**
* Action Listener
* @param e event
* @throws Exception
*/
public void onEvent(Event e) throws Exception {
if (m_actionActive)
return;
m_actionActive = true;
// Order
if (e.getTarget().equals(orderField)) {
ListItem li = orderField.getSelectedItem();
int C_Order_ID = 0;
if (li != null && li.getValue() != null)
C_Order_ID = ((Integer) li.getValue()).intValue();
// set Invoice, RMA and Shipment to Null
rmaField.setSelectedIndex(-1);
shipmentField.setSelectedIndex(-1);
loadOrder(C_Order_ID, true);
} else // Shipment
if (e.getTarget().equals(shipmentField)) {
ListItem li = shipmentField.getSelectedItem();
int M_InOut_ID = 0;
if (li != null && li.getValue() != null)
M_InOut_ID = ((Integer) li.getValue()).intValue();
// set Order, RMA and Invoice to Null
orderField.setSelectedIndex(-1);
rmaField.setSelectedIndex(-1);
loadShipment(M_InOut_ID);
} else // RMA
if (e.getTarget().equals(rmaField)) {
ListItem li = rmaField.getSelectedItem();
int M_RMA_ID = 0;
if (li != null && li.getValue() != null)
M_RMA_ID = ((Integer) li.getValue()).intValue();
// set Order and Invoice to Null
orderField.setSelectedIndex(-1);
shipmentField.setSelectedIndex(-1);
loadRMA(M_RMA_ID);
}
m_actionActive = false;
}
Aggregations