Search in sources :

Example 1 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class PreviewPanel method setLFSelection.

/**
	 *  Update the look list and theme list to show the current selection
	 */
private void setLFSelection() {
    m_setting = true;
    //  Search for PLAF
    ValueNamePair plaf = null;
    LookAndFeel lookFeel = UIManager.getLookAndFeel();
    String look = lookFeel.getClass().getName();
    for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) {
        ValueNamePair vp = AdempierePLAF.getPLAFs()[i];
        if (vp.getValue().equals(look)) {
            plaf = vp;
            break;
        }
    }
    if (plaf != null)
        lookList.setSelectedValue(plaf, true);
    //  Search for Theme
    MetalTheme metalTheme = null;
    ValueNamePair theme = null;
    boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
    themeList.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes()));
    if (metal) {
        theme = null;
        AppContext context = AppContext.getAppContext();
        metalTheme = (MetalTheme) context.get("currentMetalTheme");
        if (metalTheme != null) {
            String lookTheme = metalTheme.getName();
            for (int i = 0; i < AdempierePLAF.getThemes().length; i++) {
                ValueNamePair vp = AdempierePLAF.getThemes()[i];
                if (vp.getName().equals(lookTheme)) {
                    theme = vp;
                    break;
                }
            }
        }
        if (theme != null)
            themeList.setSelectedValue(theme, true);
    }
    m_setting = false;
    log.info(lookFeel + " - " + metalTheme);
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) AppContext(sun.awt.AppContext) ValueNamePair(org.compiere.util.ValueNamePair) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 2 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class MClickCount method getCount.

//	getMClicks
/**
	 * 	Get Count for date format
	 *	@param DateFormat valid TRUNC date format
	 *	@return count
	 */
protected ValueNamePair[] getCount(String DateFormat) {
    ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
    String sql = "SELECT TRUNC(Created, '" + DateFormat + "'), Count(*) " + "FROM W_Click " + "WHERE W_ClickCount_ID=? " + "GROUP BY TRUNC(Created, '" + DateFormat + "')";
    //
    PreparedStatement pstmt = null;
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, getW_ClickCount_ID());
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            String value = m_dateFormat.format(rs.getTimestamp(1));
            String name = m_intFormat.format(rs.getInt(2));
            ValueNamePair pp = new ValueNamePair(value, name);
            list.add(pp);
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (SQLException ex) {
        log.log(Level.SEVERE, sql, ex);
    }
    try {
        if (pstmt != null)
            pstmt.close();
    } catch (SQLException ex1) {
    }
    pstmt = null;
    //
    ValueNamePair[] retValue = new ValueNamePair[list.size()];
    list.toArray(retValue);
    return retValue;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 3 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class PayPrint method loadPaymentRule.

//  loadPaySelectInfo
/**
	 *  Bank changed - load PaymentRule
	 */
public ArrayList<ValueNamePair> loadPaymentRule(int paySelectionId) {
    ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
    // load PaymentRule for Bank
    //  MLookupInfo.getAD_Reference_ID("All_Payment Rule");
    int AD_Reference_ID = 195;
    Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
    MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
    String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY")) + " AND " + info.KeyColumn + " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) " + info.Query.substring(info.Query.indexOf(" ORDER BY"));
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, paySelectionId);
        ResultSet rs = pstmt.executeQuery();
        //
        while (rs.next()) {
            ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
            data.add(pp);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    if (data.size() == 0)
        log.config("PaySel=" + paySelectionId + ", BAcct=" + bankAccountId + " - " + sql);
    return data;
}
Also used : MLookupInfo(org.compiere.model.MLookupInfo) Language(org.compiere.util.Language) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 4 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class WHRPayPrint method loadPaymentRuleInfo.

//  loadPaymentRule
/**
	 *  PaymentRule changed - load DocumentNo, NoPayments,
	 *  enable/disable EFT, Print
	 */
private void loadPaymentRuleInfo() {
    if (fPaymentRule.getSelectedItem() == null)
        return;
    ValueNamePair pp = fPaymentRule.getSelectedItem().toValueNamePair();
    if (pp == null)
        return;
    String PaymentRule = pp.getValue();
    log.info("PaymentRule=" + PaymentRule);
    fNoPayments.setText(" ");
    int HR_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
    String msg = loadPaymentRuleInfo(HR_PaySelection_ID, PaymentRule);
    if (noPayments != null)
        fNoPayments.setText(noPayments);
    bProcess.setEnabled(PaymentRule.equals("T"));
    if (documentNo != null)
        fDocumentNo.setValue(documentNo);
    if (documentNo != null) {
        MHRPaySelection hrps = new MHRPaySelection(Env.getCtx(), HR_PaySelection_ID, null);
        if (hrps.get_ValueAsInt("CheckNo") > 0)
            fDocumentNo.setValue(hrps.get_ValueAsInt("CheckNo"));
        else
            fDocumentNo.setValue(documentNo);
    }
    if (msg != null && msg.length() > 0)
        FDialog.error(m_WindowNo, form, msg);
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) HRPayPrint(org.eevolution.service.HRPayPrint) MHRPaySelection(org.eevolution.model.MHRPaySelection)

Example 5 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class WHRPayPrint method loadPaymentRule.

//  loadPaySelectInfo
/**
	 *  Bank changed - load PaymentRule
	 */
private void loadPaymentRule() {
    log.info("");
    if (m_C_BankAccount_ID == -1)
        return;
    fPaymentRule.removeAllItems();
    // load PaymentRule for Bank
    int HR_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
    ArrayList<ValueNamePair> data = loadPaymentRule(HR_PaySelection_ID);
    for (ValueNamePair pp : data) fPaymentRule.addItem(pp);
    if (fPaymentRule.getItemCount() > 0)
        fPaymentRule.setSelectedIndex(0);
    loadPaymentRuleInfo();
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) HRPayPrint(org.eevolution.service.HRPayPrint)

Aggregations

ValueNamePair (org.compiere.util.ValueNamePair)118 KeyNamePair (org.compiere.util.KeyNamePair)36 SQLException (java.sql.SQLException)25 ArrayList (java.util.ArrayList)23 PreparedStatement (java.sql.PreparedStatement)22 ResultSet (java.sql.ResultSet)21 GridField (org.compiere.model.GridField)11 Timestamp (java.sql.Timestamp)9 MLookup (org.compiere.model.MLookup)8 BigDecimal (java.math.BigDecimal)7 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)7 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)5 MetalTheme (javax.swing.plaf.metal.MetalTheme)5 DefaultTableModel (javax.swing.table.DefaultTableModel)5 MInvoice (org.compiere.model.MInvoice)5 MLookupInfo (org.compiere.model.MLookupInfo)5 HRPayPrint (org.eevolution.service.HRPayPrint)5 PropertyVetoException (java.beans.PropertyVetoException)4 ListItem (org.adempiere.webui.component.ListItem)4 CComboBox (org.compiere.swing.CComboBox)4