use of org.compiere.print.DataEngine in project adempiere by adempiere.
the class LayoutEngine method includeFormat.
// layoutForm
/**
* Include Table Format
* @param item print format item
* @param data print data
* @return Print Element
*/
private PrintElement includeFormat(MPrintFormatItem item, PrintData data) {
newLine();
PrintElement element = null;
//
MPrintFormat format = MPrintFormat.get(getCtx(), item.getAD_PrintFormatChild_ID(), false);
format.setLanguage(m_format.getLanguage());
if (m_format.isTranslationView())
format.setTranslationLanguage(m_format.getLanguage());
int AD_Column_ID = item.getAD_Column_ID();
log.info(format + " - Item=" + item.getName() + " (" + AD_Column_ID + ")");
//
Object obj = data.getNode(new Integer(AD_Column_ID));
// Object obj = data.getNode(item.getColumnName()); // slower
if (obj == null) {
data.dumpHeader();
data.dumpCurrentRow();
log.log(Level.SEVERE, "No Node - AD_Column_ID=" + AD_Column_ID + " - " + item + " - " + data);
return null;
}
PrintDataElement dataElement = (PrintDataElement) obj;
String recordString = dataElement.getValueKey();
if (recordString == null || recordString.length() == 0) {
data.dumpHeader();
data.dumpCurrentRow();
log.log(Level.SEVERE, "No Record Key - " + dataElement + " - AD_Column_ID=" + AD_Column_ID + " - " + item);
return null;
}
int Record_ID = 0;
try {
Record_ID = Integer.parseInt(recordString);
} catch (Exception e) {
data.dumpCurrentRow();
log.log(Level.SEVERE, "Invalid Record Key - " + recordString + " (" + e.getMessage() + ") - AD_Column_ID=" + AD_Column_ID + " - " + item);
return null;
}
MQuery query = new MQuery(format.getAD_Table_ID());
query.addRestriction(item.getColumnName(), MQuery.EQUAL, new Integer(Record_ID));
format.setTranslationViewQuery(query);
log.fine(query.toString());
//
DataEngine de = new DataEngine(format.getLanguage(), m_TrxName);
PrintData includedData = de.getPrintData(data.getCtx(), format, query);
if (includedData == null)
return null;
data.addNode(includedData);
log.fine(includedData.toString());
//
element = layoutTable(format, includedData, item.getXSpace());
// handle multi page tables
if (element.getPageCount() > 1) {
Point2D.Double loc = m_position[m_area];
element.setLocation(loc);
for (// don't add last one
int p = 1; // don't add last one
p < element.getPageCount(); // don't add last one
p++) {
m_currPage.addElement(element);
newPage(true, false);
}
m_position[m_area] = loc;
((TableElement) element).setHeightToLastPage();
}
m_lastWidth[m_area] = element.getWidth();
m_lastHeight[m_area] = element.getHeight();
if (!isXspaceFor(m_lastWidth[m_area])) {
log.finest("Not enough X space for " + m_lastWidth[m_area] + " - remaining " + getXspace() + " - Area=" + m_area);
newLine();
}
if (m_area == AREA_CONTENT && !isYspaceFor(m_lastHeight[m_area])) {
log.finest("Not enough Y space " + m_lastHeight[m_area] + " - remaining " + getYspace() + " - Area=" + m_area);
newPage(true, false);
}
//
return element;
}
Aggregations