accountEditor = new IntegerField("Account", "transaction", view);
column.setCellEditor(new DefaultCellEditor(accountEditor));
column.setPreferredWidth(accountIntFieldSize);
column.setCellRenderer(numberRenderer);
accountCombo = new DataComboBox(new JdbcTable("APP.Account", 2, view), true, "Account", "transaction", view);
accountCombo.loadComboBox("AccDesc", "Account", (Integer) cc.comboBox.getSelectedItemsKey());
column = tableView.getColumn(dataModel.getColumnName(COL_ACCOUNTNAME));
column.setCellEditor(new DefaultCellEditor(accountCombo));
column.setPreferredWidth(accountNameFieldSize);
column = tableView.getColumn(dataModel.getColumnName(COL_CUSTOMERNUM));
customerEditor = new IntegerField("Customer", "transaction", view);
column.setCellEditor(new DefaultCellEditor(customerEditor));
column.setPreferredWidth(accountIntFieldSize);
column.setCellRenderer(numberRenderer);
customerCombo = new DataComboBox(new JdbcTable(
"SELECT CompId,CustId,CustName FROM Customer2 WHERE CompId=? ORDER BY CustName"
, view, new int[]{Types.INTEGER}), true, "Customer", "transaction", view);
customerCombo.loadComboBox("CustName", "CustId", (Integer) cc.comboBox.getSelectedItemsKey());
column = tableView.getColumn(dataModel.getColumnName(COL_CUSTOMERNAME));
column.setPreferredWidth(accountNameFieldSize);
column.setCellEditor(new DefaultCellEditor(customerCombo));
column = tableView.getColumn(dataModel.getColumnName(COL_DEBIT));
column.setPreferredWidth(accountTotalSize);
debitEditor = new DoubleField("DebitAccountTotal", "transaction", view);
column.setCellEditor(new DefaultCellEditor(debitEditor));
column.setCellRenderer(numberRenderer);
column = tableView.getColumn(dataModel.getColumnName(COL_CREDIT));
column.setPreferredWidth(accountTotalSize);
creditEditor = new DoubleField("CreditAccountTotal", "transaction", view);
column.setCellEditor(new DefaultCellEditor(creditEditor));
column.setCellRenderer(numberRenderer);
tableView.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
tableView.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel colSM =
tableView.getColumnModel().getSelectionModel();
colSM.addListSelectionListener(
new ListSelectionListener() {
//{{{ +valueChanged(ListSelectionEvent) : void
public void valueChanged(ListSelectionEvent e) {
//Ignore extra messages.
//if(true)return;
if (e.getValueIsAdjusting()) {
return;
}
if ((Calendar.getInstance().getTime().getTime() - lastTimeHere) < 100) {
return;
}
lastTimeHere = Calendar.getInstance().getTime().getTime();
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (!lsm.isSelectionEmpty()) {
switch (lsm.getMinSelectionIndex()) {
case COL_TEXT:
textCommentsEditor.showHelp();
break;
case COL_ACCOUNTNUM:
accountEditor.showHelp();
break;
case COL_ACCOUNTNAME:
accountEditor.showHelp();
break;
case COL_CUSTOMERNUM:
customerEditor.showHelp();
break;
case COL_CUSTOMERNAME:
customerEditor.showHelp();
break;
case COL_DEBIT:
debitEditor.showHelp();
break;
case COL_CREDIT:
creditEditor.showHelp();
break;
}
}
}//}}}
});
KeyStroke aKeyStroke = KeyStroke.getKeyStroke("ENTER");
InputMap im = tableView.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
im.remove(aKeyStroke);
im.getParent().remove(aKeyStroke);
tableView.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, im);
im = tableView.getInputMap(JComponent.WHEN_FOCUSED);
im.remove(aKeyStroke);
tableView.setInputMap(JComponent.WHEN_FOCUSED, im);
im = tableView.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.remove(aKeyStroke);
tableView.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, im);
tableView.getInputMap(JComponent.WHEN_FOCUSED).put(aKeyStroke, "eatme");
tableView.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(aKeyStroke, "eatme");
Action anAction =
new Action() {
//{{{ +actionPerformed(ActionEvent) : void
public void actionPerformed(ActionEvent e) {
ListSelectionModel rsm = tableView.getSelectionModel();
ListSelectionModel csm = tableView.getColumnModel().getSelectionModel();
int selectedRow = rsm.getAnchorSelectionIndex();
int selectedColumn = csm.getAnchorSelectionIndex();
Log.log(Log.DEBUG, "actionPerformed", "actionPerformed="
+ selectedRow + ":" + selectedColumn + ":");
switch (selectedColumn) {
case COL_ACCOUNTNUM:
if (SetupInfo.getBoolProperty(SetupInfo.INPUT_TABSTOP_CUSTOMER)) {
tableView.editCellAt(selectedRow, COL_CUSTOMERNUM);
csm.setSelectionInterval(COL_CUSTOMERNUM, COL_CUSTOMERNUM);
} else {
tableView.editCellAt(selectedRow, COL_DEBIT);
csm.setSelectionInterval(COL_DEBIT, COL_DEBIT);
}
if (debitTotal.getDouble().compareTo(
creditTotal.getDouble()) == 0 &&
creditTotal.getDouble().doubleValue() != 0 &&
tableFields[selectedRow][COL_ACCOUNTNUM].length() == 0) {
tableView.editCellAt(selectedRow, COL_ACCOUNTNUM);
csm.setSelectionInterval(COL_ACCOUNTNUM, COL_ACCOUNTNUM);
nextComp = dataMovementPane.butAdd;
dataMovementPane.butAdd.requestFocus();
//tableView.transferFocus();//this doesnt do anything anymore
} else
if (tableFields[selectedRow][COL_ACCOUNTNAME].length() == 0) {
tableView.editCellAt(selectedRow, COL_ACCOUNTNAME);
csm.setSelectionInterval(COL_ACCOUNTNAME, COL_ACCOUNTNAME);
//create a model dialog to get a name to the new account number
JDialog dialog = new JDialog((Frame) GUIUtilities.getView(tableView), true);
AccountForm af = new AccountForm(true, tableFields[selectedRow][COL_ACCOUNTNUM].toString(), dialog, view);
dialog.getContentPane().setLayout(new GridLayout(1, 1));
dialog.getContentPane().add(af);
dialog.pack();
dialog.setLocationRelativeTo(GUIUtilities.getView(tableView));
//This next command will not return untill the dialog dissappears.
dialog.setVisible(true);
if (af.isOk()) {
accountCombo = new DataComboBox(new JdbcTable("APP.Account", 2, view), true, "Account", "transaction", view);
accountCombo.loadComboBox("AccDesc", "Account", (Integer) cc.comboBox.getSelectedItemsKey());
TableColumn column = tableView.getColumn(dataModel.getColumnName(COL_ACCOUNTNAME));
column.setCellEditor(new DefaultCellEditor(accountCombo));
AccountNumberChanged(af.accountNum(), selectedRow, COL_ACCOUNTNUM);
dataModel.fireTableCellUpdated(selectedRow, COL_ACCOUNTNUM);
if (SetupInfo.getBoolProperty(SetupInfo.INPUT_TABSTOP_CUSTOMER)) {
tableView.editCellAt(selectedRow, COL_CUSTOMERNUM);
csm.setSelectionInterval(COL_CUSTOMERNUM, COL_CUSTOMERNUM);
} else {
tableView.editCellAt(selectedRow, COL_DEBIT);
csm.setSelectionInterval(COL_DEBIT, COL_DEBIT);
}
} else {
accountCombo.showPopup();
}
}
break;
case COL_CUSTOMERNUM:
tableView.editCellAt(selectedRow, COL_DEBIT);
csm.setSelectionInterval(COL_DEBIT, COL_DEBIT);
if (tableFields[selectedRow][COL_CUSTOMERNAME].length() == 0) {
tableView.editCellAt(selectedRow, COL_CUSTOMERNAME);
csm.setSelectionInterval(COL_CUSTOMERNAME, COL_CUSTOMERNAME);
//create a model dialog to get a name to the new customer number
JDialog dialog = new JDialog((Frame) GUIUtilities.getView(tableView), true);
CustomerForm cf = new CustomerForm(true, tableFields[selectedRow][COL_CUSTOMERNUM].toString(), dialog, view);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add(BorderLayout.CENTER, cf);
dialog.pack();
dialog.setLocationRelativeTo(GUIUtilities.getView(tableView));
//This next command will not return untill the dialog dissappears.
dialog.setVisible(true);
if (cf.isOk()) {
customerCombo = new DataComboBox(new JdbcTable(
"SELECT CompId,CustId,CustName FROM Customer2 WHERE CompId=? ORDER BY CustName"
, view, new int[]{Types.INTEGER}), true, "Customer", "transaction", view);
customerCombo.loadComboBox("CustName", "CustId", (Integer) cc.comboBox.getSelectedItemsKey());
TableColumn column = tableView.getColumn(dataModel.getColumnName(COL_CUSTOMERNAME));
column.setCellEditor(new DefaultCellEditor(customerCombo));