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);
}
}
}
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;
}
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;
}
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);
}
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--);
}
}
}
Aggregations