use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class InfoPanel method getSelectedRowKeys.
// getSelectedRowKey
/**
* Get the keys of selected row/s based on layout defined in prepareTable
* @return IDs if selection present
* @author ashley
*/
protected ArrayList<Integer> getSelectedRowKeys() {
ArrayList<Integer> selectedDataList = new ArrayList<Integer>();
if (p_table.getKeyColumnIndex() == -1) {
return selectedDataList;
}
if (p_multipleSelection) {
int[] rows = p_table.getSelectedIndices();
for (int row = 0; row < rows.length; row++) {
Object data = p_table.getModel().getValueAt(rows[row], p_table.getKeyColumnIndex());
if (data instanceof IDColumn) {
IDColumn dataColumn = (IDColumn) data;
selectedDataList.add(dataColumn.getRecord_ID());
} else {
log.severe("For multiple selection, IDColumn should be key column for selection");
}
}
}
if (selectedDataList.size() == 0) {
int row = p_table.getSelectedRow();
if (row != -1 && p_table.getKeyColumnIndex() != -1) {
Object data = p_table.getModel().getValueAt(row, p_table.getKeyColumnIndex());
if (data instanceof IDColumn)
selectedDataList.add(((IDColumn) data).getRecord_ID());
if (data instanceof Integer)
selectedDataList.add((Integer) data);
}
}
return selectedDataList;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class InfoProductPanel method refreshAtpTab.
// initAtpTab
/**
* Refresh ATP
*/
private void refreshAtpTab() {
boolean showDetail = checkShowDetail.isSelected();
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
int M_Warehouse_ID = 0;
// row to prevent array index out of bounds. BF 3051361
if (m_ATP_M_Warehouse_ID > 0) {
M_Warehouse_ID = m_ATP_M_Warehouse_ID;
} else
M_Warehouse_ID = m_M_Warehouse_ID;
if (M_Warehouse_ID == 0) {
// Do nothing and pass blank data to the table
} else // Update the table
{
// Create the SELECT ..UNION. clause
// This is done in-line rather than using prepareTable() so we can add a running sum to the data.
String sql;
if (!showDetail)
sql = "(SELECT s.M_Product_ID, w.Name as warehouse, l.value as locator, 0 as ID, null as Date," + " sum(s.QtyOnHand) as AvailQty, null as DeltaQty, sum(s.QtyOrdered) as QtyOrdered, sum(s.QtyReserved) as QtyReserved," + // " s.PASI,"
" null as sumPASI," + " 0 as ASI," + " null as BP_Name, null as DocumentNo, 10 as SeqNo";
else
sql = "(SELECT s.M_Product_ID, w.Name as warehouse, l.value as locator, s.M_AttributeSetInstance_ID as ID, now() as Date," + " s.QtyOnHand as AvailQty, null as DeltaQty, s.QtyOrdered as QtyOrdered, s.QtyReserved as QtyReserved," + " CASE WHEN s.PASI = '' THEN '{' || COALESCE(s.M_AttributeSetInstance_ID,0) || '}' ELSE s.PASI END as sumPASI," + " COALESCE(M_AttributeSetInstance_ID,0) as ASI," + " null as BP_Name, null as DocumentNo, 10 as SeqNo";
sql += " FROM (SELECT M_Product_ID, M_Locator_ID, QtyOnHand, QtyReserved, QtyOrdered," + " COALESCE(productAttribute(M_AttributeSetInstance_ID)::varchar, '') as PASI," + " COALESCE(M_AttributeSetInstance_ID,0) as M_AttributeSetInstance_ID FROM M_Storage) s " + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID)" + " AND s.M_Product_ID=" + m_M_Product_ID;
if (M_Warehouse_ID != 0)
sql += " AND l.M_Warehouse_ID=" + M_Warehouse_ID;
// sql += " AND s.M_AttributeSetInstance_ID=?";
if (!showDetail) {
//sql += " AND (s.QtyOnHand<>0)";
sql += " GROUP BY s.M_Product_ID, w.Name, l.value, s.M_Locator_ID, sumPASI, ASI, BP_Name, DocumentNo, SeqNo ";
} else
//sql += " AND (s.QtyOnHand<>0) ";
;
sql += " UNION ALL ";
// Orders
sql += "SELECT ol.M_Product_ID, w.Name as warehouse, null as locator, ol.M_AttributeSetInstance_ID as ID, o.DatePromised as date," + " null as AvailQty," + " CASE WHEN dt.DocBaseType = 'POO' THEN ol.QtyOrdered ELSE -ol.QtyReserved END as DeltaQty," + " CASE WHEN dt.DocBaseType = 'POO' THEN ol.QtyOrdered ELSE null END as QtyOrdered," + " CASE WHEN dt.DocBaseType = 'POO' THEN 0 ELSE 0 END as QtyReserved," + " productAttribute(ol.M_AttributeSetInstance_ID) as sumPASI," + " ol.M_AttributeSetInstance_ID as ASI," + " bp.Name as BP_Name, dt.PrintName || ' ' || o.DocumentNo As DocumentNo, 20 as SeqNo " + "FROM C_Order o" + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)" + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)" + " INNER JOIN C_BPartner bp ON (o.C_BPartner_ID=bp.C_BPartner_ID) " + "WHERE ol.QtyReserved<>0 AND o.DocStatus in ('IP','CO')" + " AND ol.M_Product_ID=" + m_M_Product_ID;
if (M_Warehouse_ID != 0)
sql += " AND w.M_Warehouse_ID=" + M_Warehouse_ID;
//if (m_M_AttributeSetInstance_ID > 0)
// sql += " AND ol.M_AttributeSetInstance_ID=?";
//sql += " ORDER BY M_Product_ID, SeqNo, ID, date, locator";
sql += " UNION ALL ";
// Distribution Orders out bound
sql += "SELECT ol.M_Product_ID, wf.Name as warehouse, lf.value as locator, ol.M_AttributeSetInstance_ID as ID, ol.DatePromised as date," + " null as AvailQty," + " -ol.QtyOrdered+ol.QtyInTransit+ol.QtyDelivered as DeltaQty," + " null as QtyOrdered," + " null as QtyReserved," + " productAttribute(ol.M_AttributeSetInstance_ID) as sumPASI," + " ol.M_AttributeSetInstance_ID as ASI," + " bp.Name as BP_Name, dt.PrintName || ' ' || o.DocumentNo As DocumentNo, 20 as SeqNo " + "FROM DD_Order o" + " INNER JOIN DD_OrderLine ol ON (o.DD_Order_ID=ol.DD_Order_ID)" + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN M_Locator l ON (l.M_Locator_ID = ol.M_LocatorTo_ID)" + " INNER JOIN M_Locator lf on (lf.M_Locator_ID = ol.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID)" + " INNER JOIN M_Warehouse wf ON (lf.M_Warehouse_ID=wf.M_Warehouse_ID)" + " INNER JOIN C_BPartner bp ON (o.C_BPartner_ID = bp.C_BPartner_ID) " + "WHERE ol.QtyReserved<>0 AND o.DocStatus in ('IP','CO') AND o.IsDelivered = 'N'" + " AND ol.M_Product_ID=" + m_M_Product_ID;
if (M_Warehouse_ID != 0)
sql += " AND wf.M_Warehouse_ID=" + M_Warehouse_ID;
//if (m_M_AttributeSetInstance_ID > 0)
// sql += " AND ol.M_AttributeSetInstance_ID=?";
sql += " UNION ALL ";
// Distribution Orders in bound
sql += "SELECT ol.M_Product_ID, w.Name as warehouse, l.value as locator, ol.M_AttributeSetInstance_ID as ID, ol.DatePromised as date," + " null as AvailQty," + " ol.QtyOrdered-ol.QtyDelivered as DeltaQty," + " null as QtyOrdered," + " null as QtyReserved," + " productAttribute(ol.M_AttributeSetInstance_ID) as sumPASI," + " ol.M_AttributeSetInstance_ID as ASI," + " bp.Name as BP_Name, dt.PrintName || ' ' || o.DocumentNo As DocumentNo, 20 as SeqNo " + "FROM DD_Order o" + " INNER JOIN DD_OrderLine ol ON (o.DD_Order_ID=ol.DD_Order_ID)" + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN M_Locator l ON (l.M_Locator_ID = ol.M_LocatorTo_ID)" + " INNER JOIN M_Locator lf on (lf.M_Locator_ID = ol.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID)" + " INNER JOIN M_Warehouse wf ON (lf.M_Warehouse_ID=wf.M_Warehouse_ID)" + " INNER JOIN C_BPartner bp ON (wf.AD_Org_ID=bp.AD_OrgBP_ID) " + "WHERE ol.QtyOrdered - ol.Qtydelivered > 0 AND o.DocStatus in ('IP','CO') AND o.IsDelivered='N'" + " AND ol.M_Product_ID=" + m_M_Product_ID;
if (M_Warehouse_ID != 0)
sql += " AND w.M_Warehouse_ID=" + M_Warehouse_ID;
//if (m_M_AttributeSetInstance_ID > 0)
// sql += " AND ol.M_AttributeSetInstance_ID=?";
sql += " ORDER BY M_Product_ID, SeqNo, ID, date, locator)";
double qty = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
int index = 1;
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next()) {
// The order of data matches the layout, not the query
// M_Product_ID, warehouse, locator, ID, Date, AvailQty, DelataQty, (1..7)
// QtyOrdered, QtyReserved, (8..9)
// PASI, ASI, (10..11)
// BP_Name, DocumentNo, SeqNo (12..14)
IDColumn mpid = new IDColumn(rs.getInt(1));
Vector<Object> line = new Vector<Object>(9);
// M_Product_ID
line.add(mpid);
// warehouse
line.add(rs.getString(2));
// Locator
line.add(rs.getString(3));
// Date
line.add(rs.getTimestamp(5));
double deltaQty = rs.getDouble(7);
qty += +rs.getDouble(6) + deltaQty;
// Qty Available (running sum)
line.add(new Double(qty) - rs.getDouble(9));
// Qty on hand (this line)
line.add(new Double(rs.getDouble(6)));
// Delta Qty
line.add(new Double(rs.getDouble(7)));
// BPartner
line.add(rs.getString(12));
// QtyOrdered
line.add(new Double(rs.getDouble(8)));
// QtyReserved
line.add(new Double(rs.getDouble(9)));
// ASI
line.add(rs.getString(10));
// DocumentNo
line.add(rs.getString(13));
data.add(line);
}
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
// Header
for (int i = 0; i < m_layoutATP.length; i++) {
m_tableAtp.addColumn(m_layoutATP[i].getColHeader());
}
m_modelAtp = new ListModelTable(data);
// Avoid an exception
//SwingUtilities.invokeLater(new Runnable(){public void run(){
m_tableAtp.setModel(m_modelAtp);
// set editors (two steps)
for (int i = 0; i < m_layoutATP.length; i++) {
m_tableAtp.setColumnClass(i, m_layoutATP[i].getColClass(), m_layoutATP[i].isReadOnly(), m_layoutATP[i].getColHeader());
if (m_layoutATP[i].isColorColumn()) {
// QtyAvailable.
m_tableAtp.setColorColumn(i);
}
}
m_tableAtp.autoSize();
m_tableAtp.repaint();
//}});
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class InfoPanel method setSelectedRow.
// prepareTable
/**
* Set the selected row to a particular key if found
* @returns true if successful
*/
protected boolean setSelectedRow(int record_id) {
if (p_table == null) {
return false;
}
// Is there a key column?
if (p_table.getKeyColumnIndex() == -1) {
return false;
}
// If the query is empty, return
if (p_table.getRowCount() == 0) {
return false;
}
if (// Select all by default
p_table.isMultiSelection() && p_table.isDefaultSelected()) {
// All rows will be selected by default
return false;
}
if (record_id <= 0) {
// Select the first record
p_table.addItemToSelection(p_table.getItemAtIndex(0));
log.fine("Selected the first record shown");
return true;
}
// Is the record already selected?
Integer selectedKey = (Integer) getSelectedKey();
if (// We're already there
selectedKey != null && selectedKey.intValue() == record_id)
return true;
// Nothing or the wrong row selected - try to find the record in the table
int rows = p_table.getRowCount();
// Ignore the total row
if (p_table.getShowTotals())
rows = rows - 1;
for (int row = 0; row < rows; row++) {
Object data = p_table.getModel().getValueAt(row, p_table.getKeyColumnIndex());
if (data instanceof IDColumn) {
IDColumn dataColumn = (IDColumn) data;
if (dataColumn.getRecord_ID() == record_id) {
p_table.addItemToSelection(p_table.getItemAtIndex(row));
log.fine("Record_ID = " + record_id + " found at row " + row);
return true;
}
}
}
// record_id not found in the current list. Select the first shown.
p_table.addItemToSelection(p_table.getItemAtIndex(0));
log.fine("Record_ID = " + record_id + " not found in the current table. Selecting the first record.");
return true;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class Info method setSelectedRow.
// getSelectedKey
/**
* Set the selected row to a particular key if found
* @returns true if successful
*/
protected boolean setSelectedRow(int record_id) {
// Is there a key column?
if (p_table.getKeyColumnIndex() == -1) {
return false;
}
if (p_table == null) {
return false;
}
// If the query is empty, return
if (p_table.getRowCount() == 0) {
return false;
}
if (// Select all by default
p_table.isMultiSelection() && p_table.isDefaultSelected()) {
// All rows will be selected by default
return false;
}
if (record_id <= 0) {
// Select the first record
p_table.changeSelection(0, p_table.getKeyColumnIndex(), false, false);
log.fine("Selected the first record shown");
return true;
}
// Is the record already selected?
Integer selectedKey = (Integer) getSelectedKey();
if (// We're already there
selectedKey != null && selectedKey.intValue() == record_id)
return true;
// Nothing or the wrong row selected - try to find the record in the table
int rows = p_table.getRowCount();
// Ignore the total row
if (p_table.getShowTotals())
rows = rows - 1;
for (int row = 0; row < rows; row++) {
Object data = p_table.getModel().getValueAt(row, p_table.getKeyColumnIndex());
if (data instanceof IDColumn) {
IDColumn dataColumn = (IDColumn) data;
if (dataColumn.getRecord_ID() == record_id) {
p_table.changeSelection(row, p_table.getKeyColumnIndex(), false, false);
log.fine("Record_ID = " + record_id + " found at row " + row);
return true;
}
}
}
// record_id not found in the current list. Select the first shown.
p_table.changeSelection(0, p_table.getKeyColumnIndex(), false, false);
log.fine("Record_ID = " + record_id + " not found in the current table. Selecting the first record.");
return true;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class WPOSOrderLinePanel method refreshPanel.
@Override
public void refreshPanel() {
if (!posPanel.hasOrder()) {
posTable.loadTable(new PO[0]);
}
// Load Data
lineTableHandle.loadTable(posPanel.getC_Order_ID());
//
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);
posPanel.changeViewPanel();
showProductInfo(i);
break;
}
// Select first row, if end of table and no row has been selected
if (i == posTable.getRowCount() - 1) {
// Set Current Order Line
orderLineId = key.getRecord_ID();
posTable.setSelectedIndex(0);
posPanel.changeViewPanel();
showProductInfo(0);
}
}
return;
}
Aggregations