branch feature/9645-filtreListeClient created (now d89f5da2)
This is an automated email from the git hooks/post-receive script. New change to branch feature/9645-filtreListeClient in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git at d89f5da2 Wait for 3 chars to init clientComboBox This branch includes the following new commits: new d89f5da2 Wait for 3 chars to init clientComboBox 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 d89f5da2dfb6b2ff581e289bd040e4e76a04bdda Author: Jean Couteau <jean.couteau@gmail.com> Date: Tue Jan 30 17:54:59 2018 +0100 Wait for 3 chars to init clientComboBox -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/9645-filtreListeClient in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git commit d89f5da2dfb6b2ff581e289bd040e4e76a04bdda Author: Jean Couteau <jean.couteau@gmail.com> Date: Tue Jan 30 17:54:59 2018 +0100 Wait for 3 chars to init clientComboBox --- .../persistence/entities/ClientTopiaDao.java | 12 ++++++++++++ .../faxtomail/services/service/ClientService.java | 2 ++ .../services/service/ClientServiceImpl.java | 13 +++++++++++++ .../ui/swing/content/demande/DemandeUIHandler.java | 21 +++++++++++++++++++-- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/ClientTopiaDao.java b/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/ClientTopiaDao.java index 48125a54..b18b1086 100644 --- a/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/ClientTopiaDao.java +++ b/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/ClientTopiaDao.java @@ -63,6 +63,18 @@ public class ClientTopiaDao extends AbstractClientTopiaDao<Client> { return findAll(query, args); } + public List<Client> forCompanyFiltered(String company, String filter) { + String query = "FROM " + Client.class.getName() + + " WHERE " + Client.PROPERTY_COMPANY + "= :companyValue " + + " AND (UPPER(" + Client.PROPERTY_NAME + ") LIKE :propValue" + + " OR UPPER(" + Client.PROPERTY_CODE + ") LIKE :propValue )"; + + Map<String, Object> args = new HashMap<>(); + args.put("propValue", "%" + filter.toUpperCase() + "%"); + args.put("companyValue", company); + return findAll(query, args); + } + public List<Client> forEmailAddressOrCodeLike(String searchQuery) { Preconditions.checkArgument(StringUtils.isNotBlank(searchQuery), "Empty query can produce unexcepted results"); diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ClientService.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ClientService.java index 94004790..c2ddd45a 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ClientService.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ClientService.java @@ -43,6 +43,8 @@ public interface ClientService extends FaxToMailService { List<Client> getClientsForFolder(MailFolder folder); + List<Client> getClientsForFolder(MailFolder folder, String filter); + void updateNewClients(); List<Client> getAllClientsForUser(FaxToMailUser currentUser); diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ClientServiceImpl.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ClientServiceImpl.java index 1df87b46..73199c3e 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ClientServiceImpl.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ClientServiceImpl.java @@ -161,6 +161,19 @@ public class ClientServiceImpl extends FaxToMailServiceSupport implements Client return result; } + @Override + public List<Client> getClientsForFolder(MailFolder folder, String filter) { + while (!folder.isUseCurrentLevelCompany() && folder.getParent() != null) { + folder = folder.getParent(); + } + + String company = folder.getCompany(); + + ClientTopiaDao clientDao = getPersistenceContext().getClientDao(); + List<Client> result = clientDao.forCompanyFiltered(company,filter); + return result; + } + /** * Récupère les information de la table NewClient pour mettre à jour la table Client. */ diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java index e888362c..78341845 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java @@ -424,15 +424,32 @@ public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, if (log.isInfoEnabled()) { log.info("avant chargement combo clients " + now); } - BeanFilterableComboBox<Client> clientComboBox = ui.getClientComboBox(); + final BeanFilterableComboBox<Client> clientComboBox = ui.getClientComboBox(); clientComboBox.getComboBoxModel().setWildcardCharacter(null); - initBeanFilterableComboBox(clientComboBox, model.getAllowedClients(), model.getClient()); + initBeanFilterableComboBox(clientComboBox, Collections.singletonList(model.getClient()), model.getClient()); long time = new Date().getTime()- now.getTime(); if (log.isInfoEnabled()) { log.info("chargement combo clients " + time); } + KeyAdapter clientComboBoxKeyAdapter = new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent e) { + if (clientComboBox.getComboBoxModel().getFilterText().length()==3){ + //init list when 3 chars entered + + initBeanFilterableComboBox(clientComboBox, getContext().getClientCache(), getModel().getClient()); + } else if (clientComboBox.getComboBoxModel().getFilterText().length()<3){ + //empty list if less than 3 chars + initBeanFilterableComboBox(clientComboBox, Collections.singletonList(getModel().getClient()), getModel().getClient()); + } // do nothing if more than 3 chars entered (list already initialised) + } + }; + + clientComboBox.addKeyListener(clientComboBoxKeyAdapter); + listModelIsModify(model); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm