r3394 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction
Author: echatellier Date: 2012-04-25 12:18:26 +0200 (Wed, 25 Apr 2012) New Revision: 3394 Url: http://chorem.org/repositories/revision/lima/3394 Log: Corrections dans la saisie des transactions (maj de l'ui) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-04-25 10:04:03 UTC (rev 3393) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-04-25 10:18:26 UTC (rev 3394) @@ -51,7 +51,6 @@ import java.math.BigDecimal; import java.util.Date; - /** * Table des transaction qui ajoute des comportement (keys). * @@ -113,9 +112,6 @@ addHighlighter(colorTransaction); // highlight unbalanced financial transactions -// if (colorBalance != null) { -// removeHighlighter(colorBalance); -// } predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-04-25 10:04:03 UTC (rev 3393) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-04-25 10:18:26 UTC (rev 3394) @@ -300,9 +300,10 @@ try { Object currentRow = transactionAndEntries.get(row); - + + FinancialTransaction currentFinancialTransaction = null; if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentFinancialTransaction = (FinancialTransaction) currentRow; + currentFinancialTransaction = (FinancialTransaction) currentRow; switch (column) { case 0: //update @@ -323,8 +324,7 @@ } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry) currentRow; - FinancialTransaction financialTransaction = - currentEntry.getFinancialTransaction(); + currentFinancialTransaction = currentEntry.getFinancialTransaction(); boolean updateTransaction = false; switch (column) { case 2: @@ -336,7 +336,7 @@ // let's update the voucher of all entries of // the transaction - for (Entry entry : financialTransaction.getEntry()) { + for (Entry entry : currentFinancialTransaction.getEntry()) { entry.setVoucher(voucher); } updateTransaction = true; @@ -356,7 +356,7 @@ // let's update the description of all entries of // the transaction - for (Entry entry : financialTransaction.getEntry()) { + for (Entry entry : currentFinancialTransaction.getEntry()) { entry.setDescription(description1); } updateTransaction = true; @@ -373,7 +373,7 @@ // let's update the description of all entries of // the transaction - for (Entry entry : financialTransaction.getEntry()) { + for (Entry entry : currentFinancialTransaction.getEntry()) { entry.setDescription(description); } updateTransaction = true; @@ -400,7 +400,7 @@ // first row modification update following rows if (updateTransaction) { // FIXME echatellier 20120413 make a single service call - for (Entry entry : financialTransaction.getEntry()) { + for (Entry entry : currentFinancialTransaction.getEntry()) { financialTransactionService.updateEntry(entry); } } else { @@ -410,7 +410,8 @@ // FIXME echatellier 20120413 une modification des dates fait que l'ordre // devient faux - fireTableRowsUpdated(row, row); + int trIndex = indexOf(currentFinancialTransaction); + fireTableRowsUpdated(trIndex, trIndex + currentFinancialTransaction.getEntry().size() - 1); } catch (LimaException ex) { throw new LimaRuntimeException("Can't propagate data modification to service", ex); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-04-25 10:04:03 UTC (rev 3393) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-04-25 10:18:26 UTC (rev 3394) @@ -360,18 +360,18 @@ int firstentryBookrow = tableModel.getFirstEntry(indexSelectedRow); String defaultVoucher = null; - String dafaultDescription = null; + String defaultDescription = null; if (firstentryBookrow != -1) { // there is no first entry, grab the voucher and defaultVoucher = (String) tableModel.getValueAt(firstentryBookrow, 2); - dafaultDescription = (String) tableModel.getValueAt(firstentryBookrow, 4); + defaultDescription = (String) tableModel.getValueAt(firstentryBookrow, 4); } try { // creates the new entry Entry entry = new EntryImpl(); entry.setVoucher(defaultVoucher); - entry.setDescription(dafaultDescription); + entry.setDescription(defaultDescription); // check if current row is a transaction or an entry FinancialTransaction currentTransaction = null; Object currentRow = tableModel.getElementAt(indexSelectedRow); @@ -388,13 +388,15 @@ currentTransaction.addEntry(newEntry); // add it in ui - tableModel.addRow(newEntry, indexSelectedRow + currentTransaction.getEntry().size()); + int addIndex = tableModel.indexOf(currentTransaction) + + currentTransaction.getEntry().size(); + tableModel.addRow(newEntry, addIndex); //select the new line ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval( - indexSelectedRow + 1, indexSelectedRow + 1); - table.changeSelection(indexSelectedRow + 1, 1, false, false); + addIndex, addIndex); + table.changeSelection(addIndex, 1, false, false); } catch (LimaException ex) { throw new LimaRuntimeException("Can't add emptyentry", ex); @@ -442,6 +444,7 @@ } else if (selectedValue instanceof Entry) { Entry currentEntry = (Entry) selectedValue; financialTransactionService.removeEntry(currentEntry); + currentEntry.getFinancialTransaction().removeEntry(currentEntry); } tableModel.deleteRow(indexSelectedRow);
participants (1)
-
echatellier@users.chorem.org