use of org.adempiere.webui.panel.InfoPAttributeInstancePanel in project adempiere by adempiere.
the class WPAttributeDialog method cmd_select.
// actionPerformed
/**
* Instance Selection Button
* @return true if selected
*/
private boolean cmd_select() {
log.config("");
int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_Warehouse_ID");
int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "C_DocType_ID");
if (C_DocType_ID > 0) {
MDocType doctype = new MDocType(Env.getCtx(), C_DocType_ID, null);
String docbase = doctype.getDocBaseType();
if (docbase.equals(MDocType.DOCBASETYPE_MaterialReceipt))
M_Warehouse_ID = 0;
}
// teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes
// Trifon - Always read Locator from Context. There are too many windows to read explicitly one by one.
int M_Locator_ID = 0;
// only window
M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true);
String title = "";
// Get Text
String sql = "SELECT p.Name, w.Name, w.M_Warehouse_ID FROM M_Product p, M_Warehouse w " + "WHERE p.M_Product_ID=? AND w.M_Warehouse_ID" + // teo_sarca [ 1564520 ]
(M_Locator_ID <= 0 ? "=?" : " IN (SELECT M_Warehouse_ID FROM M_Locator where M_Locator_ID=?)");
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID);
rs = pstmt.executeQuery();
if (rs.next()) {
title = ": " + rs.getString(1) + " - " + rs.getString(2);
// fetch the actual warehouse - teo_sarca [ 1564520 ]
M_Warehouse_ID = rs.getInt(3);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
InfoPAttributeInstancePanel pai = new InfoPAttributeInstancePanel(this, title, M_Warehouse_ID, M_Locator_ID, m_M_Product_ID, m_C_BPartner_ID);
//
if (m_M_AttributeSetInstance_ID != pai.getM_AttributeSetInstance_ID() || !(m_M_AttributeSetInstance_ID == 0 && pai.getM_AttributeSetInstance_ID() == -1)) {
m_changed = true;
//
if (pai.getM_AttributeSetInstance_ID() != -1) {
m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
m_M_AttributeSetInstanceName = pai.getM_AttributeSetInstanceName();
m_M_Locator_ID = pai.getM_Locator_ID();
} else {
m_M_AttributeSetInstance_ID = 0;
m_M_AttributeSetInstanceName = "";
// Leave the locator alone
}
}
return m_changed;
}
Aggregations