Search in sources :

Example 21 with NamePair

use of org.compiere.util.NamePair in project adempiere by adempiere.

the class FieldRecordInfo method addLine.

//	dynInit
/**
	 * 	Add Line
	 *	@param AD_Column_ID column
	 *	@param Updated updated
	 *	@param UpdatedBy user
	 *	@param OldValue old
	 *	@param NewValue new
	 */
private void addLine(int AD_Column_ID, Timestamp Updated, int UpdatedBy, String OldValue, String NewValue) {
    Vector<String> line = new Vector<String>();
    //	Column
    MColumn column = MColumn.get(Env.getCtx(), AD_Column_ID);
    //
    if (OldValue != null && OldValue.equals(MChangeLog.NULL))
        OldValue = null;
    String showOldValue = OldValue;
    if (NewValue != null && NewValue.equals(MChangeLog.NULL))
        NewValue = null;
    String showNewValue = NewValue;
    //
    try {
        if (DisplayType.isText(column.getAD_Reference_ID()))
            ;
        else if (column.getAD_Reference_ID() == DisplayType.YesNo) {
            if (OldValue != null) {
                boolean yes = OldValue.equals("true") || OldValue.equals("Y");
                showOldValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N");
            }
            if (NewValue != null) {
                boolean yes = NewValue.equals("true") || NewValue.equals("Y");
                showNewValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N");
            }
        } else if (column.getAD_Reference_ID() == DisplayType.Amount) {
            if (OldValue != null)
                showOldValue = m_amtFormat.format(new BigDecimal(OldValue));
            if (NewValue != null)
                showNewValue = m_amtFormat.format(new BigDecimal(NewValue));
        } else if (column.getAD_Reference_ID() == DisplayType.Integer) {
            if (OldValue != null)
                showOldValue = m_intFormat.format(new Integer(OldValue));
            if (NewValue != null)
                showNewValue = m_intFormat.format(new Integer(NewValue));
        } else if (DisplayType.isNumeric(column.getAD_Reference_ID())) {
            if (OldValue != null)
                showOldValue = m_numberFormat.format(new BigDecimal(OldValue));
            if (NewValue != null)
                showNewValue = m_numberFormat.format(new BigDecimal(NewValue));
        } else if (column.getAD_Reference_ID() == DisplayType.Date) {
            if (OldValue != null)
                showOldValue = m_dateFormat.format(Timestamp.valueOf(OldValue));
            if (NewValue != null)
                showNewValue = m_dateFormat.format(Timestamp.valueOf(NewValue));
        } else if (column.getAD_Reference_ID() == DisplayType.DateTime) {
            if (OldValue != null)
                showOldValue = m_dateTimeFormat.format(Timestamp.valueOf(OldValue));
            if (NewValue != null)
                showNewValue = m_dateTimeFormat.format(Timestamp.valueOf(NewValue));
        } else if (DisplayType.isLookup(column.getAD_Reference_ID())) {
            MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, AD_Column_ID, column.getAD_Reference_ID(), Env.getLanguage(Env.getCtx()), column.getColumnName(), column.getAD_Reference_Value_ID(), column.isParent(), null);
            if (OldValue != null) {
                Object key = OldValue;
                NamePair pp = lookup.get(key);
                if (pp != null)
                    showOldValue = pp.getName();
            }
            if (NewValue != null) {
                Object key = NewValue;
                NamePair pp = lookup.get(key);
                if (pp != null)
                    showNewValue = pp.getName();
            }
        } else if (DisplayType.isLOB(column.getAD_Reference_ID()))
            ;
    } catch (Exception e) {
        log.log(Level.WARNING, OldValue + "->" + NewValue, e);
    }
    //
    line.add(showNewValue);
    line.add(showOldValue);
    //	UpdatedBy
    MUser user = MUser.get(Env.getCtx(), UpdatedBy);
    line.add(user.getName());
    //	Updated
    line.add(m_dateFormat.format(Updated));
    m_data.add(line);
}
Also used : MColumn(org.compiere.model.MColumn) MLookup(org.compiere.model.MLookup) NamePair(org.compiere.util.NamePair) Vector(java.util.Vector) MUser(org.compiere.model.MUser) BigDecimal(java.math.BigDecimal)

Aggregations

NamePair (org.compiere.util.NamePair)21 KeyNamePair (org.compiere.util.KeyNamePair)14 ValueNamePair (org.compiere.util.ValueNamePair)12 BigDecimal (java.math.BigDecimal)5 Point (java.awt.Point)4 AttributedString (java.text.AttributedString)3 Vector (java.util.Vector)3 MColumn (org.compiere.model.MColumn)3 MLookup (org.compiere.model.MLookup)3 MUser (org.compiere.model.MUser)3 Color (java.awt.Color)2 Font (java.awt.Font)2 LineBreakMeasurer (java.awt.font.LineBreakMeasurer)2 TextLayout (java.awt.font.TextLayout)2 SQLException (java.sql.SQLException)2 Timestamp (java.sql.Timestamp)2 AttributedCharacterIterator (java.text.AttributedCharacterIterator)2 HashMap (java.util.HashMap)2 MQuery (org.compiere.model.MQuery)2 Dimension (java.awt.Dimension)1