Search in sources :

Example 11 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class CalloutBPartnerLocation method formatPhone.

/**
	 *	Format Phone No based on Country.
	 *  Called from C_BPartnerLocation.C_Location_ID
	 *
	 *  @param ctx      Context
	 *  @param WindowNo current Window No
	 *  @param mTab     Model Tab
	 *  @param mField   Model Field
	 *  @param value    The new value
	 *  @param oldvalue The old value
	 *  @return Error message or ""
	 */
public String formatPhone(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) {
    log.info("");
    // Called from C_Location_ID field
    Integer location_int = (Integer) mField.getValue();
    String phone_frm = null;
    if (location_int != null)
        // take the phone format from country
        phone_frm = DB.getSQLValueString(null, "SELECT ExpressionPhone FROM C_Country c, C_Location l WHERE c.C_Country_ID = l.C_Country_ID AND l.C_location_ID = ?", location_int);
    GridField fPhone = mTab.getField(MBPartnerLocation.COLUMNNAME_Phone);
    MColumn colPhone = null;
    if (fPhone != null)
        colPhone = MColumn.get(Env.getCtx(), fPhone.getAD_Column_ID());
    GridField fPhone2 = mTab.getField(MBPartnerLocation.COLUMNNAME_Phone2);
    MColumn colPhone2 = null;
    if (fPhone2 != null)
        colPhone2 = MColumn.get(Env.getCtx(), fPhone2.getAD_Column_ID());
    GridField fFax = mTab.getField(MBPartnerLocation.COLUMNNAME_Fax);
    MColumn colFax = null;
    if (fFax != null)
        colFax = MColumn.get(Env.getCtx(), fFax.getAD_Column_ID());
    // Apply the country format if the column doesn't have format
    if (colPhone != null && (colPhone.getVFormat() == null || colPhone.getVFormat().length() == 0))
        fPhone.setVFormat(phone_frm);
    if (colPhone2 != null && (colPhone2.getVFormat() == null || colPhone2.getVFormat().length() == 0))
        fPhone2.setVFormat(phone_frm);
    if (colFax != null && (colFax.getVFormat() == null || colFax.getVFormat().length() == 0))
        fFax.setVFormat(phone_frm);
    return "";
}
Also used : MColumn(org.compiere.model.MColumn) GridField(org.compiere.model.GridField)

Example 12 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class VBrowserCellEditor method vetoableChange.

//	getCellEditorValue
/**
     * VEditor Change Listener (property name is columnName).
     * - indicate change  (for String/Text/..) <br>
     * When editing is complete the value is retrieved via getCellEditorValue
     *
     * @param e event
     */
public void vetoableChange(PropertyChangeEvent e) {
    if (table == null)
        return;
    log.fine(e.getPropertyName() + "=" + e.getNewValue());
    if (e.getOldValue() != e.getNewValue()) {
        //	BR [ 268 ]
        GridField gridField = table.getGridFieldAt(row, col);
        gridField.setValue(e.getNewValue(), true);
        if (gridField.getCallout() != null) {
            table.processCallOut(gridField, e.getNewValue(), e.getOldValue(), row, col);
        }
    }
}
Also used : GridField(org.compiere.model.GridField)

Example 13 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class VBrowserTable method loadTable.

@Override
public int loadTable(ResultSet rs) {
    long start = System.currentTimeMillis();
    //	Row
    int row = 0;
    int no = 0;
    //	Delete Row
    setRowCount(row);
    try {
        log.fine("Start load - " + (System.currentTimeMillis() - start) + "ms");
        while (rs.next()) {
            no++;
            setRowCount(row + 1);
            // columns start with 1
            int colOffset = 1;
            int column = 0;
            for (MBrowseField field : getFields()) {
                Object value = null;
                if (field.isKey() && DisplayType.isID(field.getAD_Reference_ID()) && !field.getAD_View_Column().getColumnSQL().equals("'Row' AS \"Row\""))
                    value = new IDColumn(rs.getInt(column + colOffset));
                else if (field.isKey() && DisplayType.isNumeric(field.getAD_Reference_ID()) && field.getAD_View_Column().getColumnSQL().equals("'Row' AS \"Row\""))
                    value = new IDColumn(no);
                else if (DisplayType.isID(field.getAD_Reference_ID()) || field.getAD_Reference_ID() == DisplayType.Integer) {
                    Integer id = rs.getInt(column + colOffset);
                    value = id != 0 ? id : null;
                } else if (DisplayType.isNumeric(field.getAD_Reference_ID()))
                    value = rs.getBigDecimal(column + colOffset);
                else if (DisplayType.isDate(field.getAD_Reference_ID()))
                    value = rs.getTimestamp(column + colOffset);
                else if (DisplayType.YesNo == field.getAD_Reference_ID()) {
                    value = rs.getString(column + colOffset);
                    if (value != null)
                        value = value.equals("Y");
                } else
                    value = rs.getObject(column + colOffset);
                GridField gridField = MBrowseField.createGridFieldVO(field, browser.getWindowNo());
                gridField.setValue(value, true);
                //	Set Value
                setValueAnyColumn(row, column, gridField);
                column++;
            }
            //	Increment Row
            row++;
        }
        log.fine("End load - " + (System.currentTimeMillis() - start) + "ms");
    } catch (SQLException e) {
        log.log(Level.SEVERE, "", e);
    }
    //no = detail.getRowCount();
    log.fine("#" + no + " - " + (System.currentTimeMillis() - start) + "ms");
    if (isShowTotals())
        addTotals();
    //	
    autoSize();
    //
    return no;
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) MBrowseField(org.adempiere.model.MBrowseField) SQLException(java.sql.SQLException) GridField(org.compiere.model.GridField)

Example 14 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class VBrowserTable method setValueAt.

//setValueAt
//	FR [ 245 ]
@Override
public void setValueAt(Object value, int row, int column) {
    GridField gridField = browserRows.getValue(row, browserRows.getTableIndex(column));
    gridField.setValue(value, true);
    //	Set standard method
    setValueAt(row, column, gridField);
}
Also used : GridField(org.compiere.model.GridField)

Example 15 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class Browser method saveResultSelection.

/**
	 * FR [ 245 ]
	 * save result values
	 * @param browserTable
	 */
protected void saveResultSelection(IBrowserTable browserTable) {
    if (m_keyColumnIndex == -1) {
        return;
    }
    //	Verify if is Multi-Selection
    if (p_multiSelection) {
        int rows = browserTable.getRowCount();
        BrowserRow browserRows = browserTable.getData();
        m_values = new LinkedHashMap<Integer, LinkedHashMap<String, Object>>();
        //	BR [ 257 ]
        List<MBrowseField> fields = m_Browse.getFields();
        for (int row = 0; row < rows; row++) {
            //Find the IDColumn Key
            GridField selectedGridField = (GridField) browserRows.getValue(row, m_keyColumnIndex);
            //	Get Value
            Object data = selectedGridField.getValue();
            //	
            if (data instanceof IDColumn) {
                IDColumn dataColumn = (IDColumn) data;
                if (dataColumn.isSelected()) {
                    LinkedHashMap<String, Object> values = new LinkedHashMap<String, Object>();
                    for (MBrowseField field : fields) {
                        if (!field.isReadOnly() || field.isIdentifier() || field.isKey()) {
                            GridField gridField = (GridField) browserRows.getValueOfColumn(row, field.getAD_View_Column().getColumnName());
                            if (gridField != null) {
                                Object value = gridField.getValue();
                                //	Parse value to standard values
                                if (value instanceof IDColumn) {
                                    IDColumn id = (IDColumn) value;
                                    value = id.getRecord_ID();
                                } else if (value instanceof Double) {
                                    value = BigDecimal.valueOf((Double) value);
                                } else if (value instanceof Date) {
                                    value = new Timestamp(((Date) value).getTime());
                                }
                                //	Set
                                values.put(field.getAD_View_Column().getColumnName(), value);
                            }
                        }
                    }
                    //	
                    if (values.size() > 0)
                        m_values.put(dataColumn.getRecord_ID(), values);
                }
            }
        }
    }
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) GridField(org.compiere.model.GridField) Timestamp(java.sql.Timestamp) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) IDColumn(org.compiere.minigrid.IDColumn)

Aggregations

GridField (org.compiere.model.GridField)114 MQuery (org.compiere.model.MQuery)15 WEditor (org.adempiere.webui.editor.WEditor)11 GridFieldVO (org.compiere.model.GridFieldVO)10 GridTab (org.compiere.model.GridTab)10 Lookup (org.compiere.model.Lookup)9 org.apache.ecs.xhtml.tr (org.apache.ecs.xhtml.tr)8 MLookup (org.compiere.model.MLookup)8 Component (java.awt.Component)7 AdempiereException (org.adempiere.exceptions.AdempiereException)7 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)7 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)7 ValueNamePair (org.compiere.util.ValueNamePair)7 SQLException (java.sql.SQLException)6 MBrowseField (org.adempiere.model.MBrowseField)6 org.apache.ecs.xhtml.td (org.apache.ecs.xhtml.td)6 VEditor (org.compiere.grid.ed.VEditor)6 Point (java.awt.Point)5 org.apache.ecs.xhtml.a (org.apache.ecs.xhtml.a)5 org.apache.ecs.xhtml.div (org.apache.ecs.xhtml.div)5