This is an automated email from the git hooks/post-receive script. New change to branch feature/1242-no-account-research-exception in repository lima. See http://git.chorem.org/lima.git from c5f4901 refs #1242 Modification pour plus de lisibilité suite à revue de code Kevin new 5cf4e25 refs #1242 Refactoring pour plus de lisibilité The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 5cf4e2592433bca78dc06b142fb550679f7c3096 Author: dcosse <cosse@codelutin.com> Date: Mon Sep 28 17:15:06 2015 +0200 refs #1242 Refactoring pour plus de lisibilité Summary of changes: .../ui/financialtransaction/AccountColumn.java | 46 +++++++++++++++------- 1 file changed, 31 insertions(+), 15 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1242-no-account-research-exception in repository lima. See http://git.chorem.org/lima.git commit 5cf4e2592433bca78dc06b142fb550679f7c3096 Author: dcosse <cosse@codelutin.com> Date: Mon Sep 28 17:15:06 2015 +0200 refs #1242 Refactoring pour plus de lisibilité --- .../ui/financialtransaction/AccountColumn.java | 46 +++++++++++++++------- 1 file changed, 31 insertions(+), 15 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 ec431f3..d916219 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,35 +48,51 @@ public class AccountColumn extends AbstractColumn<FinancialTransactionTableModel @Override public boolean setValueAt(Object value, int row) { Entry entry = tableModel.get(row); - // 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())); + + Account selectedAccount = getSelectedAccount(value); + Account previousAccount = entry.getAccount(); + + boolean update = isValueChange(selectedAccount, previousAccount); + if (update) { - Account previousAccount = entry.getAccount(); - entry.setAccount(account); - if (!tableModel.updateEntry(entry)) { - update = revertAccountChange(entry, previousAccount); + entry.setAccount(selectedAccount); + boolean updateSucceed = !tableModel.updateEntry(entry); + if (updateSucceed) { + setDescriptionFieldIfNone(entry, selectedAccount); } else { - setDescripntionFieldIfNone(entry, account); + update = revertAccountChange(entry, previousAccount); } } return update; } - protected void setDescripntionFieldIfNone(Entry entry, Account account) { + protected Account getSelectedAccount(Object value) { + Account newAccount = null; + if (value != null && value instanceof Account) { + newAccount = (Account) value; + } + return newAccount; + } + + protected boolean isValueChange(Account newAccount, Account previousAccount) { + boolean update; + if (previousAccount == null) { + update = newAccount != null; + } else { + update = newAccount == null || !previousAccount.getAccountNumber().equals(newAccount.getAccountNumber()); + } + return update; + } + + protected void setDescriptionFieldIfNone(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; + return false; } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm