Author: vsalaun Date: 2011-05-12 10:40:28 +0200 (Thu, 12 May 2011) New Revision: 3111 Url: http://chorem.org/repositories/revision/lima/3111 Log: #267 ajout du renderer pour les objets de type BigDecimal dans la saisie des ecritures non equilibrees Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2011-05-12 08:37:36 UTC (rev 3110) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2011-05-12 08:40:28 UTC (rev 3111) @@ -34,6 +34,8 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.ui.celleditor.AccountTableCellEditor; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import org.chorem.lima.ui.celleditor.DateTableCellEditor; import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedViewHandler; @@ -75,6 +77,10 @@ setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor()); //Get new account editor setDefaultEditor(Account.class, new AccountTableCellEditor()); + //Get new amount editor + setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor()); + //Get new BigDecimal renderer + setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); //highlight financial financial transactions addColorTransaction(); @@ -123,7 +129,9 @@ Object value = adapter.getValueAt(adapter.row, 8); if (value instanceof BigDecimal) { BigDecimal currentBalance = (BigDecimal) value; - if (currentBalance != BigDecimal.ZERO) { + // can compare two BigDecimals with different scales + // e.g: 3.1 == 3.10 + if (currentBalance.compareTo(BigDecimal.ZERO) != 0) { isHighlighted = true; } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2011-05-12 08:37:36 UTC (rev 3110) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2011-05-12 08:40:28 UTC (rev 3111) @@ -312,10 +312,10 @@ result = currentEntry.getDescription(); break; case 5 : - result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; + result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; break; case 6: - result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); + result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); break; case 7: result = null; @@ -367,7 +367,7 @@ FinancialTransaction currentTransaction = null; Object currentRow = cacheDataList.get(row); Entry entry = new EntryImpl(); - entry.setAmount(new BigDecimal(0)); + entry.setAmount(BigDecimal.ZERO); entry.setDescription(description); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { @@ -433,13 +433,11 @@ currentEntry.setDescription((String)value); break; case 5 : - //FIXME jpepin 20101231 transtypage "superflu" pour éviter un bug de getColumnName - // qui ne fonctionne plus avec les BigDecimal - currentEntry.setAmount(new BigDecimal((Long)value)); + currentEntry.setAmount((BigDecimal) value); currentEntry.setDebit(true); break; case 6: - currentEntry.setAmount(new BigDecimal((Long)value)); + currentEntry.setAmount((BigDecimal) value); currentEntry.setDebit(false); break; case 8:
participants (1)
-
vsalaun@users.chorem.org