use of org.adempiere.webui.panel.InfoPanel in project adempiere by adempiere.
the class WAcctViewer method actionButton.
// actionTable
/**
* Action Button
*
* @param button pressed button
* @return ID
* @throws Exception
*/
private int actionButton(Button button) throws Exception {
String keyColumn = button.getName();
log.info(keyColumn);
// String whereClause = ""; // Elaine 2008/07/28
String whereClause = "(IsSummary='N' OR IsSummary IS NULL)";
String lookupColumn = keyColumn;
int record_id = m_data.getButtonRecordID(keyColumn);
if ("Account_ID".equals(keyColumn)) {
lookupColumn = "C_ElementValue_ID";
MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_Account);
if (ase != null)
whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
} else if ("User1_ID".equals(keyColumn)) {
lookupColumn = "C_ElementValue_ID";
MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserList1);
if (ase != null)
whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
} else if ("User2_ID".equals(keyColumn)) {
lookupColumn = "C_ElementValue_ID";
MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserList2);
if (ase != null)
whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
} else if ("User3_ID".equals(keyColumn)) {
lookupColumn = "C_ElementValue_ID";
MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserList3);
if (ase != null)
whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
} else if ("User4_ID".equals(keyColumn)) {
lookupColumn = "C_ElementValue_ID";
MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserList4);
if (ase != null)
whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
} else if ("UserElement1_ID".equals(keyColumn)) {
MAcctSchemaElement et = new Query(Env.getCtx(), MAcctSchemaElement.Table_Name, "elementtype = 'X1' ", null).setClient_ID().firstOnly();
String tableName = et.getAD_Column().getAD_Table().getTableName();
String lookupcolumnname = tableName + "_ID";
lookupColumn = lookupcolumnname;
whereClause = "";
} else if ("UserElement2_ID".equals(keyColumn)) {
MAcctSchemaElement et = new Query(Env.getCtx(), MAcctSchemaElement.Table_Name, "elementtype = 'X2' ", null).setClient_ID().firstOnly();
String tableName = et.getAD_Column().getAD_Table().getTableName();
String lookupcolumnname = tableName + "_ID";
lookupColumn = lookupcolumnname;
whereClause = "";
} else if (keyColumn.equals("M_Product_ID")) {
whereClause = "";
} else if (selDocument.isChecked())
whereClause = "";
if (// Record_ID
button == selRecord)
record_id = m_data.Record_ID;
else
record_id = m_data.getButtonRecordID(keyColumn);
String tableName = lookupColumn.substring(0, lookupColumn.length() - 3);
//whereClause = tableName + ".IsSummary='N'" + whereClause; // Elaine 2008/07/28
// Open modal
InfoPanel info = InfoPanel.create(m_data.WindowNo, tableName, lookupColumn, record_id, "", false, whereClause);
if (!info.loadedOK()) {
info.dispose();
info = null;
button.setLabel("");
m_data.whereInfo.put(keyColumn, "");
m_data.buttonRecordID.put(keyColumn, null);
return 0;
}
info.setVisible(true);
AEnv.showWindow(info);
boolean isCancelled = info.isCancelled();
boolean isOK = info.isOk();
Integer key = 0;
if (// Delete the saved info
isCancelled && !isOK) {
key = 0;
if (// Record_ID
button == selRecord)
m_data.Record_ID = key.intValue();
else {
// no query
m_data.whereInfo.put(keyColumn, "");
m_data.buttonRecordID.put(keyColumn, key.intValue());
}
button.setLabel("");
} else if (!isCancelled && isOK) {
// Save for query
// C_Project_ID=100 or ""
String selectSQL = info.getSelectedSQL();
key = (Integer) info.getSelectedKey();
log.config(keyColumn + " - " + key);
if (// Record_ID
button == selRecord)
m_data.Record_ID = key.intValue();
else {
// Add to query
m_data.whereInfo.put(keyColumn, keyColumn + "=" + key.intValue());
m_data.buttonRecordID.put(keyColumn, key.intValue());
}
// Display Selection and resize
button.setLabel(m_data.getButtonText(tableName, lookupColumn, selectSQL));
} else if (// xor: window closed or error - no change
!(isCancelled ^ isOK)) {
// m_data not changed
if (// Record_ID
button == selRecord)
key = m_data.Record_ID = key.intValue();
else
key = m_data.getButtonRecordID(keyColumn);
}
info = null;
return key.intValue();
}
Aggregations