Search in sources :

Example 11 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class WBrowserTable method setValueAt.

/**
	 * Set the cell value at <code>row</code> and <code>column</code>.
	 *
	 * @param value		The value to set
     * @param row    	the index of the row whose value is to be set
     * @param column	the index of the column whose value is to be set
	 */
public void setValueAt(Object value, int row, int column) {
    getModel().setDataAt(value, row, convertColumnIndexToModel(column));
    if (value instanceof IDColumn) {
        IDColumn id = (IDColumn) value;
        boolean selected = id.isSelected();
        ListItem listItem = this.getItemAtIndex(row);
        if (listItem != null && !listItem.isSelected() && selected) {
            listItem.setSelected(true);
        }
    }
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) ListItem(org.adempiere.webui.component.ListItem)

Example 12 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class WBrowserTable method tableValueChange.

/**
	 *
	 * @param event    The event that has occurred
	 */
public void tableValueChange(TableValueChangeEvent event) {
    // column of table field which caused the event
    int col = event.getColumn();
    // row of table field which caused the event
    int row = event.getRow();
    boolean newBoolean;
    IDColumn idColumn;
    // then set the IDColumn's select field
    if (col >= 0 && row >= 0) {
        if (this.getValueAt(row, col) instanceof IDColumn && event.getNewValue() instanceof Boolean) {
            newBoolean = ((Boolean) event.getNewValue()).booleanValue();
            idColumn = (IDColumn) this.getValueAt(row, col);
            idColumn.setSelected(newBoolean);
            this.setValueAt(idColumn, row, col);
        } else // otherwise just set the value in the model to the new value
        {
            GridField gridField = getGridFieldAt(row, col);
            gridField.setValue(event.getNewValue(), true);
            setValueAt(row, col, gridField);
            if (gridField.getCallout() != null) {
                processCallOut(gridField, event.getNewValue(), event.getOldValue(), row, col);
            }
        }
    }
    return;
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) GridField(org.compiere.model.GridField)

Example 13 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class WBrowserListItemRenderer method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    int col = -1;
    int row = -1;
    Object value = null;
    TableValueChangeEvent vcEvent = null;
    WTableColumn tableColumn;
    Component source = event.getTarget();
    if (isWithinListCell(source)) {
        row = getRowPosition(source);
        col = getColumnPosition(source);
        tableColumn = m_tableColumns.get(col);
        if (source instanceof Checkbox) {
            value = Boolean.valueOf(((Checkbox) source).isChecked());
        } else if (source instanceof Decimalbox) {
            value = ((Decimalbox) source).getValue();
        } else if (source instanceof Datebox) {
            value = ((Datebox) source).getValue();
        } else if (source instanceof Textbox) {
            value = ((Textbox) source).getValue();
        }
        if (value != null) {
            vcEvent = new TableValueChangeEvent(source, tableColumn.getHeaderValue().toString(), row, col, value, value);
            fireTableValueChange(vcEvent);
        }
    } else if (event.getTarget() instanceof WBrowserTable && Events.ON_SELECT.equals(event.getName())) {
        WBrowserTable table = (WBrowserTable) event.getTarget();
        if (table.isCheckmark()) {
            int cnt = table.getRowCount();
            if (cnt == 0 || !(table.getValueAt(0, 0) instanceof IDColumn))
                return;
            //update IDColumn
            tableColumn = m_tableColumns.get(0);
            for (int i = 0; i < cnt; i++) {
                IDColumn idcolumn = (IDColumn) table.getValueAt(i, 0);
                if (idcolumn != null) {
                    Listitem item = table.getItemAtIndex(i);
                    value = item.isSelected();
                    Boolean old = idcolumn.isSelected();
                    if (!old.equals(value)) {
                        vcEvent = new TableValueChangeEvent(source, tableColumn.getHeaderValue().toString(), i, 0, old, value);
                        fireTableValueChange(vcEvent);
                    }
                }
            }
        }
    }
    return;
}
Also used : Datebox(org.adempiere.webui.component.Datebox) WTableColumn(org.adempiere.webui.component.WTableColumn) Textbox(org.adempiere.webui.component.Textbox) Listitem(org.zkoss.zul.Listitem) IDColumn(org.compiere.minigrid.IDColumn) Decimalbox(org.zkoss.zul.Decimalbox) Checkbox(org.adempiere.webui.component.Checkbox) Component(org.zkoss.zk.ui.Component) TableValueChangeEvent(org.adempiere.webui.event.TableValueChangeEvent)

Example 14 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class VMatch method tableChanged.

//  cmd_searchTo
/***************************************************************************
	 *  Table Model Listener - calculate matched Qty
	 *  @param e event
	 */
public void tableChanged(TableModelEvent e) {
    if (e.getColumn() != 0)
        return;
    log.config("Row=" + e.getFirstRow() + "-" + e.getLastRow() + ", Col=" + e.getColumn() + ", Type=" + e.getType());
    panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    //  Matched From
    int matchedRow = xMatchedTable.getSelectedRow();
    KeyNamePair Product = (KeyNamePair) xMatchedTable.getValueAt(matchedRow, 5);
    //  Matched To
    double qty = 0.0;
    int noRows = 0;
    for (int row = 0; row < xMatchedToTable.getRowCount(); row++) {
        IDColumn id = (IDColumn) xMatchedToTable.getValueAt(row, 0);
        if (id != null && id.isSelected()) {
            KeyNamePair ProductCompare = (KeyNamePair) xMatchedToTable.getValueAt(row, 5);
            if (Product.getKey() != ProductCompare.getKey()) {
                id.setSelected(false);
            } else {
                if (matchMode.getSelectedIndex() == MODE_NOTMATCHED)
                    //  doc
                    qty += ((Double) xMatchedToTable.getValueAt(row, I_QTY)).doubleValue();
                //  matched
                qty -= ((Double) xMatchedToTable.getValueAt(row, I_MATCHED)).doubleValue();
                noRows++;
            }
        }
    }
    //  update quantities
    m_xMatchedTo = new BigDecimal(qty);
    xMatchedTo.setValue(m_xMatchedTo);
    difference.setValue(m_xMatched.subtract(m_xMatchedTo));
    bProcess.setEnabled(noRows != 0);
    panel.setCursor(Cursor.getDefaultCursor());
    //  Status
    statusBar.setStatusDB(noRows);
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) KeyNamePair(org.compiere.util.KeyNamePair) BigDecimal(java.math.BigDecimal)

Example 15 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class VFactReconcile method resetReconciliation.

//	zoom
private void resetReconciliation() {
    log.info("");
    //
    miniTable.stopEditor(true);
    if (miniTable.getRowCount() == 0)
        return;
    miniTable.setRowSelectionInterval(0, 0);
    calculateSelection();
    if (m_noSelected == 0)
        return;
    for (int r = 0; r < miniTable.getModel().getRowCount(); r++) {
        if (((IDColumn) miniTable.getModel().getValueAt(r, idColIndex)).isSelected()) {
            int factId = ((IDColumn) miniTable.getModel().getValueAt(r, idColIndex)).getRecord_ID();
            MFactReconciliation rec = new Query(Env.getCtx(), MFactReconciliation.Table_Name, "Fact_Acct_ID = ?", null).setParameters(new Object[] { factId }).first();
            if (rec == null) {
                continue;
            }
            rec.setMatchCode(null);
            rec.saveEx();
            ((DefaultTableModel) miniTable.getModel()).removeRow(r--);
        }
    }
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) Query(org.compiere.model.Query) MFactReconciliation(org.compiere.model.MFactReconciliation) DefaultTableModel(javax.swing.table.DefaultTableModel)

Aggregations

IDColumn (org.compiere.minigrid.IDColumn)74 SQLException (java.sql.SQLException)23 BigDecimal (java.math.BigDecimal)19 PreparedStatement (java.sql.PreparedStatement)18 ResultSet (java.sql.ResultSet)18 ArrayList (java.util.ArrayList)15 KeyNamePair (org.compiere.util.KeyNamePair)13 Timestamp (java.sql.Timestamp)8 Vector (java.util.Vector)5 GridField (org.compiere.model.GridField)5 MBrowseField (org.adempiere.model.MBrowseField)4 ApplicationException (org.adempiere.webui.exception.ApplicationException)4 SimpleDateFormat (java.text.SimpleDateFormat)3 DefaultTableModel (javax.swing.table.DefaultTableModel)3 PO (org.compiere.model.PO)3 Component (org.zkoss.zk.ui.Component)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 DecimalFormat (java.text.DecimalFormat)2 Date (java.util.Date)2 ChangeEvent (javax.swing.event.ChangeEvent)2