r3105 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports
Author: vsalaun Date: 2011-05-12 10:23:54 +0200 (Thu, 12 May 2011) New Revision: 3105 Url: http://chorem.org/repositories/revision/lima/3105 Log: #267 ajout du renderer pour les objets de type BigDecimal dans l'edition des comptes Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2011-05-12 08:23:54 UTC (rev 3105) @@ -0,0 +1,32 @@ +package org.chorem.lima.ui.accountsreports; + +import java.math.BigDecimal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.ui.accountsreports.AccountsReportsTable; +import org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; +import org.jdesktop.swingx.JXTable; + +public class AccountsReportsTable extends JXTable { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6093850347322834480L; + + /** log. */ + private static final Log log = LogFactory + .getLog(AccountsReportsTable.class); + + protected AccountsReportsViewHandler handler; + + public AccountsReportsTable(AccountsReportsViewHandler handler) { + + this.handler = handler; + + //Get new BigDecimal renderer + setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); + + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2011-05-12 08:15:34 UTC (rev 3104) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2011-05-12 08:23:54 UTC (rev 3105) @@ -26,12 +26,18 @@ package org.chorem.lima.ui.accountsreports; import static org.nuiton.i18n.I18n._; + +import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.util.Date; + import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.ReportsDatas; +import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.Letter; /** * Entry book table model. @@ -67,7 +73,43 @@ public int getColumnCount() { return 8; } + + @Override + public Class<?> getColumnClass(int column) { + Class<?> result = null; + + switch (column) { + case 0: + result = Account.class; + break; + case 1: + result = Date.class; + break; + case 2: + result = Entry.class; + break; + case 3: + result = String.class; + break; + case 4: + result = String.class; + break; + case 5: + result = Letter.class; + break; + case 6: + result = BigDecimal.class; + break; + case 7: + result = BigDecimal.class; + break; + } + + return result; + } + + @Override public String getColumnName(int column) { String res = "n/a"; @@ -139,10 +181,10 @@ } break; case 6: - result = currentRow.getDebit() ? currentRow.getAmount() : 0; + result = currentRow.getDebit() ? currentRow.getAmount() : BigDecimal.ZERO; break; case 7: - result = currentRow.getDebit() ? 0 : currentRow.getAmount(); + result = currentRow.getDebit() ? BigDecimal.ZERO : currentRow.getAmount(); break; } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2011-05-12 08:15:34 UTC (rev 3104) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2011-05-12 08:23:54 UTC (rev 3105) @@ -65,7 +65,8 @@ <row> <cell fill="both" weightx="1" weighty="1" columns="6"> <JScrollPane> - <org.jdesktop.swingx.JXTable id="accountsReportsTable" rowHeight="24" + <org.chorem.lima.ui.accountsreports.AccountsReportsTable id="accountsReportsTable" rowHeight="24" + constructorParams="getHandler()" model="{getModelAccountsReportsTable()}" highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2011-05-12 08:15:34 UTC (rev 3104) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2011-05-12 08:23:54 UTC (rev 3105) @@ -51,6 +51,8 @@ protected AccountsReportsView view; + protected AccountsReportsTable table; + protected AccountsReportsTableModel tableModel; protected AccountComboBoxModel comboBoxModel;
participants (1)
-
vsalaun@users.chorem.org