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);
}
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;
}
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;
}
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);
}
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();
}
Aggregations