use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class WPOSOrderLinePanel method seekFromProduct.
/**
* Seek in record from Product
* @param p_M_Product_ID
*/
public void seekFromProduct(int p_M_Product_ID) {
int m_C_OrderLine_ID = getC_OrderLine_ID(p_M_Product_ID);
if (m_C_OrderLine_ID <= 0)
return;
//
orderLineId = m_C_OrderLine_ID;
// Iterate
for (int i = 0; i < posTable.getRowCount(); i++) {
IDColumn key = (IDColumn) posTable.getModel().getValueAt(i, 0);
if (key != null && orderLineId > 0 && key.getRecord_ID() == orderLineId) {
posTable.setSelectedIndex(i);
selectLine();
break;
}
}
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class WPOSOrderLinePanel method selectLine.
public void selectLine() {
lineTableHandle.setEditable(posPanel.isModifyPrice(), posPanel.isDrafted());
IDColumn key = (IDColumn) posTable.getModel().getValueAt(posTable.getSelectedRow(), 0);
orderLineId = key.getRecord_ID();
showProductInfo(posTable.getSelectedRow());
posPanel.changeViewPanel();
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class WPOSTable method loadTable.
// loadTable
/**
* Load Table from Object Array.
* @param pos array of Persistent Objects
*/
public void loadTable(PO[] pos) {
int row = 0;
int col = 0;
// index into the PO array
int poIndex = 0;
String columnName;
Object data;
Class columnClass;
if (m_layout == null) {
throw new UnsupportedOperationException("Layout not defined");
}
// Clear Table
clearTable();
for (poIndex = 0; poIndex < pos.length; poIndex++) {
PO myPO = pos[poIndex];
row = getRowCount();
setRowCount(row + 1);
for (col = 0; col < m_layout.length; col++) {
columnName = m_layout[col].getColSQL();
data = myPO.get_Value(columnName);
if (data != null) {
columnClass = m_layout[col].getColClass();
if (isColumnClassMismatch(col, columnClass)) {
throw new ApplicationException("Cannot enter a " + columnClass.getName() + " in column " + col + ". " + "An object of type " + m_modelHeaderClass.get(col).getSimpleName() + " was expected.");
}
if (columnClass == IDColumn.class) {
data = new IDColumn(((Integer) data).intValue());
} else if (columnClass == Double.class) {
data = new Double(((BigDecimal) data).doubleValue());
}
}
// store
getModel().setDataAt(data, row, col);
}
}
autoSize();
if (getShowTotals())
addTotals(m_layout);
// repaint the table
this.repaint();
logger.config("Row(array)=" + getRowCount());
return;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class WMRPDetailed method work.
public void work() {
log.fine("Info.Worker.run");
StringBuilder sql = new StringBuilder(m_sqlMain);
String dynWhere = getSQLWhere();
if (dynWhere.length() > 0) {
System.out.println("where" + dynWhere);
// includes first AND
sql.append(dynWhere);
}
StringBuilder sqlFinal = new StringBuilder(MRole.getDefault().addAccessSQL(Msg.parseTranslation(getCtx(), sql.toString()), getTableName(), MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO));
sqlFinal.append(" ORDER BY DatePromised,ProductValue");
try {
PreparedStatement pstmt = DB.prepareStatement(sqlFinal.toString(), null);
log.fine("SQL=" + sqlFinal.toString());
setParameters(pstmt, false);
ResultSet rs = pstmt.executeQuery();
p_table.loadTable(rs);
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, "Info.Worker.run - " + sqlFinal.toString(), e);
}
if (getM_Product_ID() > 0) {
BigDecimal OnHand = getQtyOnHand();
for (int row = 0; row < p_table.getRowCount(); row++) {
Timestamp datepromised = (Timestamp) p_table.getValueAt(row, 5);
Timestamp today = new Timestamp(System.currentTimeMillis());
IDColumn id = (IDColumn) p_table.getValueAt(row, 0);
String TypeMRP = DB.getSQLValueString(null, "SELECT TypeMRP FROM " + getTableName() + " WHERE PP_MRP_ID=?", id.getRecord_ID());
String OrderType = (String) p_table.getValueAt(row, 11);
if (MPPMRP.TYPEMRP_Demand.equals(TypeMRP) || (// TODO: arhipac: teo_sarca: is this ok, since gross req = sum of all demands ???
MPPMRP.ORDERTYPE_Forecast.equals(OrderType) && datepromised.after(today))) {
BigDecimal QtyGrossReqs = (BigDecimal) p_table.getValueAt(row, 6);
OnHand = OnHand.subtract(QtyGrossReqs);
p_table.setValueAt(OnHand, row, 9);
}
if (MPPMRP.TYPEMRP_Supply.equals(TypeMRP)) {
BigDecimal QtyScheduledReceipts = (BigDecimal) p_table.getValueAt(row, 7);
BigDecimal QtyPlan = (BigDecimal) p_table.getValueAt(row, 8);
if (QtyPlan == null)
QtyPlan = Env.ZERO;
if (QtyScheduledReceipts == null)
QtyScheduledReceipts = Env.ZERO;
OnHand = OnHand.add(QtyScheduledReceipts.add(QtyPlan));
p_table.setValueAt(OnHand, row, 9);
}
}
}
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class WListbox method tableValueChange.
/* (non-Javadoc)
* @see org.adempiere.webui.event.TableValueChangeListener#tableValueChange
* (org.adempiere.webui.event.TableValueChangeEvent)
*/
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 // othewise just set the value in the model to the new value
{
this.setValueAt(event.getNewValue(), row, col);
}
}
return;
}
Aggregations