Author: vsalaun Date: 2011-05-12 10:37:36 +0200 (Thu, 12 May 2011) New Revision: 3110 Url: http://chorem.org/repositories/revision/lima/3110 Log: #267 ajout du renderer pour les objets de type BigDecimal dans la recherche des transactions 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 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-05-12 08:35:16 UTC (rev 3109) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-05-12 08:37:36 UTC (rev 3110) @@ -32,6 +32,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.jdesktop.swingx.JXTable; @@ -70,6 +72,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(); @@ -118,7 +124,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/financialtransactionsearch/FinancialTransactionSearchTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-05-12 08:35:16 UTC (rev 3109) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-05-12 08:37:36 UTC (rev 3110) @@ -293,10 +293,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; @@ -348,7 +348,7 @@ FinancialTransaction currentTransaction = null; Object currentRow = cacheDataList.get(row); Entry entry = new EntryImpl(); - entry.setAmount(new BigDecimal(0)); + entry.setAmount(BigDecimal.ZERO); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { currentTransaction = (FinancialTransaction)currentRow;