Search in sources :

Example 76 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class VInOutInvoiceGen method tableChanged.

//	stateChanged
/**
	 *  Table Model Listener
	 *  @param e event
	 */
public void tableChanged(TableModelEvent e) {
    int rowsSelected = 0;
    int rows = miniTable.getRowCount();
    for (int i = 0; i < rows; i++) {
        //  ID in column 0
        IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
        if (id != null && id.isSelected())
            rowsSelected++;
    }
    statusBar.setStatusDB(" " + rowsSelected + " ");
}
Also used : IDColumn(org.compiere.minigrid.IDColumn)

Example 77 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class VInOutInvoiceGen method executeQuery.

/**
	 *  Query Info
	 */
private void executeQuery() {
    log.info("");
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
    String sql = "";
    KeyNamePair docTypeKNPair = (KeyNamePair) cmbDocType.getSelectedItem();
    if (docTypeKNPair.getKey() == MRMA.Table_ID) {
        sql = getRMASql();
    } else {
        sql = getOrderSQL();
    }
    log.fine(sql);
    //  reset table
    int row = 0;
    miniTable.setRowCount(row);
    //  Execute
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
        pstmt.setInt(1, AD_Client_ID);
        ResultSet rs = pstmt.executeQuery();
        //
        while (rs.next()) {
            //  extend table
            miniTable.setRowCount(row + 1);
            //  set values
            //  C_Order_ID
            miniTable.setValueAt(new IDColumn(rs.getInt(1)), row, 0);
            //  Org
            miniTable.setValueAt(rs.getString(2), row, 1);
            //  DocType
            miniTable.setValueAt(rs.getString(3), row, 2);
            //  Doc No
            miniTable.setValueAt(rs.getString(4), row, 3);
            //  BPartner
            miniTable.setValueAt(rs.getString(5), row, 4);
            //  DateOrdered
            miniTable.setValueAt(rs.getTimestamp(6), row, 5);
            //  TotalLines
            miniTable.setValueAt(rs.getBigDecimal(7), row, 6);
            //  prepare next
            row++;
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql.toString(), e);
    }
    //
    miniTable.autoSize();
//	statusBar.setStatusDB(String.valueOf(miniTable.getRowCount()));
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) KeyNamePair(org.compiere.util.KeyNamePair)

Example 78 with IDColumn

use of org.compiere.minigrid.IDColumn in project lar_361 by comitsrl.

the class InvoiceGen method saveSelection.

// executeQuery
/**
 *	Save Selection & return selecion Query or ""
 *  @return where clause like C_Order_ID IN (...)
 */
public void saveSelection(IMiniTable miniTable) {
    log.info("");
    // Array of Integers
    ArrayList<Integer> results = new ArrayList<Integer>();
    setSelection(null);
    // Get selected entries
    int rows = miniTable.getRowCount();
    for (int i = 0; i < rows; i++) {
        // ID in column 0
        IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
        // log.fine( "Row=" + i + " - " + id);
        if (id != null && id.isSelected())
            results.add(id.getRecord_ID());
    }
    if (results.size() == 0)
        return;
    log.config("Selected #" + results.size());
    setSelection(results);
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) ArrayList(java.util.ArrayList)

Example 79 with IDColumn

use of org.compiere.minigrid.IDColumn in project lar_361 by comitsrl.

the class Info method actionPerformed.

// getSelectedSQL;
/**
 ************************************************************************
 *	(Button) Action Listener & Popup Menu
 *  @param e event
 */
public void actionPerformed(ActionEvent e) {
    // Popup => Calculator
    if (e.getSource().equals(calcMenu)) {
        BigDecimal number = null;
        Object data = p_table.getSelectedValue();
        try {
            if (data != null) {
                if (data instanceof BigDecimal)
                    number = (BigDecimal) data;
                else
                    number = new BigDecimal(data.toString());
            }
        } catch (Exception ex) {
        }
        Calculator c = new Calculator(null, number);
        c.setVisible(true);
        return;
    }
    // popup
    // Confirm Panel
    String cmd = e.getActionCommand();
    if (cmd.equals(ConfirmPanel.A_OK)) {
        dispose(true);
    } else if (cmd.equals(ConfirmPanel.A_CANCEL)) {
        m_cancel = true;
        dispose(false);
    } else // 
    if (cmd.equals(ConfirmPanel.A_HISTORY))
        showHistory();
    else if (cmd.equals(ConfirmPanel.A_CUSTOMIZE))
        customize();
    else if (cmd.equals(ConfirmPanel.A_ZOOM))
        zoom();
    else if (cmd.equals(ConfirmPanel.A_RESET))
        doReset();
    else if (cmd.equals(ConfirmPanel.A_PRINT))
        PrintScreenPainter.printScreen(this);
    else // @fchiappano Boton seleccionar todo
    if (cmd.equals(SELECT_DESELECT_ALL)) {
        TableModel model = p_table.getModel();
        int rows = model.getRowCount() - 1;
        Boolean selectAll = selectDeselectAllAction.isPressed() ? Boolean.FALSE : Boolean.TRUE;
        for (int i = 0; i < rows; i++) {
            Object linea = model.getValueAt(i, 0);
            if (linea != null)
                ((IDColumn) linea).setSelected(selectAll);
            else
                rows++;
        }
        p_table.updateUI();
    } else
        // Default
        executeQuery();
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) Calculator(org.compiere.grid.ed.Calculator) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException) TableModel(javax.swing.table.TableModel)

Aggregations

IDColumn (org.compiere.minigrid.IDColumn)79 SQLException (java.sql.SQLException)25 BigDecimal (java.math.BigDecimal)20 PreparedStatement (java.sql.PreparedStatement)20 ResultSet (java.sql.ResultSet)20 ArrayList (java.util.ArrayList)16 KeyNamePair (org.compiere.util.KeyNamePair)13 Timestamp (java.sql.Timestamp)8 Vector (java.util.Vector)5 GridField (org.compiere.model.GridField)5 MBrowseField (org.adempiere.model.MBrowseField)4 ApplicationException (org.adempiere.webui.exception.ApplicationException)4 SimpleDateFormat (java.text.SimpleDateFormat)3 DefaultTableModel (javax.swing.table.DefaultTableModel)3 PO (org.compiere.model.PO)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 DecimalFormat (java.text.DecimalFormat)2 Date (java.util.Date)2 ChangeEvent (javax.swing.event.ChangeEvent)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2