From kmorin@users.forge.codelutin.com Fri Dec 12 12:51:03 2014
From: kmorin@users.forge.codelutin.com
To: faxtomail-commits@list.forge.codelutin.com
Subject: [Faxtomail-commits] r728 - in trunk:	=?utf-8?q?faxtomail-persistenc?=
 =?utf-8?q?e/src/main/java/com/franciaflex/faxtomail/persistence/entities?=
	faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service
	faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing
	faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions	
 =?utf-8?q?faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swi?=
 =?utf-8?q?ng/content/demande?=
	faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util
Date: Fri, 12 Dec 2014 12:51:03 +0000
Message-ID: <20141212125103.270E05CA409@goh.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============1496690942245912572=="

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

Author: kmorin
Date: 2014-12-12 12:51:00 +0000 (Fri, 12 Dec 2014)
New Revision: 728

Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/728

Log:
fix filter issues

Modified:
   trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persis=
tence/entities/EmailTopiaDao.java
   trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/s=
ervice/EmailServiceImpl.java
   trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/=
FaxToMailUIContext.java
   trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/=
actions/LoadFolderEmailsAction.java
   trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/=
content/demande/DemandeListTableFilter.java
   trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/=
content/demande/DemandeListUIHandler.java
   trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/=
util/FaxToMailUIUtil.java

Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail=
/persistence/entities/EmailTopiaDao.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persi=
stence/entities/EmailTopiaDao.java	2014-12-11 15:20:39 UTC (rev 727)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persi=
stence/entities/EmailTopiaDao.java	2014-12-12 12:51:00 UTC (rev 728)
@@ -407,7 +407,8 @@
                 Email.PROPERTY_CLIENT,
                 //Email.PROPERTY_RANGE_ROW + "." + RangeRow.PROPERTY_RANGE,
                 Email.PROPERTY_WAITING_STATE,
-                Email.PROPERTY_TAKEN_BY
+                Email.PROPERTY_TAKEN_BY,
+                Email.PROPERTY_LAST_ATTACHMENT_OPENER
                 //Email.PROPERTY_REPLIES,
                 //Email.PROPERTY_ATTACHMENT,
                 //Email.PROPERTY_HISTORY + "." + History.PROPERTY_FAX_TO_MAI=
L_USER,
@@ -460,13 +461,13 @@
             //Hibernate.initialize(email.getTakenBy());
             Hibernate.initialize(email.getReplies());
             Hibernate.initialize(email.getAttachment());
-            Collection<History> histories =3D email.getHistory();
-            if (histories !=3D null) {
-                for (History history : histories) {
-                    Hibernate.initialize(history.getFaxToMailUser());
-                    Hibernate.initialize(history.getFields());
-                }
-            }
+//            Collection<History> histories =3D email.getHistory();
+//            if (histories !=3D null) {
+//                for (History history : histories) {
+//                    Hibernate.initialize(history.getFaxToMailUser());
+//                    Hibernate.initialize(history.getFields());
+//                }
+//            }
             EmailGroup emailGroup =3D email.getEmailGroup();
             if (emailGroup !=3D null) {
                 Hibernate.initialize(emailGroup.getEmail());
@@ -510,18 +511,24 @@
      */
     public PaginationResult<Email> getEmailForFolder(EmailFilter emailFilter=
, MailFolder folder, PaginationParameter pagination) {
=20
+        long start =3D new Date().getTime();
+
         Map<String, Object> args =3D new HashMap<>();
         String query =3D filteredDemandsOfFolderCondition(folder, emailFilte=
r, args);
=20
         // add same fecth liste as emailService#getEmailForFolder()
         String hqlForFetchStep1 =3D "select E." + TopiaEntity.PROPERTY_TOPIA=
_ID + " FROM " + Email.class.getName() + " E " + query;
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder 1 - " + hqlForFetchStep1);
+        }
         String hqlForFetchStep2 =3D "select distinct E FROM " + Email.class.=
getName() + " E " + addAllFecthes(
                 Email.PROPERTY_PRIORITY,
                 Email.PROPERTY_DEMAND_TYPE,
                 Email.PROPERTY_CLIENT,
                 //Email.PROPERTY_RANGE_ROW + "." + RangeRow.PROPERTY_RANGE,
                 Email.PROPERTY_WAITING_STATE,
-                Email.PROPERTY_TAKEN_BY
+                Email.PROPERTY_TAKEN_BY,
+                Email.PROPERTY_LAST_ATTACHMENT_OPENER
                 //Email.PROPERTY_REPLIES,
                 //Email.PROPERTY_ATTACHMENT,
                 //Email.PROPERTY_HISTORY + "." + History.PROPERTY_FAX_TO_MAI=
L_USER,
@@ -529,8 +536,23 @@
                 //Email.PROPERTY_EMAIL_GROUP + "." + EmailGroup.PROPERTY_EMA=
IL
         ) + " WHERE E." + TopiaEntity.PROPERTY_TOPIA_ID + " in ( :topiaIdsFo=
rFetch_ )";
=20
+        if (log.isDebugEnabled()) {
+            log.debug("getEmailForFolder 2 - " + hqlForFetchStep2);
+        }
+
         // code copied from topia to perform search
+        long time =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder start query 1 : " + time);
+        }
+
         PaginationResult<String> pageResult =3D findPage(hqlForFetchStep1, a=
rgs, pagination);
+
+        long time2 =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder end query 1 : " + time2 + " (" + (t=
ime2 - time) + ")");
+        }
+
         List<String> step1ResultTopiaIds =3D pageResult.getElements();
=20
         List<Email> sortedEntities;
@@ -539,13 +561,38 @@
         } else {
             Map<String, Object> step2Args =3D Maps.newHashMap();
             step2Args.put("topiaIdsForFetch_", step1ResultTopiaIds);
+
+            time =3D new Date().getTime();
+            if (log.isTraceEnabled()) {
+                log.trace("getEmailForFolder start query 2 : " + time);
+            }
+
             List<Email> entities =3D forHql(hqlForFetchStep2, step2Args).fin=
dAll();
=20
+            time2 =3D new Date().getTime();
+            if (log.isTraceEnabled()) {
+                log.trace("getEmailForFolder end query 2 : " + time2 + " (" =
+ (time2 - time) + ")");
+            }
             sortedEntities =3D sortAccordingToIds(entities, step1ResultTopia=
Ids);
+
+            long time3 =3D new Date().getTime();
+            if (log.isTraceEnabled()) {
+                log.trace("getEmailForFolder sort query 2 : " + time3 + " ("=
 + (time3 - time2) + ")");
+            }
         }
=20
+        time =3D new Date().getTime();
+        if (log.isDebugEnabled()) {
+            log.trace("getEmailForFolder init results : " + time);
+        }
+
         PaginationResult<Email> result =3D PaginationResult.of(sortedEntitie=
s, pageResult.getCount(), pageResult.getCurrentPage());
=20
+        time2 =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder after pagination results : " + time=
2 + " (" + (time2 - time) + ")");
+        }
+
         //PaginationResult<Email> result =3D findPage(query.toString(), args=
, pagination);
=20
         // manual fetch
@@ -574,13 +621,156 @@
             //Hibernate.initialize(email.getTakenBy());
             Hibernate.initialize(email.getReplies());
             Hibernate.initialize(email.getAttachment());
-            Collection<History> histories =3D email.getHistory();
-            if (histories !=3D null) {
-                for (History history : histories) {
-                    Hibernate.initialize(history.getFaxToMailUser());
-                    Hibernate.initialize(history.getFields());
+//            Collection<History> histories =3D email.getHistory();
+//            if (histories !=3D null) {
+//                for (History history : histories) {
+//                    Hibernate.initialize(history.getFaxToMailUser());
+//                    Hibernate.initialize(history.getFields());
+//                }
+//            }
+            EmailGroup emailGroup =3D email.getEmailGroup();
+            if (emailGroup !=3D null) {
+                Hibernate.initialize(emailGroup.getEmail());
+                for (Email groupedEmail : emailGroup.getEmail()) {
+                    // initialize folder of the grouped demand to transmit t=
he grouped emails of the same folder
+                    Hibernate.initialize(groupedEmail.getMailFolder());
+                    // initialize the attachments for the attachments in the=
 replies
+                    Hibernate.initialize(groupedEmail.getAttachment());
                 }
             }
+        }
+
+        long time3 =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder after hibernate initializing : " + =
time3 + " (" + (time3 - time2) + ")");
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("getEmailFolder total : " + (time3 - start));
+        }
+
+        return result;
+    }
+
+    public PaginationResult<Email> getEmailForFolder2(EmailFilter emailFilte=
r, MailFolder folder, PaginationParameter pagination) {
+        long start =3D new Date().getTime();
+
+        Map<String, Object> args =3D new HashMap<>();
+        String query =3D filteredDemandsOfFolderCondition(folder, emailFilte=
r, args);
+
+        // add same fecth liste as emailService#getEmailForFolder()
+        String hqlForFetchStep1 =3D "select E." + TopiaEntity.PROPERTY_TOPIA=
_ID + " FROM " + Email.class.getName() + " E " + query;
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder2 1 - " + hqlForFetchStep1);
+        }
+        String hqlForFetchStep2 =3D "select distinct E FROM " + Email.class.=
getName() + " E " + addAllFecthes(
+                Email.PROPERTY_PRIORITY,
+                Email.PROPERTY_DEMAND_TYPE,
+                Email.PROPERTY_CLIENT,
+                Email.PROPERTY_RANGE_ROW + "." + RangeRow.PROPERTY_RANGE,
+                Email.PROPERTY_WAITING_STATE,
+                Email.PROPERTY_TAKEN_BY,
+                Email.PROPERTY_REPLIES,
+                Email.PROPERTY_LAST_ATTACHMENT_OPENER
+//                Email.PROPERTY_ATTACHMENT
+//                Email.PROPERTY_HISTORY + "." + History.PROPERTY_FAX_TO_MAI=
L_USER
+//                Email.PROPERTY_HISTORY + "." + History.PROPERTY_FIELDS_JSON
+//                Email.PROPERTY_EMAIL_GROUP + "." + EmailGroup.PROPERTY_EMA=
IL + "." + Email.PROPERTY_ATTACHMENT,
+//                Email.PROPERTY_EMAIL_GROUP + "." + EmailGroup.PROPERTY_EMA=
IL + "." + Email.PROPERTY_MAIL_FOLDER
+        ) + " WHERE E." + TopiaEntity.PROPERTY_TOPIA_ID + " in ( :topiaIdsFo=
rFetch_ )";
+
+        if (log.isDebugEnabled()) {
+            log.debug("getEmailForFolder2 2 - " + hqlForFetchStep2);
+        }
+
+
+        // code copied from topia to perform search
+        long time =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder2 start query 1 : " + time);
+        }
+
+        PaginationResult<String> pageResult =3D findPage(hqlForFetchStep1, a=
rgs, pagination);
+
+        long time2 =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder2 end query 1 : " + time2 + " (" + (=
time2 - time) + ")");
+        }
+
+        List<String> step1ResultTopiaIds =3D pageResult.getElements();
+
+        List<Email> sortedEntities;
+        if (CollectionUtils.isEmpty(step1ResultTopiaIds)) {
+            sortedEntities =3D Lists.newArrayList();
+        } else {
+            Map<String, Object> step2Args =3D Maps.newHashMap();
+            step2Args.put("topiaIdsForFetch_", step1ResultTopiaIds);
+
+            time =3D new Date().getTime();
+            if (log.isTraceEnabled()) {
+                log.trace("getEmailForFolder2 start query 2 : " + time);
+            }
+
+            List<Email> entities =3D forHql(hqlForFetchStep2, step2Args).fin=
dAll();
+
+            time2 =3D new Date().getTime();
+            if (log.isTraceEnabled()) {
+                log.trace("getEmailForFolder2 end query 2 : " + time2 + " ("=
 + (time2 - time) + ")");
+            }
+            sortedEntities =3D sortAccordingToIds(entities, step1ResultTopia=
Ids);
+
+            long time3 =3D new Date().getTime();
+            if (log.isTraceEnabled()) {
+                log.trace("getEmailForFolder2 sort query 2 : " + time3 + " (=
" + (time3 - time2) + ")");
+            }
+        }
+
+        time =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder2 init results : " + time);
+        }
+
+        PaginationResult<Email> result =3D PaginationResult.of(sortedEntitie=
s, pageResult.getCount(), pageResult.getCurrentPage());
+
+        time2 =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder2 after pagination results : " + tim=
e2 + " (" + (time2 - time) + ")");
+        }
+
+        //PaginationResult<Email> result =3D findPage(query.toString(), args=
, pagination);
+
+        // manual fetch
+        // Email.PROPERTY_PRIORITY,
+        // Email.PROPERTY_DEMAND_TYPE,
+        // Email.PROPERTY_CLIENT,
+        // Email.PROPERTY_RANGE_ROW + "." + RangeRow.PROPERTY_RANGE,
+        // Email.PROPERTY_ETAT_ATTENTE,
+        // Email.PROPERTY_TAKEN_BY,
+        // Email.PROPERTY_REPLIES,
+//        Email.PROPERTY_ATTACHMENT,
+        // Email.PROPERTY_HISTORY + "." + History.PROPERTY_FAX_TO_MAIL_USER,
+        // Email.PROPERTY_HISTORY + "." + History.PROPERTY_FIELDS,
+        // Email.PROPERTY_EMAIL_GROUP + "." + EmailGroup.PROPERTY_EMAIL)
+        for (Email email : result.getElements()) {
+            //Hibernate.initialize(email.getPriority());
+            //Hibernate.initialize(email.getDemandType());
+            //Hibernate.initialize(email.getClient());
+//            List<RangeRow> rangeRows =3D email.getRangeRow();
+//            if (rangeRows !=3D null) {
+//                for (RangeRow rangeRow : rangeRows) {
+//                    Hibernate.initialize(rangeRow.getRange());
+//                }
+//            }
+            //Hibernate.initialize(email.getWaitingState());
+            //Hibernate.initialize(email.getTakenBy());
+//            Hibernate.initialize(email.getReplies());
+            Hibernate.initialize(email.getAttachment());
+//            Collection<History> histories =3D email.getHistory();
+//            if (histories !=3D null) {
+//                for (History history : histories) {
+//                    Hibernate.initialize(history.getFaxToMailUser());
+//                    Hibernate.initialize(history.getFields());
+//                }
+//            }
             EmailGroup emailGroup =3D email.getEmailGroup();
             if (emailGroup !=3D null) {
                 Hibernate.initialize(emailGroup.getEmail());
@@ -592,6 +782,15 @@
                 }
             }
         }
+
+        long time3 =3D new Date().getTime();
+        if (log.isTraceEnabled()) {
+            log.trace("getEmailForFolder2 after hibernate initializing : " +=
 time3 + " (" + (time3 - time2) + ")");
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("getEmailForFolder2 total : " + (time3 - start));
+        }
+
         return result;
     }
=20
@@ -998,7 +1197,7 @@
=20
         String propertyList;
         if (sum) {
-            propertyList =3D "sum(" + StringUtils.join(properties, "), sum("=
) + ")";
+            propertyList =3D "SUM(" + StringUtils.join(properties, "), SUM("=
) + ")";
         } else {
             propertyList =3D StringUtils.join(properties, ", ");
         }
@@ -1020,7 +1219,7 @@
         query +=3D folderAndStatusCondition;
=20
         if (sum) {
-            query +=3D " group by email." + Email.PROPERTY_TOPIA_ID;
+            query +=3D " GROUP BY email." + Email.PROPERTY_TOPIA_ID;
         }
=20
         List<Object> queryResults =3D findAll(query, args);

Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/ser=
vices/service/EmailServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/=
service/EmailServiceImpl.java	2014-12-11 15:20:39 UTC (rev 727)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/=
service/EmailServiceImpl.java	2014-12-12 12:51:00 UTC (rev 728)
@@ -740,6 +740,7 @@
             EmailTopiaDao dao =3D getPersistenceContext().getEmailDao();
=20
             result =3D dao.getEmailForFolder(filter, folder, page);
+//            result =3D dao.getEmailForFolder2(filter, folder, page);
 //            TopiaQueryBuilderAddCriteriaOrRunQueryStep<Email> builderAddCr=
iteriaOrRunQueryStep =3D
 //                    dao.forMailFolderEquals(folder)
 //                        .addNull(Email.PROPERTY_ARCHIVE_DATE)
@@ -1258,6 +1259,7 @@
             }
             email.setMailFolder(newFolder);
             email.setTakenBy(null);
+            email.setLastAttachmentOpener(null);
=20
             History history =3D historyDao.create(History.PROPERTY_TYPE, His=
toryType.TRANSMISSION,
                                                 History.PROPERTY_FAX_TO_MAIL=
_USER, currentUser,

Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui=
/swing/FaxToMailUIContext.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/FaxToMailUIContext.java	2014-12-11 15:20:39 UTC (rev 727)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/FaxToMailUIContext.java	2014-12-12 12:51:00 UTC (rev 728)
@@ -265,8 +265,7 @@
         FaxToMailServiceContext serviceContext =3D newServiceContext();
         useFolderCache =3D serviceContext.getApplicationConfig().isUseFolder=
Cache();
=20
-        InitFaxToMailService initFaxToMailService =3D
-                serviceContext.getInitFaxToMailService();
+        InitFaxToMailService initFaxToMailService =3D serviceContext.getInit=
FaxToMailService();
         initFaxToMailService.init();
=20
         Map<Class, State> additionalStates =3D Maps.newHashMap();

Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui=
/swing/actions/LoadFolderEmailsAction.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/actions/LoadFolderEmailsAction.java	2014-12-11 15:20:39 UTC (rev 727)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/actions/LoadFolderEmailsAction.java	2014-12-12 12:51:00 UTC (rev 728)
@@ -38,12 +38,9 @@
 import com.franciaflex.faxtomail.ui.swing.util.DemandeTableModel;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.swing.table.filter.TableRowFilterSupport;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jdesktop.swingx.JXTable;
-import org.nuiton.decorator.Decorator;
 import org.nuiton.topia.persistence.TopiaEntities;
 import org.nuiton.util.pagination.PaginationResult;
=20
@@ -104,7 +101,7 @@
                 getContext().getSwingSession().add(dataTable, true);
=20
                 // fixes #5528 filtre sur les colonnes : il manque l'icone q=
ui indique que la colonne est filtr=C3=A9e
-                handler.initTableFilter();
+                handler.updateEmailFilterWithContextEmailFilter();
                 result =3D true;
             }
         }

Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui=
/swing/content/demande/DemandeListTableFilter.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/content/demande/DemandeListTableFilter.java	2014-12-11 15:20:39 UTC (rev 727)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/content/demande/DemandeListTableFilter.java	2014-12-12 12:51:00 UTC (rev 728)
@@ -179,6 +179,7 @@
=20
     @Override
     public Set<Object> distinctValuesForColumn(int i) {
+        log.info("distinctValuesForColumn " + i);
         MailFolder selectedFolder =3D handler.getModel().getSelectedFolder();
         if (selectedFolder =3D=3D null) {
             return null;

Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui=
/swing/content/demande/DemandeListUIHandler.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/content/demande/DemandeListUIHandler.java	2014-12-11 15:20:39 UTC (rev 727)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/content/demande/DemandeListUIHandler.java	2014-12-12 12:51:00 UTC (rev 728)
@@ -27,8 +27,6 @@
 import java.awt.*;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
 import java.awt.event.MouseEvent;
 import java.beans.IntrospectionException;
 import java.beans.PropertyChangeEvent;
@@ -40,10 +38,8 @@
 import java.util.Collection;
 import java.util.Date;
 import java.util.Enumeration;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
=20
 import javax.swing.*;
 import javax.swing.event.ListSelectionEvent;
@@ -56,24 +52,17 @@
 import javax.swing.tree.TreePath;
=20
 import com.franciaflex.faxtomail.persistence.entities.Configuration;
-import com.franciaflex.faxtomail.persistence.entities.DemandType;
 import com.franciaflex.faxtomail.persistence.entities.EmailFilter;
 import com.franciaflex.faxtomail.persistence.entities.MailAction;
-import com.franciaflex.faxtomail.persistence.entities.Priority;
-import com.franciaflex.faxtomail.persistence.entities.Range;
-import com.franciaflex.faxtomail.persistence.entities.WaitingState;
-import com.franciaflex.faxtomail.services.service.EmailService;
 import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext;
 import com.franciaflex.faxtomail.ui.swing.actions.OpenMailFolderChooserFromL=
istAction;
 import com.franciaflex.faxtomail.ui.swing.util.DemandeTableModel;
 import com.google.common.collect.Lists;
 import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.swing.table.filter.FilterChangeListener;
 import jaxx.runtime.swing.table.filter.TableFilter;
 import jaxx.runtime.swing.table.filter.TableRowFilterSupport;
 import jaxx.runtime.validator.swing.SwingValidator;
=20
-import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -109,11 +98,8 @@
 import com.franciaflex.faxtomail.ui.swing.util.PaginationComboModel;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
-import org.nuiton.util.ObjectUtil;
-import org.nuiton.util.beans.BeanUtil;
 import org.nuiton.util.beans.Binder;
 import org.nuiton.util.beans.BinderFactory;
-import org.nuiton.util.pagination.PaginationParameter;
=20
 /**
  * Handler of UI {@link com.franciaflex.faxtomail.ui.swing.content.demande.D=
emandeListUIHandler}.
@@ -195,8 +181,32 @@
=20
         tableFilter =3D new DemandeListTableFilter(dataTable, this);
=20
-        initTableFilter();
+        Decorator<Object> decorator =3D new Decorator<Object>(Object.class) {
+            @Override
+            public String toString(Object bean) {
+                String s =3D null;
+                if (bean !=3D null) {
+                    Decorator<?> decorator =3D getDecorator(bean.getClass(),=
 null);
+                    if (decorator !=3D null) {
+                        s =3D decorator.toString(bean);
+                    }
+                }
+                if (s =3D=3D null) {
+                    s =3D JAXXUtil.getStringValue(bean);
+                }
+                return s;
+            }
+        };
=20
+        TableRowFilterSupport.forFilter(tableFilter)
+                             .searchable(true)
+                             .searchDecorator(decorator)
+                             .useTableRenderers(true)
+                             .setPopupDefaultSize(new Dimension(250, 290))
+                             .apply();
+
+        updateEmailFilterWithContextEmailFilter();
+
         dataTable.getSelectionModel().addListSelectionListener(new ListSelec=
tionListener() {
=20
             @Override
@@ -329,38 +339,11 @@
         loadFolderDemands(folder, nodesByFolder);
     }
=20
-    public void initTableFilter() {
-
+    public void updateEmailFilterWithContextEmailFilter() {
         EmailFilter emailFilter =3D getModel().getEmailFilter();
         emailFilter.removePropertyChangeListener(emailFilterPropertyChangeLi=
stener);
         filtersFromContextToModel();
         emailFilter.addPropertyChangeListener(emailFilterPropertyChangeListe=
ner);
-
-        Decorator<Object> decorator =3D new Decorator<Object>(Object.class) {
-            @Override
-            public String toString(Object bean) {
-                String s =3D null;
-                if (bean !=3D null) {
-                    Decorator<?> decorator =3D getDecorator(bean.getClass(),=
 null);
-                    if (decorator !=3D null) {
-                        s =3D decorator.toString(bean);
-                    }
-                }
-                if (s =3D=3D null) {
-                    s =3D JAXXUtil.getStringValue(bean);
-                }
-                return s;
-            }
-        };
-
-        JTable table =3D TableRowFilterSupport.forFilter(tableFilter)
-                                            .searchable(true)
-                                            .searchDecorator(decorator)
-                                            .useTableRenderers(true)
-                                            .setPopupDefaultSize(new Dimensi=
on(250, 290))
-                                            .apply();
-
-        tableFilter.modelChanged(table.getModel());
     }
=20
     protected void filtersFromContextToModel() {
@@ -466,8 +449,8 @@
                     break;
             }
=20
-            if (log.isDebugEnabled()) {
-                log.debug(i + "property to copy to model's emailfilter : " +=
 property);
+            if (log.isTraceEnabled()) {
+                log.trace(i + "property to copy to model's emailfilter : " +=
 property);
             }
             if (property !=3D null) {
                 try {

Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui=
/swing/util/FaxToMailUIUtil.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/util/FaxToMailUIUtil.java	2014-12-11 15:20:39 UTC (rev 727)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing=
/util/FaxToMailUIUtil.java	2014-12-12 12:51:00 UTC (rev 728)
@@ -54,6 +54,9 @@
 import java.util.regex.Pattern;
=20
 import javax.media.jai.PlanarImage;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.MediaPrintableArea;
 import javax.swing.*;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
@@ -77,6 +80,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jpedal.PdfDecoder;
+import org.jpedal.examples.simpleviewer.paper.PaperSizes;
 import org.jpedal.exception.PdfException;
 import org.jpedal.fonts.FontMappings;
 import org.nuiton.jaxx.application.ApplicationTechnicalException;
@@ -512,6 +516,15 @@
             paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight()=
);
             pf.setPaper(paper);
=20
+//            PaperSizes ps =3D new PaperSizes("A4");
+//            log.info(ps.getAvailablePaperSizes());
+
+//            Paper paper =3D pf.getPaper();
+//            final int paperWidth =3D (int) paper.getImageableWidth();
+//            final int paperHeight =3D (int) paper.getImageableHeight();
+//            final int paperX =3D (int) paper.getImageableX();
+//            final int paperY =3D (int) paper.getImageableY();
+
             printJob.setPrintable(new Printable() {
                 public int print(Graphics graphics, PageFormat pageFormat, i=
nt pageIndex) throws PrinterException {
                     try {
@@ -520,6 +533,14 @@
                         }
                         BufferedImage image =3D pdfDecoder.getPageAsImage(pa=
geIndex + 1);
                         graphics.drawImage(image, 0, 0, image.getWidth(), im=
age.getHeight(), null);
+
+//                        graphics.drawImage(image,
+//                                           paperX,
+//                                           paperY,
+//                                           Math.min(paperWidth, image.getW=
idth()),
+//                                           Math.min(paperHeight, image.get=
Height()),
+//                                           null);
+
                         return PAGE_EXISTS;
=20
                     } catch (Exception e) {
@@ -530,9 +551,17 @@
             });
=20
             // Send print job to default printer
+//            PrintRequestAttributeSet attributes =3D new HashPrintRequestAt=
tributeSet();
+//            float xmargin =3D 0.5f;
+//            float ymargin =3D 0.5f;
+//            float w =3D 595;
+//            float h =3D 842;
+//            attributes.add(new MediaPrintableArea(xmargin, ymargin, w - 2*=
xmargin, h - 2*ymargin, MediaPrintableArea.INCH));
+//            result =3D defaultPrinter || printJob.printDialog(attributes);
             result =3D defaultPrinter || printJob.printDialog();
             if (result) {
                 printJob.print();
+//                printJob.print(attributes);
             }
=20
=20


--===============1496690942245912572==--


