This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository lima. See http://git.chorem.org/lima.git commit 54e25dd273e118c5a7df3c7dba3a21edc6635f5f Author: dcosse <cosse@codelutin.com> Date: Wed Sep 16 14:55:59 2015 +0200 refs #1293 Auto selection du compte si un seul compte correspond à la recherche --- .../lima/ui/celleditor/AccountTableCellEditor.java | 26 +++++++++++++++++----- .../ui/financialtransaction/AccountColumn.java | 6 +++-- pom.xml | 2 +- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java b/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java index f1fec63..0fdd3f1 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java @@ -27,12 +27,11 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; import org.chorem.lima.ui.combobox.AccountComboBox; -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.table.TableCellEditor; import javax.swing.text.JTextComponent; -import java.awt.Component; +import java.awt.*; +import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.EventObject; @@ -60,6 +59,24 @@ public class AccountTableCellEditor extends AbstractCellEditor implements TableC accountComboBox = new AccountComboBox(); accountComboBox.setLeafAccounts(true); accountComboBox.setShowDecorator(false); + + final JComboBox comboBox = accountComboBox.getCombobox(); + comboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + if (accountComboBox.isEnterToSelectUniqueUniverse() && comboBox.getItemCount() == 1) { + + // auto-select the account + if (log.isDebugEnabled()) { + log.debug("Auto-select unique result with *ENTER* or *TAB* key"); + } + e.consume(); + // edition is done + comboBox.setSelectedIndex(0); + comboBox.hidePopup(); + } + } + }); } @Override @@ -106,5 +123,4 @@ public class AccountTableCellEditor extends AbstractCellEditor implements TableC boolean result = !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 1; return result; } - } 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..e8484d0 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 @@ -25,6 +25,7 @@ package org.chorem.lima.ui.financialtransaction; import org.apache.commons.lang3.StringUtils; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; +import org.chorem.lima.ui.celleditor.AccountTableCellEditor; import org.chorem.lima.ui.common.AbstractColumn; import org.chorem.lima.ui.common.FinancialTransactionTableModel; @@ -37,6 +38,7 @@ public class AccountColumn extends AbstractColumn<FinancialTransactionTableModel public AccountColumn() { super(Account.class, t("lima.entry.account"), true); + setCellEditor(new AccountTableCellEditor()); } @Override @@ -60,14 +62,14 @@ public class AccountColumn extends AbstractColumn<FinancialTransactionTableModel if (!tableModel.updateEntry(entry)) { update = revertAccountChange(entry, previousAccount); } else { - setDescripntionFieldIfNone(entry, account); + setDescriptionFieldIfNone(entry, account); } } return update; } - protected void setDescripntionFieldIfNone(Entry entry, Account account) { + protected void setDescriptionFieldIfNone(Entry entry, Account account) { if (StringUtils.isBlank(entry.getDescription()) && account != null && StringUtils.isNotBlank(account.getLabel())) { entry.setDescription(account.getLabel()); } diff --git a/pom.xml b/pom.xml index a2a368e..32a10b7 100644 --- a/pom.xml +++ b/pom.xml @@ -200,7 +200,7 @@ <itextVersion>4.2.1</itextVersion> <jasperreportsVersion>6.0.3</jasperreportsVersion> <javaxServletVersion>3.1.0</javaxServletVersion> - <jaxxVersion>2.24</jaxxVersion> + <jaxxVersion>2.26</jaxxVersion> <jbossTransactionVersion>1.0.0.Final</jbossTransactionVersion> <jdomVersion>2.0.5</jdomVersion> <jettyPluginVersion>9.2.3.v20140905</jettyPluginVersion> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.