Author: vsalaun Date: 2011-05-12 10:35:16 +0200 (Thu, 12 May 2011) New Revision: 3109 Url: http://chorem.org/repositories/revision/lima/3109 Log: #267 ajout du renderer pour les objets de type BigDecimal dans la saisie des ecritures 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 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 2011-05-12 08:32:13 UTC (rev 3108) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-05-12 08:35:16 UTC (rev 3109) @@ -39,8 +39,10 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.ui.celleditor.AccountTableCellEditor; +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.celleditor.BigDecimalTableCellEditor; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; @@ -83,6 +85,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(); @@ -131,7 +137,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/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-05-12 08:32:13 UTC (rev 3108) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-05-12 08:35:16 UTC (rev 3109) @@ -312,10 +312,10 @@ } break; case 6: - result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; + result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; break; case 7: - result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); + result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); break; case 8: result = null; @@ -360,8 +360,8 @@ public void addFinancialTransaction() throws LimaException{ /* Calling transaction service */ FinancialTransaction financialTransaction = new FinancialTransactionImpl(); - financialTransaction.setAmountDebit(new BigDecimal(0)); - financialTransaction.setAmountCredit(new BigDecimal(0)); + financialTransaction.setAmountDebit(BigDecimal.ZERO); + financialTransaction.setAmountCredit(BigDecimal.ZERO); //if a period is selected if (selectedFinancialPeriod != null){ financialTransaction.setFinancialPeriod(selectedFinancialPeriod); @@ -413,7 +413,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) { @@ -513,13 +513,11 @@ currentEntry.setLetter((Letter)value); break; case 6: - //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 7: - currentEntry.setAmount(new BigDecimal((Long)value)); + currentEntry.setAmount((BigDecimal) value); currentEntry.setDebit(false); break; }
participants (1)
-
vsalaun@users.chorem.org