This is an automated email from the git hooks/post-receive script. New commit to branch feature/1240-select-no-account-exception in repository lima. See http://git.chorem.org/lima.git commit 34f7074a2979ef27bb195fe4f03daecdc37a7f55 Author: dcosse <cosse@codelutin.com> Date: Mon Jun 29 14:25:13 2015 +0200 refs #1240 ajout de controles --- .../ui/financialtransaction/AccountColumn.java | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java index c38a68b..ec431f3 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java @@ -48,22 +48,35 @@ public class AccountColumn extends AbstractColumn<FinancialTransactionTableModel @Override public boolean setValueAt(Object value, int row) { Entry entry = tableModel.get(row); - Account account = (Account) value; + // In case of Account field being feed up but no account was selected + // the value is a String instead of Account. + Account account = value == null ? null : value instanceof Account ? (Account) value : null; boolean update = ((entry.getAccount()) == null != (account == null)) || (entry.getAccount() != null - && !entry.getAccount().getAccountNumber().equals(account.getAccountNumber())); + && !entry.getAccount().getAccountNumber().equals(account.getAccountNumber())); if (update) { Account previousAccount = entry.getAccount(); entry.setAccount(account); if (!tableModel.updateEntry(entry)) { - entry.setAccount(previousAccount); - update = false; + update = revertAccountChange(entry, previousAccount); } else { - if (StringUtils.isBlank(entry.getDescription()) && StringUtils.isNotBlank(account.getLabel())) { - entry.setDescription(account.getLabel()); - } + setDescripntionFieldIfNone(entry, account); } } + + return update; + } + + protected void setDescripntionFieldIfNone(Entry entry, Account account) { + if (StringUtils.isBlank(entry.getDescription()) && account != null && StringUtils.isNotBlank(account.getLabel())) { + entry.setDescription(account.getLabel()); + } + } + + protected boolean revertAccountChange(Entry entry, Account previousAccount) { + boolean update; + entry.setAccount(previousAccount); + update = false; return update; } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.