Search in sources :

Example 51 with KeyNamePair

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;
}
Also used : Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) NamePair(org.compiere.util.NamePair) ValueNamePair(org.compiere.util.ValueNamePair) KeyNamePair(org.compiere.util.KeyNamePair) MPrintFont(org.compiere.print.MPrintFont) MPrintFont(org.compiere.print.MPrintFont) Font(java.awt.Font) PrintDataElement(org.compiere.print.PrintDataElement) MPrintColor(org.compiere.print.MPrintColor) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair)

Example 52 with KeyNamePair

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");
}
Also used : AdempiereSystemError(org.compiere.util.AdempiereSystemError) MAcctSchemaDefault(org.compiere.model.MAcctSchemaDefault) MAccount(org.compiere.model.MAccount) KeyNamePair(org.compiere.util.KeyNamePair)

Example 53 with KeyNamePair

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());
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair)

Example 54 with KeyNamePair

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"));
}
Also used : MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) KeyNamePair(org.compiere.util.KeyNamePair)

Example 55 with KeyNamePair

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);
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair)

Aggregations

KeyNamePair (org.compiere.util.KeyNamePair)286 SQLException (java.sql.SQLException)66 ResultSet (java.sql.ResultSet)65 PreparedStatement (java.sql.PreparedStatement)62 BigDecimal (java.math.BigDecimal)46 ArrayList (java.util.ArrayList)38 ValueNamePair (org.compiere.util.ValueNamePair)36 Timestamp (java.sql.Timestamp)32 Vector (java.util.Vector)22 ListItem (org.adempiere.webui.component.ListItem)22 Login (org.compiere.util.Login)22 MProduct (org.compiere.model.MProduct)17 IDColumn (org.compiere.minigrid.IDColumn)13 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)12 AdempiereException (org.adempiere.exceptions.AdempiereException)10 MLookup (org.compiere.model.MLookup)10 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)9 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)8 org.apache.ecs.xhtml.script (org.apache.ecs.xhtml.script)8 MUOM (org.compiere.model.MUOM)7