This is an automated email from the git hooks/post-receive script. New commit to branch feature/1173_ajout_toto in repository lima. See http://git.chorem.org/lima.git commit 74dc1b7547b4874f7547cb032f82484a3c1bc7ca Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Feb 27 16:26:09 2015 +0100 debut de code pour ajout des totaux en dessous du tableau --- .../FinancialTransactionView.css | 5 ++ .../FinancialTransactionView.jaxx | 17 ++++++ .../FinancialTransactionViewHandler.java | 64 ++++++++++++++++++---- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.css b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.css index 3be927b..451745b 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.css @@ -124,4 +124,9 @@ #financialTransactionTable { rowHeight : 22; +} + +#statusLabel { + text: {getStatusText()}; + horizontalTextPosition:{JLabel.RIGHT}; } \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx index 427676d..0805eb8 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx @@ -135,4 +135,21 @@ selectionModel='{selectionModel}' model='{financialTransactionTableModel}'/> </JScrollPane> + + <String id="statusText" javaBean=''/> + + <JPanel constraints="BorderLayout.SOUTH" layout="{new BorderLayout()}"> + <JLabel id='statusLabel' constraints="BorderLayout.EAST"/> + </JPanel> + <!--Table fill="both" weightx="1" constraints="BorderLayout.SOUTH"> + <row> + <cell weightx="1"> + <JLabel/> + </cell> + <cell anchor="east"> + <JLabel id='statusLabel'/> + </cell> + </row> + </Table--> + </JPanel> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java index a674720..11d5967 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java @@ -106,13 +106,13 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo LimaServiceFactory.addServiceListener(ImportService.class, this); errorHelper = new ErrorHelper(LimaSwingConfig.getInstance()); initShortCuts(); - } + } /** * Init all combo box in view. */ public void init() { - + // fiscal periods List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); @@ -137,6 +137,23 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo FinancialTransactionTable table = view.getFinancialTransactionTable(); table.getColumnModel().addColumnModelListener(this); SwingUtil.fixTableColumnWidth(table, 0, 40); + + tableModel.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent e) { + + boolean mustRecompute = e.getType() == TableModelEvent.DELETE + || e.getType() == TableModelEvent.INSERT + || (e.getType() == TableModelEvent.UPDATE && + (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == 4 || e.getColumn() == 5)); + + if (mustRecompute) { + computeStatusText(); + } + + } + }); } protected void initShortCuts() { @@ -268,7 +285,7 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo /** * New fiscal period selection. - * + * * @param event event */ public void fiscalPeriodSelected(ItemEvent event) { @@ -277,13 +294,13 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); - + if (log.isDebugEnabled()) { log.debug(String.format("Loaded %d financial periods", financialPeriods.size())); } view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); view.getFinancialPeriodComboBoxModel().setSelectedItem(financialPeriods.get(0)); - + // update transactions updateFinancialTransactions(); } @@ -291,7 +308,7 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo /** * New financial period selection. - * + * * @param event event */ public void financialPeriodSelected(ItemEvent event) { @@ -302,7 +319,7 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo /** * New entry book selected. - * + * * @param event event */ public void entryBookSelected(ItemEvent event) { @@ -841,7 +858,7 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo /** * Select previous value in combo box. - * + * * @param comboBox combo box */ public void back(JComboBox comboBox) { @@ -854,7 +871,7 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo /** * Select next value in combo box. - * + * * @param comboBox combo box */ public void next(JComboBox comboBox) { @@ -871,11 +888,11 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo */ @Override public void notifyMethod(String serviceName, String methodName) { - + if (log.isDebugEnabled()) { log.debug("Method notified " + serviceName + "#" + methodName); } - + if (serviceName.contains("FinancialTransaction") || methodName.contains("importEntries") || methodName.contains("importAll")) { @@ -953,4 +970,29 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo return lastAssignDate; } + + protected void computeStatusText() { + + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); + + BigDecimal totalDebit = BigDecimal.ZERO; + BigDecimal totalCredit = BigDecimal.ZERO; + + for (Entry entry : tableModel.getValues()) { + + BigDecimal amount = entry.getAmount(); + boolean debit = entry.isDebit(); + if (debit) { + totalDebit = totalDebit.add(amount); + } else { + totalCredit = totalCredit.add(amount); + } + } + + //TODO Just do mi ! + String result = String.format("<html>Débit <strong><font color=#ffffdd>%s</font></strong> - Crédit <b>%s</b>", totalDebit, totalCredit); + view.setStatusText(result); + + } + } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.