use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class MiniTable method loadTable.
// setRowCount
/**************************************************************************
* Load Table from ResultSet - The ResultSet is not closed
*
* @param rs ResultSet with the column layout defined in prepareTable
*/
public void loadTable(ResultSet rs) {
if (m_layout == null)
throw new UnsupportedOperationException("Layout not defined");
// Clear Table
setRowCount(0);
//
try {
while (rs.next()) {
int row = getRowCount();
setRowCount(row + 1);
// columns start with 1
int colOffset = 1;
for (int col = 0; col < m_layout.length; col++) {
Object data = null;
Class<?> c = m_layout[col].getColClass();
int colIndex = col + colOffset;
if (c == IDColumn.class)
data = new IDColumn(rs.getInt(colIndex));
else if (c == Boolean.class)
data = new Boolean("Y".equals(rs.getString(colIndex)));
else if (c == Timestamp.class)
data = rs.getTimestamp(colIndex);
else if (c == BigDecimal.class)
data = rs.getBigDecimal(colIndex);
else if (c == Double.class)
data = rs.getDouble(colIndex);
else if (c == Integer.class)
data = rs.getInt(colIndex);
else if (c == KeyNamePair.class) {
String display = rs.getString(colIndex);
int key = rs.getInt(colIndex + 1);
data = new KeyNamePair(key, display);
colOffset++;
} else {
String s = rs.getString(colIndex);
if (s != null)
// problems with NCHAR
data = s.trim();
}
// store
setValueAt(data, row, col);
// log.fine( "r=" + row + ", c=" + col + " " + m_layout[col].getColHeader(),
// "data=" + data.toString() + " " + data.getClass().getName() + " * " + m_table.getCellRenderer(row, col));
}
}
} catch (SQLException e) {
log.log(Level.SEVERE, "", e);
}
if (getShowTotals())
addTotals(m_layout);
autoSize();
log.config("Row(rs)=" + getRowCount());
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class Viewer method selectReportView.
// fillComboReport
/**
* Select a Report view from print format
* @param p_AD_ReportView_ID
*/
private void selectReportView(int p_AD_ReportView_ID) {
comboReportView.removeActionListener(this);
// Select
KeyNamePair selectValue = null;
for (int i = 0; i < comboReportView.getItemCount(); i++) {
KeyNamePair pp = (KeyNamePair) comboReportView.getItemAt(i);
if (pp.getKey() == p_AD_ReportView_ID) {
selectValue = pp;
break;
}
}
// Set Value
if (selectValue != null) {
comboReportView.setSelectedItem(selectValue);
} else {
comboReportView.setSelectedIndex(0);
}
// Add Listener
comboReportView.addActionListener(this);
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class TranslationController method getClientList.
public ArrayList<KeyNamePair> getClientList() {
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
list.add(new KeyNamePair(-1, ""));
String sql = "SELECT Name, AD_Client_ID " + "FROM AD_Client " + "WHERE IsActive='Y' " + "ORDER BY AD_Client_ID";
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
KeyNamePair kp = new KeyNamePair(rs.getInt(2), rs.getString(1));
list.add(kp);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
return list;
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VTranslationDialog method dynInit.
// jbInit
/**
* Dynamic Init.
* - fill Language & Table
*/
private void dynInit() {
// Fill Client
ArrayList<KeyNamePair> clients = getClientList();
for (KeyNamePair client : clients) cbClient.addItem(client);
// Fill Language
ArrayList<ValueNamePair> languages = getLanguageList();
for (ValueNamePair language : languages) cbLanguage.addItem(language);
// Fill Table
ArrayList<ValueNamePair> tables = getTableList();
for (ValueNamePair table : tables) cbTable.addItem(table);
// Info
setStatusBar(statusBar);
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class POSLookupProduct method setFillingComponent.
/**
* Set Filling Component
*/
public void setFillingComponent(JComboBox<KeyNamePair> productLookupComboBox) {
this.productLookupComboBox = productLookupComboBox;
productLookupComboBox.addActionListener(this);
productLookupComboBox.addKeyListener(this);
char[] charArray = new char[200];
Arrays.fill(charArray, ' ');
this.fill = new String(charArray);
this.title = new StringBuffer().append(productValueTitle).append(separator).append(productTitle).append(separator).append(availableTitle).append(separator).append(priceStdTitle).append(separator).append(priceListTile).toString();
productLookupComboBox.addItem(new KeyNamePair(0, this.title));
}
Aggregations