use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class LayoutEngine method createFieldElement.
// createStringElement
/**
* Create Field Element
* @param item Format Item
* @param maxWidth max width
* @param FieldAlignmentType alignment type (MPrintFormatItem.FIELD_ALIGN_*)
* @param isForm true if document
* @return Print Element or null if nothing to print
*/
private PrintElement createFieldElement(MPrintFormatItem item, int maxWidth, String FieldAlignmentType, boolean isForm) {
// Get Data
Object obj = m_data.getNode(new Integer(item.getAD_Column_ID()));
if (obj == null)
return null;
else if (obj instanceof PrintDataElement)
;
else {
log.log(Level.SEVERE, "Element not PrintDataElement " + obj.getClass());
return null;
}
// Convert DataElement to String
PrintDataElement data = (PrintDataElement) obj;
if (data.isNull() && item.isSuppressNull())
return null;
String stringContent = data.getValueDisplay(m_format.getLanguage());
if ((stringContent == null || stringContent.length() == 0) && item.isSuppressNull())
return null;
// non-string
Object content = stringContent;
if (data.getValue() instanceof Boolean)
content = data.getValue();
// Convert AmtInWords Content to alpha
if (item.getColumnName().equals("AmtInWords")) {
log.fine("AmtInWords: " + stringContent);
stringContent = Msg.getAmtInWords(m_format.getLanguage(), stringContent);
content = stringContent;
}
// Label
String label = item.getPrintName(m_format.getLanguage());
String labelSuffix = item.getPrintNameSuffix(m_format.getLanguage());
// ID Type
NamePair ID = null;
if (data.isID()) {
// Record_ID/ColumnName
Object value = data.getValue();
if (value instanceof KeyNamePair)
ID = new KeyNamePair(((KeyNamePair) value).getKey(), item.getColumnName());
else if (value instanceof ValueNamePair)
ID = new ValueNamePair(((ValueNamePair) value).getValue(), item.getColumnName());
} else if (MPrintFormatItem.FIELDALIGNMENTTYPE_Default.equals(FieldAlignmentType)) {
if (data.isNumeric())
FieldAlignmentType = MPrintFormatItem.FIELDALIGNMENTTYPE_TrailingRight;
else
FieldAlignmentType = MPrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft;
}
// Get Color/ Font
// default
Color color = getColor();
if (ID != null && !isForm)
// link color/underline handeled in PrintElement classes
;
else if (item.getAD_PrintColor_ID() != 0 && m_printColor.get_ID() != item.getAD_PrintColor_ID()) {
MPrintColor c = MPrintColor.get(getCtx(), item.getAD_PrintColor_ID());
if (c.getColor() != null)
color = c.getColor();
}
// default
Font font = m_printFont.getFont();
if (item.getAD_PrintFont_ID() != 0 && m_printFont.get_ID() != item.getAD_PrintFont_ID()) {
MPrintFont f = MPrintFont.get(item.getAD_PrintFont_ID());
if (f.getFont() != null)
font = f.getFont();
}
// Create String, HTML or Location
PrintElement e = null;
if (data.getDisplayType() == DisplayType.Location) {
e = new LocationElement(m_printCtx, ((KeyNamePair) ID).getKey(), font, color, item.isHeightOneLine(), label, labelSuffix, m_format.getLanguage().getAD_Language());
e.layout(maxWidth, item.getMaxHeight(), item.isHeightOneLine(), FieldAlignmentType);
} else {
if (HTMLElement.isHTML(stringContent))
e = new HTMLElement(stringContent);
else
e = new StringElement(content, font, color, isForm ? null : ID, label, labelSuffix);
e.layout(maxWidth, item.getMaxHeight(), item.isHeightOneLine(), FieldAlignmentType);
}
return e;
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class AcctSchemaCopyAcct method copyDefault.
// copyGL
/**
* Copy Default
* @param targetAS target
* @throws Exception
*/
private void copyDefault(MAcctSchema targetAS) throws Exception {
MAcctSchemaDefault source = MAcctSchemaDefault.get(getCtx(), p_SourceAcctSchema_ID);
MAcctSchemaDefault target = new MAcctSchemaDefault(getCtx(), 0, get_TrxName());
target.setC_AcctSchema_ID(p_TargetAcctSchema_ID);
target.setC_AcctSchema_ID(p_TargetAcctSchema_ID);
ArrayList<KeyNamePair> list = source.getAcctInfo();
for (int i = 0; i < list.size(); i++) {
KeyNamePair pp = list.get(i);
int sourceC_ValidCombination_ID = pp.getKey();
String columnName = pp.getName();
MAccount sourceAccount = MAccount.get(getCtx(), sourceC_ValidCombination_ID);
MAccount targetAccount = createAccount(targetAS, sourceAccount);
target.setValue(columnName, new Integer(targetAccount.getC_ValidCombination_ID()));
}
if (!target.save())
throw new AdempiereSystemError("Could not Save Default");
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VInOutGen method executeQuery.
// fillPicks
public void executeQuery() {
KeyNamePair docTypeKNPair = (KeyNamePair) cmbDocType.getSelectedItem();
executeQuery(docTypeKNPair, panel.getMiniTable());
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VInOutGen method dynInit.
// jbInit
/**
* Fill Picks.
* Column_ID from C_Order
* @throws Exception if Lookups cannot be initialized
*/
public void dynInit() throws Exception {
// C_OrderLine.M_Warehouse_ID
MLookup orgL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2223, DisplayType.TableDir);
fWarehouse = new VLookup("M_Warehouse_ID", true, false, true, orgL);
lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
fWarehouse.addVetoableChangeListener(this);
setM_Warehouse_ID(fWarehouse.getValue());
// Document Action Prepared/ Completed
MLookup docActionL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 4324, /* M_InOut.DocStatus */
DisplayType.List, Env.getLanguage(Env.getCtx()), "DocAction", 135, /* _Document Action */
false, "AD_Ref_List.Value IN ('CO','PR')");
docAction = new VLookup("DocAction", true, false, true, docActionL);
docAction.addVetoableChangeListener(this);
//@Trifon - Pre-select "Prepare"
docAction.setValue("PR");
// C_Order.C_BPartner_ID
MLookup bpL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search);
fBPartner = new VLookup("C_BPartner_ID", false, false, true, bpL);
lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
fBPartner.addVetoableChangeListener(this);
//Document Type Sales Order/Vendor RMA
lDocType.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
cmbDocType.addItem(new KeyNamePair(MOrder.Table_ID, Msg.translate(Env.getCtx(), "Order")));
cmbDocType.addItem(new KeyNamePair(MRMA.Table_ID, Msg.translate(Env.getCtx(), "VendorRMA")));
cmbDocType.addActionListener(this);
//@@
panel.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateSel"));
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VInvoiceGen method generate.
// vetoableChange
/**************************************************************************
* Generate Shipments
*/
public String generate() {
KeyNamePair docTypeKNPair = (KeyNamePair) cmbDocType.getSelectedItem();
String docActionSelected = (String) docAction.getValue();
return generate(panel.getStatusBar(), docTypeKNPair, docActionSelected);
}
Aggregations