From scm@users.codelutin.com Tue Jan 30 17:57:01 2018
From: "codelutin.com scm" <scm@users.codelutin.com>
To: faxtomail-commits@list.forge.codelutin.com
Subject: [Faxtomail-commits] branch feature/9645-filtreListeClient created
	(now d89f5da2)
Date: Tue, 30 Jan 2018 17:57:00 +0100
Message-ID: <20180130165700.12203.42978@bihar.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============0285257523687937530=="

--===============0285257523687937530==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

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>.

--===============0285257523687937530==--


From scm@users.codelutin.com Tue Jan 30 17:57:01 2018
From: "codelutin.com scm" <scm@users.codelutin.com>
To: faxtomail-commits@list.forge.codelutin.com
Subject: [Faxtomail-commits] 01/01: Wait for 3 chars to init clientComboBox
Date: Tue, 30 Jan 2018 17:57:01 +0100
Message-ID: <20180130165701.AB1A25C0FDE@goh.codelutin.com>
In-Reply-To: <20180130165700.12203.42978@bihar.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============3348108552323048469=="

--===============3348108552323048469==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

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/pe=
rsistence/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/persisten=
ce/entities/ClientTopiaDao.java
+++ b/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persisten=
ce/entities/ClientTopiaDao.java
@@ -63,6 +63,18 @@ public class ClientTopiaDao extends AbstractClientTopiaDao=
<Client> {
         return findAll(query, args);
     }
=20
+    public List<Client> forCompanyFiltered(String company, String filter) {
+        String query =3D "FROM " + Client.class.getName() +
+                " WHERE " + Client.PROPERTY_COMPANY +  "=3D :companyValue " +
+                " AND (UPPER(" + Client.PROPERTY_NAME + ") LIKE :propValue" +
+                " OR UPPER(" + Client.PROPERTY_CODE + ") LIKE :propValue )";
+
+        Map<String, Object> args =3D new HashMap<>();
+        args.put("propValue", "%" + filter.toUpperCase() + "%");
+        args.put("companyValue", company);
+        return findAll(query, args);
+    }
+
=20
     public List<Client> forEmailAddressOrCodeLike(String searchQuery) {
         Preconditions.checkArgument(StringUtils.isNotBlank(searchQuery), "Em=
pty query can produce unexcepted results");
diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/servic=
es/service/ClientService.java b/faxtomail-service/src/main/java/com/franciafl=
ex/faxtomail/services/service/ClientService.java
index 94004790..c2ddd45a 100644
--- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/serv=
ice/ClientService.java
+++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/serv=
ice/ClientService.java
@@ -43,6 +43,8 @@ public interface ClientService extends FaxToMailService {
=20
     List<Client> getClientsForFolder(MailFolder folder);
=20
+    List<Client> getClientsForFolder(MailFolder folder, String filter);
+
     void updateNewClients();
=20
     List<Client> getAllClientsForUser(FaxToMailUser currentUser);
diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/servic=
es/service/ClientServiceImpl.java b/faxtomail-service/src/main/java/com/franc=
iaflex/faxtomail/services/service/ClientServiceImpl.java
index 1df87b46..73199c3e 100644
--- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/serv=
ice/ClientServiceImpl.java
+++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/serv=
ice/ClientServiceImpl.java
@@ -161,6 +161,19 @@ public class ClientServiceImpl extends FaxToMailServiceS=
upport implements Client
         return result;
     }
=20
+    @Override
+    public List<Client> getClientsForFolder(MailFolder folder, String filter=
) {
+        while (!folder.isUseCurrentLevelCompany() && folder.getParent() !=3D=
 null) {
+            folder =3D folder.getParent();
+        }
+
+        String company =3D folder.getCompany();
+
+        ClientTopiaDao clientDao =3D getPersistenceContext().getClientDao();
+        List<Client> result =3D clientDao.forCompanyFiltered(company,filter);
+        return result;
+    }
+
     /**
      * R=C3=A9cup=C3=A8re les information de la table NewClient pour mettre =
=C3=A0 jour la table Client.
      */
diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/sw=
ing/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/con=
tent/demande/DemandeUIHandler.java
+++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/con=
tent/demande/DemandeUIHandler.java
@@ -424,15 +424,32 @@ public class DemandeUIHandler extends AbstractFaxToMail=
UIHandler<DemandeUIModel,
         if (log.isInfoEnabled()) {
             log.info("avant chargement combo clients " + now);
         }
-        BeanFilterableComboBox<Client> clientComboBox =3D ui.getClientComboB=
ox();
+        final BeanFilterableComboBox<Client> clientComboBox =3D ui.getClient=
ComboBox();
         clientComboBox.getComboBoxModel().setWildcardCharacter(null);
-        initBeanFilterableComboBox(clientComboBox, model.getAllowedClients()=
, model.getClient());
+        initBeanFilterableComboBox(clientComboBox, Collections.singletonList=
(model.getClient()), model.getClient());
=20
         long time =3D new Date().getTime()- now.getTime();
         if (log.isInfoEnabled()) {
             log.info("chargement combo clients " + time);
         }
=20
+        KeyAdapter clientComboBoxKeyAdapter =3D new KeyAdapter() {
+
+            @Override
+            public void keyPressed(KeyEvent e) {
+                if (clientComboBox.getComboBoxModel().getFilterText().length=
()=3D=3D3){
+                    //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.s=
ingletonList(getModel().getClient()), getModel().getClient());
+                } // do nothing if more than 3 chars entered (list already i=
nitialised)
+            }
+        };
+
+        clientComboBox.addKeyListener(clientComboBoxKeyAdapter);
+
         listModelIsModify(model);
     }
=20

--=20
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm@codelutin.com>.

--===============3348108552323048469==--


