use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class VPayPrint method cmd_export.
// loadPaymentRuleInfo
/**************************************************************************
* Export payments to file
*/
private void cmd_export() {
ValueNamePair pp = (ValueNamePair) fPaymentRule.getSelectedItem();
if (pp == null)
return;
String paymentRule = pp.getValue();
log.info(paymentRule);
if (!getChecks(paymentRule))
return;
// Get File Info
JFileChooser fc = new JFileChooser();
fc.setDialogTitle(Msg.getMsg(Env.getCtx(), "Export"));
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
fc.setSelectedFile(new java.io.File("paymentExport.txt"));
if (fc.showSaveDialog(panel) != JFileChooser.APPROVE_OPTION)
return;
// Create File
int no = 0;
StringBuffer error = new StringBuffer("");
if (paymentExportClass == null || paymentExportClass.trim().length() == 0) {
paymentExportClass = "org.compiere.util.GenericPaymentExport";
}
try {
Class<?> clazz = Class.forName(paymentExportClass);
if (clazz.isInstance(PaymentExportList.class)) {
PaymentExportList custom = (PaymentExportList) clazz.newInstance();
no = custom.exportToFile(paySelectionChecks, fc.getSelectedFile(), error);
} else if (clazz.isInstance(PaymentExport.class)) {
PaymentExport custom = (PaymentExport) clazz.newInstance();
no = custom.exportToFile(paySelectionChecks.toArray(new MPaySelectionCheck[paySelectionChecks.size()]), fc.getSelectedFile(), error);
}
} catch (ClassNotFoundException e) {
no = -1;
error.append("No custom PaymentExport class " + paymentExportClass + " - " + e.toString());
log.log(Level.SEVERE, error.toString(), e);
} catch (Exception e) {
no = -1;
error.append("Error in " + paymentExportClass + " check log, " + e.toString());
log.log(Level.SEVERE, error.toString(), e);
}
if (no >= 0) {
ADialog.info(windowNo, panel, "Saved", fc.getSelectedFile().getAbsolutePath() + "\n" + Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
if (ADialog.ask(windowNo, panel, "VPayPrintSuccess?")) {
// int lastDocumentNo =
MPaySelectionCheck.confirmPrint(paySelectionChecks, paymentBatch);
// document No not updated
}
} else {
ADialog.error(windowNo, panel, "Error", error.toString());
}
dispose();
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class VPaySelect method loadTableInfo.
// loadBankInfo
/**
* Query and create TableInfo
*/
private void loadTableInfo() {
Timestamp payDate = (Timestamp) fieldPayDate.getValue();
miniTable.setColorCompare(payDate);
log.config("PayDate=" + payDate);
BankInfo bi = (BankInfo) fieldBankAccount.getSelectedItem();
ValueNamePair paymentRule = (ValueNamePair) fieldPaymentRule.getSelectedItem();
KeyNamePair docType = (KeyNamePair) fieldDtype.getSelectedItem();
int c_bpartner_id = 0;
if (fieldBPartner.getValue() != null)
c_bpartner_id = ((Integer) fieldBPartner.getValue()).intValue();
loadTableInfo(bi, payDate, paymentRule, onlyDue.isSelected(), c_bpartner_id, docType, miniTable);
calculateSelection();
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class FolderBrowser method onEvent.
public void onEvent(Event e) throws Exception {
if (e.getName() == Events.ON_DOUBLE_CLICK && e.getTarget() instanceof ListItem) {
int index = listDir.getSelectedIndex();
ValueNamePair vnp = listDir.getItemAtIndex(index).toValueNamePair();
getFileListing(vnp.getValue());
}
if (e.getTarget() == confirmPanel.getButton(ConfirmPanel.A_OK)) {
path = txtPath.getValue();
if (path != null) {
File file = new File(path);
if (showDirOnly) {
if (!file.isDirectory() || !file.exists()) {
FDialog.error(0, "Invalid directory");
return;
}
} else {
if (!file.isFile() || !file.exists()) {
FDialog.error(0, "Invalid file");
return;
}
}
path = file.getAbsolutePath();
}
dispose();
} else if (e.getTarget() == confirmPanel.getButton(ConfirmPanel.A_CANCEL)) {
path = null;
dispose();
}
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class FindWindow method addOperators.
// addOperators
/**
* add Operators
* @param op array of operators
**/
private void addOperators(ValueNamePair[] op, Listbox listOperator) {
List<?> itemList = listOperator.getChildren();
itemList.clear();
for (ValueNamePair item : op) {
listOperator.appendItem(item.getName(), item.getValue());
}
listOperator.setSelectedIndex(0);
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class FindWindow method createFields.
/**
* create respective fields in the advanced window tab
*
**/
private void createFields(String[] fields, int row) {
ListItem listItem = new ListItem();
listItem.setWidth("100%");
Listbox listColumn = new Listbox();
listColumn.setId("listColumn" + listItem.getId());
listColumn.setName("listColumn");
listColumn.setMold("select");
listColumn.setRows(0);
listColumn.addEventListener(Events.ON_SELECT, this);
Listbox listOperator = new Listbox();
listOperator.setId("listOperator" + listItem.getId());
listOperator.setName("listOperator");
listOperator.setMold("select");
listOperator.setRows(0);
listOperator.addEventListener(Events.ON_SELECT, this);
Listbox listAndOr = new Listbox();
listAndOr.setId("listAndOr" + listItem.getId());
listAndOr.setName("listAndOr");
listAndOr.setMold("select");
listAndOr.setRows(0);
listAndOr.addEventListener(Events.ON_SELECT, this);
Listbox listLeftBracket = new Listbox();
listLeftBracket.setId("listLeftBracket" + listItem.getId());
listLeftBracket.setName("listLeftBracket");
listLeftBracket.setMold("select");
listLeftBracket.setRows(0);
listLeftBracket.addEventListener(Events.ON_SELECT, this);
Listbox listRightBracket = new Listbox();
listRightBracket.setId("listRightBracket" + listItem.getId());
listRightBracket.setName("listRightBracket");
listRightBracket.setMold("select");
listRightBracket.setRows(0);
listRightBracket.addEventListener(Events.ON_SELECT, this);
setValues(listColumn, listOperator, fields);
// And Or
ValueNamePair[] andOr = new ValueNamePair[] { new ValueNamePair("", ""), new ValueNamePair("AND", Msg.getMsg(Env.getCtx(), "AND")), new ValueNamePair("OR", Msg.getMsg(Env.getCtx(), "OR")) };
for (ValueNamePair item : andOr) listAndOr.appendItem(item.getName(), item.getValue());
if (row <= 0) {
// don't show item on the first row.
listAndOr.setSelectedIndex(0);
listAndOr.setVisible(false);
} else {
//And - default
listAndOr.setSelectedIndex(1);
listAndOr.setVisible(true);
}
// Left Bracket
ValueNamePair[] leftBracket = new ValueNamePair[] { new ValueNamePair("", ""), new ValueNamePair("(", "("), new ValueNamePair("((", "(("), new ValueNamePair("(((", "(((") };
for (ValueNamePair item : leftBracket) listLeftBracket.appendItem(item.getName(), item.getValue());
listLeftBracket.setSelectedIndex(0);
// Right Bracket
ValueNamePair[] rightBracket = new ValueNamePair[] { new ValueNamePair("", ""), new ValueNamePair(")", ")"), new ValueNamePair("))", "))"), new ValueNamePair(")))", ")))") };
for (ValueNamePair item : rightBracket) listRightBracket.appendItem(item.getName(), item.getValue());
listRightBracket.setSelectedIndex(0);
ListCell cellColumn = new ListCell();
cellColumn.appendChild(listColumn);
cellColumn.setId("cellColumn" + listItem.getId());
ListCell cellOperator = new ListCell();
cellOperator.appendChild(listOperator);
cellOperator.setId("cellOperator" + listItem.getId());
ListCell cellQueryFrom = new ListCell();
cellQueryFrom.setId("cellQueryFrom" + listItem.getId());
ListCell cellQueryTo = new ListCell();
cellQueryTo.setId("cellQueryTo" + listItem.getId());
ListCell cellAndOr = new ListCell();
cellAndOr.appendChild(listAndOr);
cellAndOr.setId("cellAndOr" + listItem.getId());
ListCell cellLeftBracket = new ListCell();
cellLeftBracket.appendChild(listLeftBracket);
cellLeftBracket.setId("cellLeftBracket" + listItem.getId());
ListCell cellRightBracket = new ListCell();
cellRightBracket.appendChild(listRightBracket);
cellRightBracket.setId("cellRightBracket" + listItem.getId());
listItem.appendChild(cellAndOr);
listItem.appendChild(cellLeftBracket);
listItem.appendChild(cellColumn);
listItem.appendChild(cellOperator);
listItem.appendChild(cellQueryFrom);
listItem.appendChild(cellQueryTo);
listItem.appendChild(cellRightBracket);
advancedPanel.appendChild(listItem);
advancedPanel.setSelectedItem(listItem);
if (fields != null) {
// QueryFrom
String columnName = listColumn.getSelectedItem().getValue().toString();
if (columnName == null || columnName == "")
return;
String value = fields.length > INDEX_VALUE ? fields[INDEX_VALUE] : "";
if (value.length() > 0) {
// Elaine 2009/03/16 - set attribute value
cellQueryFrom.setAttribute("value", value);
cellQueryFrom.appendChild(parseString(getTargetMField(columnName), value, listItem, false));
}
// QueryTo
String value2 = fields.length > INDEX_VALUE2 ? fields[INDEX_VALUE2] : "";
if (value2.length() > 0) {
// Elaine 2009/03/16 - set attribute value
cellQueryTo.setAttribute("value", value);
cellQueryTo.appendChild(parseString(getTargetMField(columnName), value2, listItem, true));
}
// AndOr
String sandOr = fields.length > INDEX_ANDOR ? fields[INDEX_ANDOR] : "";
if (sandOr.length() > 0) {
for (int i = 0; i < listAndOr.getItems().size(); i++) {
if (listAndOr.getItemAtIndex(i).getValue().equals(sandOr)) {
listAndOr.setSelectedIndex(i);
break;
}
}
}
// Left Bracket
String sLeftBracket = fields.length > INDEX_LEFTBRACKET ? fields[INDEX_LEFTBRACKET] : "";
if (sLeftBracket.length() > 0) {
for (int i = 0; i < listLeftBracket.getItems().size(); i++) {
if (listLeftBracket.getItemAtIndex(i).getValue().equals(sLeftBracket)) {
listLeftBracket.setSelectedIndex(i);
break;
}
}
}
// Right Bracket
String sRightBracket = fields.length > INDEX_RIGHTBRACKET ? fields[INDEX_RIGHTBRACKET] : "";
if (sRightBracket.length() > 0) {
for (int i = 0; i < listRightBracket.getItems().size(); i++) {
if (listRightBracket.getItemAtIndex(i).getValue().equals(sRightBracket)) {
listRightBracket.setSelectedIndex(i);
break;
}
}
}
}
}
Aggregations