use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class InfoPanel method onEvent.
// getAD_Window_ID
public void onEvent(Event event) {
if (!p_loadedOK)
// We aren't ready
return;
if (m_busy)
// We're busy. Ignore events.
return;
if (event != null) {
if (event.getName().equals("onOK")) {
// The enter key was pressed in a criteria field. Ignore it. The key click will trigger
// other events that will be trapped.
event.stopPropagation();
return;
}
Component component = event.getTarget();
if (component != null) {
// Generic components in the criteria fields
if (component instanceof Textbox) {
Textbox tb = ((Textbox) component);
if (tb.hasChanged()) {
p_triggerRefresh = true;
} else {
// if the dialog was opened from a menu.
if (isModal())
// Save the selection and close;
dispose(true);
else
return;
}
} else if (component instanceof Checkbox) {
// Check box changes generally always cause a refresh
// Capture changes that don't in a specific event handler
p_triggerRefresh = true;
Checkbox cb = (Checkbox) component;
if (cb.getName() != null && cb.getName().equals("AutoQuery")) {
// Only trigger a refresh if the check box is selected
if (!cb.isSelected()) {
return;
}
}
} else {
// Assume another type of component
if (event.getName().equals("onChange")) {
if (component instanceof Combobox) {
if (// Test for meaningful changes. Null == " ".
hasOutstandingChanges())
p_triggerRefresh = true;
} else
p_triggerRefresh = true;
}
}
// Buttons
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_OK))) {
// VLookup fields in the criteria
if (hasOutstandingChanges()) {
return;
} else {
// We might close
p_triggerRefresh = false;
}
onOk();
} else if (component == p_table && event.getName().equals(Events.ON_DOUBLE_CLICK)) {
onDoubleClick();
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_RESET))) {
// Created by the reset button, if used, to reset the criteria panel.
// Go back to the defaults
// Prevent other actions
m_busy = true;
// Should be overridden in the subordinate class
initInfo();
m_busy = false;
p_triggerRefresh = true;
// Ignore the autoQuery value and refresh now.
p_refreshNow = true;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_REFRESH))) {
// Refresh always causes a requery in case there are
// changes to the underlying tables - even if the
// criteria haven't changed.
p_resetColumns = true;
p_triggerRefresh = true;
p_refreshNow = true;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_CANCEL))) {
m_cancel = true;
// close
dispose(false);
} else // Elaine 2008/12/16
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_HISTORY))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
showHistory();
}
return;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_CUSTOMIZE))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
customize();
}
return;
} else //
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_ZOOM))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
zoom();
if (isModal())
this.detach();
}
return;
} else if (component == paging) {
int pgNo = paging.getActivePage();
if (pageNo != pgNo) {
p_table.clearSelection();
pageNo = pgNo;
int start = pageNo * PAGE_SIZE;
int end = start + PAGE_SIZE;
List<Object> subList = readLine(start, end);
model = new ListModelTable(subList);
model.setSorter(this);
model.addTableModelListener(this);
p_table.setData(model, null);
p_table.setSelectedIndex(0);
}
}
}
// All events, unless trapped above, will get here.
// Check if we need to reset the table. The flag is reset when
// the table is reset. The first change triggers the reset.
p_resetColumns = p_resetColumns || columnIsDynamic(component);
// Refresh if the autoquery feature is selected or the refresh button is clicked.
if ((p_triggerRefresh && autoQuery()) || p_refreshNow) {
prepareAndExecuteQuery();
p_refreshNow = false;
}
}
}
use of org.adempiere.webui.component.ListModelTable 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.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class InfoProductPanel method clearAtpTab.
// refresh
//End - fer_luck @ centuryon
/**
* clearAtpTab() - wipe the ATP table of data
*/
private void clearAtpTab() {
m_modelAtp = new ListModelTable();
m_tableAtp.setRowCount(0);
m_tableAtp.setModel(m_modelAtp);
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WCreateFromShipmentUI method findProductRow.
/**
* Finds the row where a given product is. If the product is not found
* in the table -1 is returned.
* @param M_Product_ID
* @return Row of the product or -1 if non existing.
*
*/
private int findProductRow(int M_Product_ID) {
//DefaultTableModel model = (DefaultTableModel)dialog.getMiniTable().getModel();
ListModelTable model = (ListModelTable) v_CreateFromPanel.getWListbox().getModel();
KeyNamePair kp;
for (int i = 0; i < model.getRowCount(); i++) {
kp = (KeyNamePair) model.getValueAt(i, 4);
if (kp.getKey() == M_Product_ID) {
return (i);
}
}
return (-1);
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WCharge method dynamicInitialise.
/**
* Initialises the dynamic components of the form.
* <li>Gets defaults for primary AcctSchema
* <li>Creates Table with Accounts
*/
private void dynamicInitialise() {
findChargeElementID();
ListModelTable model = new ListModelTable(getData());
m_tblData.setData(model, getColumnNames());
setColumnClass(m_tblData);
findTaxCategoryID();
return;
}
Aggregations