use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class Find method actionPerformed.
// dispose
/**************************************************************************
* Action Listener
* @param e ActionEvent
*/
public void actionPerformed(ActionEvent e) {
log.info(e.getActionCommand());
//
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
cmd_cancel();
else if (e.getActionCommand().equals(ConfirmPanel.A_REFRESH))
cmd_refresh();
else //
if (e.getActionCommand().equals(ConfirmPanel.A_NEW)) {
m_query = MQuery.getNoRecordQuery(m_tableName, true);
m_total = 0;
dispose();
} else //
if (e.getSource() == bIgnore)
cmd_ignore();
else if (e.getSource() == bNew)
cmd_new();
else if (e.getSource() == bSave)
cmd_save(true);
else if (e.getSource() == bDelete)
cmd_delete();
else //
if (e.getSource() == columns) {
String columnName = null;
Object selected = columns.getSelectedItem();
if (selected != null) {
if (selected instanceof ValueNamePair) {
ValueNamePair column = (ValueNamePair) selected;
columnName = column.getValue();
} else {
columnName = selected.toString();
}
}
if (columnName != null) {
log.config("Column: " + columnName);
if (columnName.endsWith("_ID") || columnName.endsWith("_Acct"))
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS_ID));
else if (columnName.startsWith("Is"))
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS_YN));
else
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS));
}
} else if (e.getSource() == fQueryName) {
// fQueryName has changed.
int index = fQueryName.getSelectedIndex();
if (index < 0) {
if (fQueryName.getSelectedItem() == null || fQueryName.getSelectedItem().equals(m_sTipText)) {
return;
}
} else if (index == 0) {
// no query - wipe and start over.
advancedTable.stopEditor(false);
DefaultTableModel model = (DefaultTableModel) advancedTable.getModel();
int cnt = model.getRowCount();
if (cnt > 0) {
for (int i = cnt - 1; i >= 0; i--) {
model.removeRow(i);
}
// No row - create one.
cmd_new();
}
fQueryName.setSelectedIndex(-1);
fQueryName.setSelectedItem(m_sTipText);
advancedTable.requestFocusInWindow();
} else
parseUserQuery(userQueries[index - 1]);
} else // ConfirmPanel.A_OK and enter in fields
{
if (e.getSource() == confirmPanelA.getOKButton())
cmd_ok_Advanced();
else if (e.getSource() == confirmPanelS.getOKButton())
cmd_ok_Simple();
else if (e.getSource() instanceof JTextField && tabbedPane.getSelectedIndex() == 0)
cmd_ok_Simple();
}
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class FindValueEditor method getTableCellEditorComponent.
// getCellEditorValue
/**
* Get Editor
*
* @param table Table
* @param value Value
* @param isSelected cell is selected
* @param row row
* @param col column
* @return Editor component
*/
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) {
// log.config( "FindValueEditor.getTableCellEditorComponent", "r=" + row + ", c=" + col);
// Between - enables valueToColumn
m_between = false;
Object betweenValue = table.getModel().getValueAt(row, Find.INDEX_OPERATOR);
if (m_valueToColumn && betweenValue != null && betweenValue.equals(MQuery.OPERATORS[MQuery.BETWEEN_INDEX]))
m_between = true;
boolean enabled = !m_valueToColumn || (m_valueToColumn && m_between);
log.config("(" + value + ") - Enabled=" + enabled);
if (enabled) {
String columnName = null;
Object column = table.getModel().getValueAt(row, Find.INDEX_COLUMNNAME);
if (column != null)
columnName = ((ValueNamePair) column).getValue();
// Create Editor
GridField field = m_find.getTargetMField(columnName);
// log.fine( "Field=" + field.toStringX());
if (field.isKey())
m_editor = new VNumber(columnName, false, false, true, DisplayType.Integer, columnName);
else
m_editor = VEditorFactory.getEditor(field, true);
if (m_editor == null)
m_editor = new VString();
m_editor.setValue(value);
m_editor.setReadWrite(enabled);
m_editor.setBorder(null);
} else {
m_editor = null;
}
//
return (Component) m_editor;
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class FindValueRenderer method getTableCellRendererComponent.
// getCheck
/*************************************************************************
* Get TableCell RendererComponent
* @param table table
* @param value value
* @param isSelected selected
* @param hasFocus focus
* @param row row
* @param col col
* @return renderer component (Label or CheckBox)
*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
// log.config( "FindValueRenderer.getTableCellRendererComponent", "r=" + row + ", c=" + col );
// Column
m_columnName = null;
Object column = table.getModel().getValueAt(row, Find.INDEX_COLUMNNAME);
if (column != null) {
if (column instanceof ValueNamePair)
m_columnName = ((ValueNamePair) column).getValue();
else
m_columnName = column.toString();
}
// Between - enables valueToColumn
m_between = false;
Object betweenValue = table.getModel().getValueAt(row, Find.INDEX_OPERATOR);
if (m_valueToColumn && betweenValue != null && betweenValue.equals(MQuery.OPERATORS[MQuery.BETWEEN_INDEX]))
m_between = true;
boolean enabled = !m_valueToColumn || (m_valueToColumn && m_between);
// set Background
if (enabled)
setBackground(AdempierePLAF.getFieldBackground_Normal());
else
setBackground(AdempierePLAF.getFieldBackground_Inactive());
// log.config( "FindValueRenderer.getTableCellRendererComponent - (" + value + ") - Enabled=" + enabled);
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
if (value == null || (m_valueToColumn && !m_between))
return c;
//
GridField field = getMField();
if (field != null && field.getDisplayType() == DisplayType.YesNo) {
JCheckBox cb = getCheck();
if (value instanceof Boolean)
cb.setSelected(((Boolean) value).booleanValue());
else
cb.setSelected(value.toString().indexOf('Y') != -1);
return cb;
}
return c;
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class VPayPrint method cmd_print.
// cmd_EFT
/**
* Print Checks and/or Remittance
*/
private void cmd_print() {
ValueNamePair valueNamePair = (ValueNamePair) fPaymentRule.getSelectedItem();
if (valueNamePair == null)
return;
String paymentRule = valueNamePair.getValue();
log.info(paymentRule);
if (!getChecks(paymentRule))
return;
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
AtomicBoolean somethingPrinted = new AtomicBoolean(false);
boolean directPrint = !Ini.isPropertyBool(Ini.P_PRINTPREVIEW);
// for all checks
paySelectionChecks.stream().filter(paySelectionCheck -> paySelectionCheck != null).forEach(paySelectionCheck -> {
boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, paySelectionCheck.get_ID(), null, Env.getWindowNo(panel), directPrint);
if (!somethingPrinted.get() && ok)
somethingPrinted.set(true);
});
// Confirm Print and Update BankAccountDoc
if (somethingPrinted.get() && ADialog.ask(windowNo, panel, "VPayPrintSuccess?")) {
int lastDocumentNo = MPaySelectionCheck.confirmPrint(paySelectionChecks, paymentBatch);
if (lastDocumentNo != 0) {
StringBuffer sb = new StringBuffer();
sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(++lastDocumentNo).append(" WHERE C_BankAccount_ID=").append(bankAccountId).append(" AND PaymentRule='").append(paymentRule).append("'");
DB.executeUpdate(sb.toString(), null);
}
}
if (ADialog.ask(windowNo, panel, "VPayPrintPrintRemittance")) {
paySelectionChecks.stream().filter(paySelectionCheck -> paySelectionCheck != null).forEach(paySelectionCheck -> {
ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, paySelectionCheck.get_ID(), null, Env.getWindowNo(panel), directPrint);
});
}
// remittance
panel.setCursor(Cursor.getDefaultCursor());
dispose();
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class VPaySelect method loadBankInfo.
// dynInit
/**
* Load Bank Info - Load Info from Bank Account and valid Documents (PaymentRule)
*/
private void loadBankInfo() {
// Prevent event processing
m_loadedOK = false;
log.fine("");
BankInfo bi = (BankInfo) fieldBankAccount.getSelectedItem();
if (bi == null)
return;
labelCurrency.setText(bi.Currency);
labelBalance.setText(m_format.format(bi.Balance));
// PaymentRule
fieldPaymentRule.removeAllItems();
ArrayList<ValueNamePair> paymentRuleData = getPaymentRuleData(bi);
for (ValueNamePair vp : paymentRuleData) fieldPaymentRule.addItem(vp);
fieldPaymentRule.setSelectedIndex(0);
// Enable event processing
m_loadedOK = true;
}
Aggregations