r3183 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch
Author: vsalaun Date: 2011-06-17 17:23:41 +0200 (Fri, 17 Jun 2011) New Revision: 3183 Url: http://chorem.org/repositories/revision/lima/3183 Log: correct the selection on the right row while updating datas (FinancialTransactionSearch) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-06-17 14:59:28 UTC (rev 3182) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-06-17 15:23:41 UTC (rev 3183) @@ -195,22 +195,22 @@ && e.getModifiers() == KeyEvent.CTRL_MASK)) { handler.addEmptyEntry(); } + + // paste : ctrl + c - // add financial transaction with the key combination : ctrl + tab + // add financial transaction with the key combination : ctrl + c if (e.getKeyCode() == KeyEvent.VK_C && e.getModifiers() == KeyEvent.CTRL_MASK) { handler.copyRow(); } - // copy : ctrl + c + // copy : ctrl + v - // add financial transaction with the key combination : ctrl + tab + // add financial transaction with the key combination : ctrl + v if (e.getKeyCode() == KeyEvent.VK_V && e.getModifiers() == KeyEvent.CTRL_MASK) { handler.pasteRow(); } - - // paste : ctrl + v // add financial transaction with the key combination : ctrl + tab if (e.getKeyCode() == KeyEvent.VK_TAB Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-06-17 14:59:28 UTC (rev 3182) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-06-17 15:23:41 UTC (rev 3183) @@ -358,10 +358,13 @@ } + /** - * @throws LimaException + * + * @return int: indexOf new FianancialTransaction + * @throws LimaException */ - public void addFinancialTransaction() throws LimaException{ + public int addFinancialTransaction() throws LimaException{ /* Calling transaction service */ FinancialTransaction financialTransaction = new FinancialTransactionImpl(); financialTransaction.setAmountDebit(BigDecimal.ZERO); @@ -405,12 +408,14 @@ // set date to the financial transaction financialTransaction.setTransactionDate(transactionDate); // create it - financialTransactionService.createFinancialTransaction(financialTransaction); + FinancialTransaction fTransaction = + financialTransactionService.createFinancialTransaction(financialTransaction); //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); - int row = getDataList(financialTransactionSearch).indexOf(financialTransaction); + int row = cacheDataList.indexOf(fTransaction); fireTableRowsInserted(row, row); + return row; //fireTableDataChanged(); } else { @@ -418,11 +423,14 @@ } } - /** - * @throws LimaException + * + * @param value + * @param row + * @return int: indexOf new FianancialTransaction + * @throws LimaException */ - public void addEmptyEntry(Object value, int row) throws LimaException { + public int addEmptyEntry(Object value, int row) throws LimaException { FinancialTransaction currentTransaction = null; Object currentRow = cacheDataList.get(row); Entry entry = new EntryImpl(); @@ -438,10 +446,12 @@ } //create it entry.setFinancialTransaction(currentTransaction); - financialTransactionService.createEntry(entry); + Entry newEntry = financialTransactionService.createEntry(entry); //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); - fireTableDataChanged(); + int newrow = cacheDataList.indexOf(newEntry); + fireTableRowsInserted(newrow, newrow); + return newrow; } /** @@ -549,11 +559,15 @@ fireTableDataChanged(); } - /** - * @throws LimaException + * + * @param value + * @param description + * @param row + * @return int: indexOf new FianancialTransaction + * @throws LimaException */ - public void addEmptyEntry(Object value, String description, int row) throws LimaException { + public int addEmptyEntry(Object value, String description, int row) throws LimaException { FinancialTransaction currentTransaction = null; Object currentRow = cacheDataList.get(row); Entry entry = new EntryImpl(); @@ -572,14 +586,16 @@ } //create it entry.setFinancialTransaction(currentTransaction); - financialTransactionService.createEntry(entry); + Entry newEntry = financialTransactionService.createEntry(entry); //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); - fireTableDataChanged(); + int newrow = cacheDataList.indexOf(newEntry); + fireTableRowsInserted(newrow, newrow); + return newrow; } - public void addEntry(Object value, Entry entry, int row) throws LimaException { + public int addEntry(Object value, Entry entry, int row) throws LimaException { FinancialTransaction currentTransaction = null; int financialTransactionRow = 0; Object currentRow = cacheDataList.get(row); @@ -601,12 +617,14 @@ } //create it entry.setFinancialTransaction(currentTransaction); - financialTransactionService.createEntry(entry); + Entry newEntry = financialTransactionService.createEntry(entry); fireTableRowsUpdated(financialTransactionRow, getRowCount()-1); //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); - fireTableDataChanged(); + int newrow = cacheDataList.indexOf(newEntry); + fireTableRowsInserted(newrow, newrow); + return newrow; } @Override Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-06-17 14:59:28 UTC (rev 3182) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-06-17 15:23:41 UTC (rev 3183) @@ -246,14 +246,14 @@ try { //copy + paste the description String description = (String) tableModel.getValueAt(indexSelectedRow, 4); - tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow); + int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow); //select the new line ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval( indexSelectedRow+1, indexSelectedRow+1); //focus on second column - table.changeSelection(indexSelectedRow+1, 1, false, false); + table.changeSelection(index, 1, false, false); table.requestFocusInWindow(); } catch (LimaException eee){ if (log.isErrorEnabled()) { @@ -289,14 +289,14 @@ Object selectedValue = tableModel.getElementAt(indexSelectedRow); if (clipBoard instanceof Entry) { try { - tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow); + int index = tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow); //select the new line ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval( indexSelectedRow+1, indexSelectedRow+1); //focus on second column - table.changeSelection(indexSelectedRow+1, 1, false, false); + table.changeSelection(index, 1, false, false); table.requestFocusInWindow(); } catch (LimaException eee){ if (log.isErrorEnabled()) { @@ -317,14 +317,14 @@ tableModel = view.getFinancialTransactionSearchTableModel(); try { - tableModel.addFinancialTransaction(); + int index = tableModel.addFinancialTransaction(); //select the new line int numberRow = table.getRowCount(); ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval(numberRow-1, numberRow-1); //focus on first column - table.changeSelection(numberRow-1, 0, false, false); + table.changeSelection(index, 0, false, false); table.requestFocusInWindow(); } catch (LimaException eee) { if (log.isErrorEnabled()) {
participants (1)
-
vsalaun@users.chorem.org