This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 10064bde3b5434481b77360b2af384b185a14bd3 Author: David Cossé <cosse@codelutin.com> Date: Wed Oct 18 00:56:51 2017 +0200 refs #1394 initialisation des listeners apres modification des la vue initiale --- .../ui/common/FinancialTransactionTableModel.java | 6 +-- .../FinancialTransactionViewHandler.java | 53 ++++++++++++++-------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java index 5ef4ded1..859cbf95 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java @@ -130,11 +130,7 @@ public class FinancialTransactionTableModel extends TableModelWithGroup<Entry> i protected LinkedHashMap<String, List<Entry>> getEntriesByVoucherByDate(List<Entry> orderedEntries) { LinkedHashMap<String, List<Entry>> orderedEntriesByVoucher = new LinkedHashMap<>(); for (Entry orderedEntry : orderedEntries) { - List<Entry> entriesForVoucher = orderedEntriesByVoucher.get(orderedEntry.getVoucher()); - if (entriesForVoucher == null) { - entriesForVoucher = Lists.newArrayList(); - orderedEntriesByVoucher.put(orderedEntry.getVoucher(), entriesForVoucher); - } + List<Entry> entriesForVoucher = orderedEntriesByVoucher.computeIfAbsent(orderedEntry.getVoucher(), k -> Lists.newArrayList()); entriesForVoucher.add(orderedEntry); } return orderedEntriesByVoucher; 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 5bc1f20d..1b73eaed 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 @@ -22,7 +22,6 @@ package org.chorem.lima.ui.financialtransaction; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import jaxx.runtime.SwingUtil; import org.apache.commons.lang.StringUtils; @@ -121,10 +120,12 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo * Init all combo box in view. */ public void init() { - MainView mainView = LimaSwingApplicationContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + // fiscal periods List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); + view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + if (log.isDebugEnabled()) { log.debug(String.format("Loaded %d fiscal periods", fiscalPeriods.size())); } @@ -143,13 +144,27 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo view.getEntryBookComboBoxModel().setSelectedItem(allEntryBooks.get(0)); } - FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); - tableModel.addTableModelListener(this); + initializationComplete = true; + updateFinancialTransactions(); + computePeriodStatusText(); + + setAddEntryAllowed(); + + addListeners(); + + } + + protected void addListeners() { FinancialTransactionTable table = view.getFinancialTransactionTable(); table.getColumnModel().addColumnModelListener(this); SwingUtil.fixTableColumnWidth(table, 0, 40); + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); + tableModel.addTableModelListener(this); + + MainView mainView = LimaSwingApplicationContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + tableModel.addTableModelListener(e -> { boolean mustRecompute = e.getType() == TableModelEvent.DELETE @@ -163,12 +178,6 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo } }); - - initializationComplete = true; - updateFinancialTransactions(); - computePeriodStatusText(); - - setAddEntryAllowed(); } protected void initShortCuts() { @@ -350,21 +359,28 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo * and entry book. */ public void updateFinancialTransactions() { - if (initializationComplete) { + if (view.getEntryBookComboBoxModel().getSelectedItem() != null && + view.getFiscalPeriodComboBoxModel().getSelectedItem() != null && + view.getFinancialPeriodComboBox().getSelectedItem() != null && + initializationComplete) { + FinancialPeriod financialPeriod = (FinancialPeriod) view.getFinancialPeriodComboBox().getSelectedItem(); EntryBook entryBook = (EntryBook) view.getEntryBookComboBox().getSelectedItem(); - List<FinancialTransaction> transactions = Lists.newArrayList(); - if (entryBook != null && financialPeriod != null) { - transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod, entryBook); - } + List<FinancialTransaction> transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod, entryBook); + FinancialTransactionTable table = view.getFinancialTransactionTable(); FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); table.exit(); + tableModel.setTransactions(transactions); boolean isLock = isTableLock(financialPeriod, entryBook); - table.setEditable(!isLock); + + if (table.isEditable() == isLock) { + table.setEditable(!isLock); + } + } } @@ -677,8 +693,9 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo entry.setDescription(defaultDescription); String defaultAccount; - //Actual (2012) tva percentage : 19,6% - BigDecimal tvaPercentAdd = new BigDecimal(0.196); + //TODO dcosse pas de valeur en dur + //Actual (2017) tva percentage : 20% + BigDecimal tvaPercentAdd = new BigDecimal(0.2); BigDecimal tvaTax = null; //Calculation of tva tax only if first entry is a sale -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.