IDEMPIERE-2665 ListBox component changed to Table Dir
This commit is contained in:
parent
1ca7631d78
commit
ffc0e623f9
|
@ -15,9 +15,7 @@ import org.adempiere.webui.component.ConfirmPanel;
|
|||
import org.adempiere.webui.component.Grid;
|
||||
import org.adempiere.webui.component.GridFactory;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.ListItem;
|
||||
import org.adempiere.webui.component.ListModelTable;
|
||||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.component.ListboxFactory;
|
||||
import org.adempiere.webui.component.Panel;
|
||||
import org.adempiere.webui.component.Row;
|
||||
|
@ -37,8 +35,10 @@ import org.adempiere.webui.panel.IFormController;
|
|||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.compiere.apps.form.FactReconcile;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.X_C_ElementValue;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -94,7 +94,7 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
|
|||
private Label labelReconciled = new Label();
|
||||
private Checkbox isReconciled = new Checkbox();
|
||||
private Label labelAccount = new Label();
|
||||
private Listbox fieldAccount = new Listbox();
|
||||
private WTableDirEditor fieldAccount = null;
|
||||
private Label labelBPartner = new Label();
|
||||
private WSearchEditor fieldBPartner = null;
|
||||
|
||||
|
@ -184,8 +184,8 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
|
|||
row.appendCellChild(fieldOrg.getComponent(), 2);
|
||||
row = rows.newRow();
|
||||
row.appendCellChild(labelAccount.rightAlign());
|
||||
fieldAccount.setHflex("true");
|
||||
row.appendCellChild(fieldAccount, 2);
|
||||
fieldAccount.getComponent().setHflex("true");
|
||||
row.appendCellChild(fieldAccount.getComponent(), 2);
|
||||
row.appendCellChild(labelReconciled);
|
||||
row.appendCellChild(isReconciled, 2);
|
||||
row = rows.newRow();
|
||||
|
@ -274,16 +274,14 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
|
|||
fieldProduct = new WSearchEditor("M_Product_ID", false, false, true, lookupProduct);
|
||||
|
||||
// Account
|
||||
loadAccounts();
|
||||
}
|
||||
|
||||
private void loadAccounts(){
|
||||
fieldAccount.removeAllItems();
|
||||
Vector<KeyNamePair> vector = getAccount();
|
||||
for(int i=0;i<vector.size();i++)
|
||||
fieldAccount.addItem(vector.get(i));
|
||||
fieldAccount.setMold("select");
|
||||
fieldAccount.setSelectedIndex(0);
|
||||
AD_Column_ID = MColumn.getColumn_ID(X_C_ElementValue.Table_Name, X_C_ElementValue.COLUMNNAME_C_ElementValue_ID);
|
||||
MLookup lookupAccount = MLookupFactory.get(Env.getCtx(), form.getWindowNo(), AD_Column_ID, DisplayType.TableDir, Env.getLanguage(Env.getCtx()),
|
||||
X_C_ElementValue.COLUMNNAME_C_ElementValue_ID, 0, true,
|
||||
" C_ElementValue.IsActive='Y' AND C_ElementValue.IsSummary='N' "
|
||||
+ "AND EXISTS (SELECT 1 FROM C_AcctSchema_Element ase "
|
||||
+ "WHERE ase.C_Element_ID=C_ElementValue.C_Element_ID AND ase.ElementType='AC' "
|
||||
+ "AND ase.C_AcctSchema_ID=" + m_C_AcctSchema_ID + " AND ase.AD_Client_ID=" + m_AD_Client_ID + ") ");
|
||||
fieldAccount = new WTableDirEditor("C_ElementValue_ID", false, false, true, lookupAccount);
|
||||
}
|
||||
|
||||
public void loadData(){
|
||||
|
@ -293,14 +291,8 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
|
|||
else
|
||||
m_C_AcctSchema_ID = 0;
|
||||
|
||||
ListItem listAccount = fieldAccount.getSelectedItem();
|
||||
int Account_ID = 0;
|
||||
if(listAccount!=null){
|
||||
Account_ID = (Integer)listAccount.getValue();
|
||||
}
|
||||
|
||||
if (Account_ID != 0)
|
||||
m_Account_ID = Account_ID;
|
||||
if(fieldAccount.getValue()!=null)
|
||||
m_Account_ID = (Integer)fieldAccount.getValue();
|
||||
else
|
||||
m_Account_ID = 0;
|
||||
|
||||
|
@ -388,7 +380,7 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
|
|||
|
||||
if (name.equals("C_AcctSchema_ID")) {
|
||||
m_C_AcctSchema_ID = ((Integer)value).intValue();
|
||||
loadAccounts();
|
||||
fieldAccount.actionRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,41 +253,4 @@ public class FactReconcile {
|
|||
rec.setMatchCode(null);
|
||||
return rec.save();
|
||||
}
|
||||
|
||||
protected Vector<KeyNamePair> getAccount(){
|
||||
Vector<KeyNamePair> vector = new Vector<KeyNamePair>();
|
||||
String sql = MRole.getDefault().addAccessSQL(
|
||||
"SELECT ev.C_ElementValue_ID, ev.Value || ' ' || ev.Name FROM C_ElementValue ev", "ev",
|
||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)
|
||||
+ "AND ev.IsActive='Y' AND ev.IsSummary='N' "
|
||||
+ "AND EXISTS (SELECT 1 FROM C_AcctSchema_Element ase "
|
||||
+ "WHERE ase.C_Element_ID=ev.C_Element_ID AND ase.ElementType='AC' "
|
||||
+ "AND ase.C_AcctSchema_ID=" + m_C_AcctSchema_ID + " AND ase.AD_Client_ID=" + m_AD_Client_ID + ") "
|
||||
+ "ORDER BY 2";
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
vector.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue