Search in sources :

Example 86 with KeyNamePair

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());
}
Also used : SQLException(java.sql.SQLException) KeyNamePair(org.compiere.util.KeyNamePair) BigDecimal(java.math.BigDecimal)

Example 87 with KeyNamePair

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);
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair) Point(java.awt.Point)

Example 88 with KeyNamePair

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;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) KeyNamePair(org.compiere.util.KeyNamePair)

Example 89 with KeyNamePair

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);
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair)

Example 90 with KeyNamePair

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));
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair)

Aggregations

KeyNamePair (org.compiere.util.KeyNamePair)286 SQLException (java.sql.SQLException)66 ResultSet (java.sql.ResultSet)65 PreparedStatement (java.sql.PreparedStatement)62 BigDecimal (java.math.BigDecimal)46 ArrayList (java.util.ArrayList)38 ValueNamePair (org.compiere.util.ValueNamePair)36 Timestamp (java.sql.Timestamp)32 Vector (java.util.Vector)22 ListItem (org.adempiere.webui.component.ListItem)22 Login (org.compiere.util.Login)22 MProduct (org.compiere.model.MProduct)17 IDColumn (org.compiere.minigrid.IDColumn)13 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)12 AdempiereException (org.adempiere.exceptions.AdempiereException)10 MLookup (org.compiere.model.MLookup)10 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)9 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)8 org.apache.ecs.xhtml.script (org.apache.ecs.xhtml.script)8 MUOM (org.compiere.model.MUOM)7