r503 - in trunk: faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities faxtomail-persistence/src/main/xmi faxtomail-service/src/main/java/com/franciaflex/faxtomail/services faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande faxtomail-ui-swing/src/main/java/com/franciaflex/faxtom
Author: echatellier Date: 2014-08-08 16:20:13 +0200 (Fri, 08 Aug 2014) New Revision: 503 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/503 Log: fixes #5536: il faut pouvoir faire un d?\195?\169plac?\195?\169 depuis la liste via le menu contextuel Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIModel.java Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/MailFolderImpl.java trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/MailFolderTopiaDao.java trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceContext.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveFromListAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeFromListAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.css trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.jaxx 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/content/demande/DemandeListUIModel.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/QuantitiesByRangeUIModel.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUI.jaxx trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/MailFolderImpl.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/MailFolderImpl.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/MailFolderImpl.java 2014-08-08 14:20:13 UTC (rev 503) @@ -6,27 +6,37 @@ */ public class MailFolderImpl extends MailFolderAbstract { - protected Boolean folderReadable; - protected Boolean folderWritable; + protected transient boolean folderReadable; + protected transient boolean folderWritable; + protected transient boolean folderMoveable; @Override - public Boolean isFolderReadable() { + public boolean isFolderReadable() { return folderReadable; } @Override - public void setFolderReadable(Boolean folderReadable) { + public void setFolderReadable(boolean folderReadable) { this.folderReadable = folderReadable; } @Override - public Boolean isFolderWritable() { + public boolean isFolderWritable() { return folderWritable; } @Override - public void setFolderWritable(Boolean folderWritable) { + public void setFolderWritable(boolean folderWritable) { this.folderWritable = folderWritable; } + @Override + public void setFolderMoveable(boolean moveable) { + this.folderMoveable = moveable; + } + + @Override + public boolean isFolderMoveable() { + return folderMoveable; + } } Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/MailFolderTopiaDao.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/MailFolderTopiaDao.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/MailFolderTopiaDao.java 2014-08-08 14:20:13 UTC (rev 503) @@ -24,13 +24,10 @@ * #L% */ -import com.google.common.collect.Collections2; import com.google.common.collect.Maps; -import org.apache.commons.lang3.StringUtils; import java.util.Collection; import java.util.HashMap; -import java.util.List; public class MailFolderTopiaDao extends AbstractMailFolderTopiaDao<MailFolder> { @@ -65,5 +62,14 @@ Collection<MailFolder> folders = findAll(query, map); return folders; } + + public Collection<MailFolder> getMoveableFolders(FaxToMailUser user) { + String query = newFromClause("mf") + " where :user in elements(mf.moveRightUsers) or exists (from mf.moveRightGroups g where g in (:groups))"; + HashMap<String, Object> map = Maps.newHashMap(); + map.put("user", user); + map.put("groups", user.getUserGroups()); + Collection<MailFolder> folders = findAll(query, map); + return folders; + } } //MailFolderTopiaDao Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo =================================================================== (Binary files differ) Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceContext.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceContext.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceContext.java 2014-08-08 14:20:13 UTC (rev 503) @@ -112,6 +112,7 @@ } else { if (persistenceContext == null) { persistenceContext = topiaApplicationContext.newPersistenceContext(); + System.out.println("Open new session" + Thread.currentThread().getName()); } return persistenceContext; } @@ -254,6 +255,7 @@ if (persistenceContext != null) { persistenceContext.close(); persistenceContext = null; + System.out.println("Close session" + Thread.currentThread().getName()); } } } Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java 2014-08-08 14:20:13 UTC (rev 503) @@ -24,16 +24,18 @@ * #L% */ +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.franciaflex.faxtomail.persistence.entities.DemandType; import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.MailFilter; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.services.FaxToMailService; -import java.util.Collection; -import java.util.List; -import java.util.Map; - /** * @author Kevin Morin (Code Lutin) */ @@ -54,7 +56,7 @@ List<MailFolder> getMailFolders(Collection<String> ids); - Collection<MailFolder> getFoldersWithEtatAttente(EtatAttente etatAttente); + Collection<MailFolder> getFoldersWithEtatAttenteAndDemandType(Set<EtatAttente> etatAttentes, Set<DemandType> demandTypes); Map<String, Long> getMailFoldersUsage(); Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java 2014-08-08 14:20:13 UTC (rev 503) @@ -26,30 +26,29 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import com.franciaflex.faxtomail.persistence.entities.DemandType; -import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; - -import com.franciaflex.faxtomail.persistence.entities.MailField; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.Predicate; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Hibernate; import org.nuiton.util.pagination.PaginationParameter; +import com.franciaflex.faxtomail.persistence.entities.DemandType; import com.franciaflex.faxtomail.persistence.entities.EmailTopiaDao; import com.franciaflex.faxtomail.persistence.entities.EtatAttente; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.MailFilter; import com.franciaflex.faxtomail.persistence.entities.MailFilterTopiaDao; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.persistence.entities.MailFolderTopiaDao; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.google.common.collect.Collections2; /** * @author kmorin - kmorin@codelutin.com @@ -164,31 +163,48 @@ } @Override - public void fetchFolderAttributes(MailFolder folder) { - Hibernate.initialize(folder.getFolderTableColumns()); - Hibernate.initialize(folder.getRanges()); - Hibernate.initialize(folder.getReplyAddresses()); - Hibernate.initialize(folder.getReplyDomains()); - Hibernate.initialize(folder.getDemandTypes()); + public List<MailFolder> getRootMailFoldersWithMoveRights(FaxToMailUser user) { + MailFolderTopiaDao dao = getPersistenceContext().getMailFolderDao(); - if (folder.sizeEtatAttentes() > 0) { - for (EtatAttente etatAttente : folder.getEtatAttentes()) { - Hibernate.initialize(etatAttente.getInvalidFormDisabledActions()); - Hibernate.initialize(etatAttente.getValidFormDisabledActions()); + List<MailFolder> folders = new ArrayList<>(dao.getMoveableFolders(user)); + // copy the list to be able to remove the folders whose parent is already in the list + List<MailFolder> result = new ArrayList<>(folders); + + for (MailFolder folder : folders) { + MailFolder f = folder; + while (f.getParent() != null) { + f = f.getParent(); + + // if the parent is already in the readable roots, remove the current folder from the roots + if (result.contains(f)) { + result.remove(folder); + folder = null; + break; + } + + fetchFolderAttributes(f); } + + if (folder != null) { + browseMoveableFolders(folder, result, user); + } } + return result; } - @Override - public List<MailFolder> getRootMailFoldersWithMoveRights(FaxToMailUser user) { - List<MailFolder> rootFolders = getRootMailFolders(); - List<MailFolder> result = new ArrayList<>(); + protected void browseMoveableFolders(MailFolder folder, List<MailFolder> readableRoots, FaxToMailUser user) { + folder.setFolderMoveable(true); - for (MailFolder folder : rootFolders) { - findMoveFolders(folder, user, result); + if (folder.isChildrenNotEmpty()) { + for (MailFolder child : folder.getChildren()) { + // if the child is in the readable roots, rmeove it to merge the branches + if (!readableRoots.remove(child)) { + browseMoveableFolders(child, readableRoots, user); + } + } } - return result; + fetchFolderAttributes(folder); } protected void findMoveFolders(MailFolder folder, FaxToMailUser user, List<MailFolder> folders) { @@ -204,20 +220,43 @@ } @Override + public void fetchFolderAttributes(MailFolder folder) { + Hibernate.initialize(folder.getFolderTableColumns()); + Hibernate.initialize(folder.getRanges()); + Hibernate.initialize(folder.getReplyAddresses()); + Hibernate.initialize(folder.getReplyDomains()); + + if (folder.sizeEtatAttentes() > 0) { + for (EtatAttente etatAttente : folder.getEtatAttentes()) { + Hibernate.initialize(etatAttente.getInvalidFormDisabledActions()); + Hibernate.initialize(etatAttente.getValidFormDisabledActions()); + } + } + + Hibernate.initialize(folder.getDemandTypes()); + } + + @Override public List<MailFolder> getMailFolders(Collection<String> ids) { MailFolderTopiaDao dao = getPersistenceContext().getMailFolderDao(); return new ArrayList<MailFolder>(dao.forTopiaIdIn(ids).findAll()); } + /** + * Retourne les dossiers qui ont l'ensemble des etats d'attente et l'ensemble des types de + * demande compatible avec ceux en argument. + */ @Override - public Collection<MailFolder> getFoldersWithEtatAttente(EtatAttente etatAttente) { - Collection<MailFolder> result = new HashSet<>(); + public Set<MailFolder> getFoldersWithEtatAttenteAndDemandType(Set<EtatAttente> requiredEtatAttentes, Set<DemandType> requiredDemandTypes) { + Set<MailFolder> result = new HashSet<>(); MailFolderTopiaDao dao = getPersistenceContext().getMailFolderDao(); List<MailFolder> roots = dao.forParentEquals(null).findAll(); for (MailFolder root : roots) { - result.addAll(getFoldersWithEtatAttente(root, new HashSet<EtatAttente>(), etatAttente)); + Collection<MailFolder> mailFolders = getFoldersWithEtatAttente(root, new HashSet<EtatAttente>(), + new HashSet<DemandType>(), requiredEtatAttentes, requiredDemandTypes); + result.addAll(mailFolders); } return result; @@ -225,23 +264,45 @@ protected Collection<MailFolder> getFoldersWithEtatAttente(MailFolder folder, Collection<EtatAttente> parentEtatAttente, - EtatAttente etatAttente) { + Collection<DemandType> parentDemandType, + Set<EtatAttente> requiredEtatAttentes, + Set<DemandType> requiredDemandTypes) { Collection<EtatAttente> etatAttentes = folder.getEtatAttentes(); if (CollectionUtils.isEmpty(etatAttentes)) { etatAttentes = parentEtatAttente; } else { parentEtatAttente = etatAttentes; } + Collection<DemandType> demandTypes = folder.getDemandTypes(); + if (CollectionUtils.isEmpty(demandTypes)) { + demandTypes = parentDemandType; + } else { + parentDemandType = demandTypes; + } + // resursion Collection<MailFolder> result = new HashSet<>(); Collection<MailFolder> children = folder.getChildren(); if (children != null) { for (MailFolder child : children) { - result.addAll(getFoldersWithEtatAttente(child, parentEtatAttente, etatAttente)); + Collection<MailFolder> subMailFolders = getFoldersWithEtatAttente(child, + parentEtatAttente, parentDemandType, requiredEtatAttentes, requiredDemandTypes); + result.addAll(subMailFolders); } } - if (etatAttentes.contains(etatAttente)) { + // pour qu'un dossier soit sélectionné il faut que les dossiers ait des etat d'attentes (ou ses parents) + // que les etats d'attente requis ne soit pas vide + // ET + // qu'un dossier ait des types de demandes et que les types de demande requis ne soit pas + // vide + if ((CollectionUtils.isEmpty(etatAttentes) || + CollectionUtils.isEmpty(requiredEtatAttentes) || + etatAttentes.containsAll(requiredEtatAttentes)) + && + CollectionUtils.isEmpty(demandTypes) || + CollectionUtils.isEmpty(requiredDemandTypes) || + demandTypes.containsAll(requiredDemandTypes)) { result.add(folder); } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveFromListAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveFromListAction.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveFromListAction.java 2014-08-08 14:20:13 UTC (rev 503) @@ -61,7 +61,7 @@ @Override public void doAction() throws Exception { - List<DemandeUIModel> currentEmails = getModel().getCurrentEmails(); + List<DemandeUIModel> currentEmails = getModel().getSelectedEmails(); for (DemandeUIModel email : currentEmails) { email.setArchiveDate(new Date()); email.setDemandStatus(DemandStatus.ARCHIVED); @@ -75,12 +75,7 @@ @Override public void postSuccessAction() { super.postSuccessAction(); - getModel().removeEmails(getModel().getCurrentEmails()); - getModel().setCurrentEmails(null); + getModel().removeEmails(getModel().getSelectedEmails()); + getModel().setSelectedEmails(null); } - - @Override - protected void releaseAction() { - super.releaseAction(); - } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeFromListAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeFromListAction.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeFromListAction.java 2014-08-08 14:20:13 UTC (rev 503) @@ -53,7 +53,7 @@ public void doAction() throws Exception { FaxToMailUIContext context = getContext(); - for (DemandeUIModel model : getModel().getCurrentEmails()) { + for (DemandeUIModel model : getModel().getSelectedEmails()) { String topiaId = model.getTopiaId(); FaxToMailServiceContext serviceContext = context.newServiceContext(); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java 2014-08-08 14:20:13 UTC (rev 503) @@ -100,7 +100,7 @@ FaxToMailUser currentUser = getContext().getCurrentUser(); MailFolder folder = currentEmail.getMailFolder(); - if (currentEmail.getArchiveDate() != null || !Boolean.TRUE.equals(folder.isFolderWritable())) { + if (currentEmail.getArchiveDate() != null || !folder.isFolderWritable()) { currentEmail.setEditable(false); } else if (takenBy != null && !currentUser.equals(takenBy)) { Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java 2014-08-08 14:20:13 UTC (rev 503) @@ -24,22 +24,25 @@ * #L% */ +import static org.nuiton.i18n.I18n.t; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXUtil; + import com.franciaflex.faxtomail.persistence.entities.DemandStatus; +import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUI; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUI; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandesUI; import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUI; import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUIHandler; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXUtil; +import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUIModel; -import static org.nuiton.i18n.I18n.t; - /** * @author Kevin Morin (Code Lutin) * */ -public class TransmitAction extends AbstractFaxToMailAction<DemandeUIModel, MailFolderChooserUI, MailFolderChooserUIHandler> { +public class TransmitAction extends AbstractFaxToMailAction<MailFolderChooserUIModel, MailFolderChooserUI, MailFolderChooserUIHandler> { public TransmitAction(MailFolderChooserUIHandler handler) { super(handler, false); @@ -48,14 +51,36 @@ @Override public void doAction() throws Exception { - DemandeUIModel model = getModel(); - model.setDemandStatus(DemandStatus.QUALIFIED); - model.setTakenBy(null); + MailFolderChooserUIModel model = getModel(); + for (DemandeUIModel demande : model.getDemandeUIModels()) { + demande.setDemandStatus(DemandStatus.QUALIFIED); + demande.setMailFolder(model.getMailFolder()); + demande.setTakenBy(null); + } - DemandesUI parentUI = (DemandesUI) getUI().getContextValue(JAXXContext.class, JAXXUtil.PARENT); - DemandeUI demandeUI = (DemandeUI) parentUI.getDemandsTabPane().getSelectedComponent(); - getContext().getActionEngine().runInternalAction(demandeUI.getHandler(), - SaveDemandeAndExitAction.class); + // suivant la condition on est soit dans le cas d'une edition de demande + // soit dans le cas d'une action contextuel depuis la liste des demandes + DemandeListUI parentDemandeListUI = (DemandeListUI)getUI().getContextValue(JAXXContext.class, JAXXUtil.PARENT); + if (parentDemandeListUI != null) { + // appel du service pour sauver les mails + // mais il faudrai sauver tous les mails d'un seul coup + for (DemandeUIModel demande : model.getDemandeUIModels()) { + String topiaId = demande.getTopiaId(); + Email email = getContext().newServiceContext().getEmailService().getEmailById(topiaId); + email = demande.toEntity(email); + getContext().newServiceContext().getEmailService().saveEmail(email, null, Email.PROPERTY_MAIL_FOLDER); + } + + // appel de l'action de rechargement de la liste + getContext().getActionEngine().runInternalAction(parentDemandeListUI.getHandler(), + LoadFolderEmailsAction.class); + + } else { + DemandesUI parentUI = (DemandesUI) getUI().getContextValue(JAXXContext.class, JAXXUtil.PARENT); + DemandeUI demandeUI = (DemandeUI) parentUI.getDemandsTabPane().getSelectedComponent(); + getContext().getActionEngine().runInternalAction(demandeUI.getHandler(), + SaveDemandeAndExitAction.class); + } } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.css =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.css 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.css 2014-08-08 14:20:13 UTC (rev 503) @@ -113,6 +113,13 @@ enabled: { model.isArchiveEnabled() }; } +#moveMenu { + actionIcon: transmit; + text: "faxtomail.demandeList.action.transmit"; + toolTipText: "faxtomail.demandeList.action.transmit.tip"; + enabled: { model.isTransmitEnabled() }; +} + #totalDemandCountLabel { text: "faxtomail.demandeList.totalCount"; } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.jaxx 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.jaxx 2014-08-08 14:20:13 UTC (rev 503) @@ -64,6 +64,8 @@ onActionPerformed='handler.reply()'/> <JMenuItem id='archiveMenu' onActionPerformed='handler.archive()'/> + <JMenuItem id='moveMenu' + onActionPerformed='handler.transmit()'/> </JPopupMenu> <JSplitPane constraints='BorderLayout.CENTER' id="mainSplitPane"> Modified: 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/content/demande/DemandeListUIHandler.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2014-08-08 14:20:13 UTC (rev 503) @@ -32,7 +32,6 @@ import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.io.ObjectInputStream.GetField; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -58,6 +57,7 @@ import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; +import jaxx.runtime.JAXXContext; import jaxx.runtime.JAXXUtil; import jaxx.runtime.validator.swing.SwingValidator; @@ -68,6 +68,7 @@ import org.jdesktop.swingx.decorator.ComponentAdapter; import org.jdesktop.swingx.decorator.HighlightPredicate; import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; +import org.nuiton.jaxx.application.swing.util.CloseableUI; import com.ezware.oxbow.swingbits.table.filter.DistinctColumnItem; import com.ezware.oxbow.swingbits.table.filter.ITableFilter; @@ -88,11 +89,14 @@ import com.franciaflex.faxtomail.ui.swing.actions.ComputeQuantitiesByRangeAction; import com.franciaflex.faxtomail.ui.swing.actions.LoadFolderEmailsAction; import com.franciaflex.faxtomail.ui.swing.actions.PrintOnDefaultPrinterAction; +import com.franciaflex.faxtomail.ui.swing.actions.SaveAndOpenDialogAction; +import com.franciaflex.faxtomail.ui.swing.actions.SaveDemandeAndExitAction; import com.franciaflex.faxtomail.ui.swing.actions.SaveDemandeFromListAction; import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUI; import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUIModel; +import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUI; +import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUIModel; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailDemandListHandler; -import org.nuiton.jaxx.application.swing.util.CloseableUI; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import com.franciaflex.faxtomail.ui.swing.util.FolderTreeNode; import com.google.common.collect.HashMultimap; @@ -117,8 +121,7 @@ public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); - if (Email.PROPERTY_PRIORITY.equals(propertyName) - || Email.PROPERTY_TAKEN_BY.equals(propertyName)) { + if (Email.PROPERTY_PRIORITY.equals(propertyName)) { if (evt.getNewValue() != null || evt.getOldValue() != null) { SaveDemandeFromListAction saveAction = getContext().getActionFactory().createLogicAction(DemandeListUIHandler.this, @@ -187,7 +190,7 @@ DemandeListUIModel model = getModel(); if (source.isSelectionEmpty()) { - model.setCurrentEmails(null); + model.setSelectedEmails(null); } else { List<DemandeUIModel> selectedRows = new ArrayList<DemandeUIModel>(); AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); @@ -196,7 +199,7 @@ selectedRows.add(dataTableModel.getEntry(i)); } } - model.setCurrentEmails(selectedRows); + model.setSelectedEmails(selectedRows); } } }); @@ -232,7 +235,7 @@ } }); - model.addPropertyChangeListener(DemandeListUIModel.PROPERTY_CURRENT_EMAILS, new PropertyChangeListener() { + model.addPropertyChangeListener(DemandeListUIModel.PROPERTY_SELECTED_EMAILS, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { @@ -466,11 +469,20 @@ int selectedRowCount = getUI().getDataTable().getSelectedRowCount(); DemandeListUIModel model = getModel(); - model.setReplyEnabled(selectedRowCount == 1 && model.getCurrentEmails().get(0).isEditable()); + model.setReplyEnabled(selectedRowCount == 1 && model.getSelectedEmails().get(0).isEditable()); model.setArchiveEnabled(selectedRowCount > 1 || - selectedRowCount > 0 && model.getCurrentEmails().get(0).isEditable()); + selectedRowCount > 0 && model.getSelectedEmails().get(0).isEditable()); + model.setTransmitEnabled(selectedRowCount > 1 || + selectedRowCount > 0 && model.getSelectedEmails().get(0).isEditable()); } + /** + * During rigth clic, auto-select located under mouse position (not done by default by java) and + * display contextual menu. + * + * @param e event + * @param popup popup menu to display + */ public void autoSelectNodeInTree(MouseEvent e, JPopupMenu popup) { boolean rightClick = SwingUtilities.isRightMouseButton(e); @@ -541,7 +553,7 @@ Multimap<DemandeUIModel, AttachmentFile> attachmentToPrints = HashMultimap.create(); - for (DemandeUIModel demandeUIModel : model.getCurrentEmails()) { + for (DemandeUIModel demandeUIModel : model.getSelectedEmails()) { for (Attachment attachment : demandeUIModel.getAttachment()) { // force lazy loading @@ -563,7 +575,7 @@ } public void reply() { - DemandeUIModel demand = getModel().getCurrentEmails().get(0); + DemandeUIModel demand = getModel().getSelectedEmails().get(0); getContext().setCurrentEmail(demand); ReplyFormUI dialogContent = new ReplyFormUI(ui); @@ -587,4 +599,16 @@ ArchiveFromListAction.class); getContext().getActionEngine().runAction(saveAction); } + + /** + * Display move popup for user to chose where to move all selected demands. + */ + public void transmit() { + List<DemandeUIModel> selectedEmails = getModel().getSelectedEmails(); + MailFolderChooserUIModel model = new MailFolderChooserUIModel(); + model.setDemandeUIModels(selectedEmails); + MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, model); + + openDialog(dialogContent, t("faxtomail.chooseMailFolder.title"), new Dimension(350, 500)); + } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIModel.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIModel.java 2014-08-08 14:20:13 UTC (rev 503) @@ -43,7 +43,7 @@ public static final String PROPERTY_PAGINATION_PARAMETER = "paginationParameter"; public static final String PROPERTY_PAGINATION_RESULT = "paginationResult"; public static final String PROPERTY_FILTERED_EMAILS = "filteredEmails"; - public static final String PROPERTY_CURRENT_EMAILS = "currentEmails"; + public static final String PROPERTY_SELECTED_EMAILS = "selectedEmails"; public static final String PROPERTY_EMAIL_NB = "emailNb"; public static final String PROPERTY_SELECTED_FOLDER = "selectedFolder"; public static final String PROPERTY_QUOTATION_NB = "quotationNb"; @@ -51,6 +51,7 @@ public static final String PROPERTY_SAV_NB = "savNb"; public static final String PROPERTY_REPLY_ENABLED = "replyEnabled"; public static final String PROPERTY_ARCHIVE_ENABLED = "archiveEnabled"; + public static final String PROPERTY_TRANSMIT_ENABLED = "transmitEnabled"; public static final String PROPERTY_COMPUTE_QUANTITIES_BY_RANGE_ENABLED = "computeQuantitiesByRangeEnabled"; public static final String PROPERTY_NEW_DEMAND_ENABLED = "newDemandEnabled"; public static final String PROPERTY_RESULT_PER_PAGE = "resultPerPage"; @@ -67,7 +68,8 @@ protected List<DemandeUIModel> filteredEmails; - protected List<DemandeUIModel> currentEmails; + /** Currently selected email in table. */ + protected List<DemandeUIModel> selectedEmails; protected MailFolder selectedFolder; @@ -75,6 +77,8 @@ protected boolean archiveEnabled; + protected boolean transmitEnabled; + protected boolean computeQuantitiesByRangeEnabled; protected boolean newDemandEnabled; @@ -141,14 +145,14 @@ firePropertyChange(PROPERTY_EMAIL_NB, oldValue, newValue); } - public List<DemandeUIModel> getCurrentEmails() { - return currentEmails; + public List<DemandeUIModel> getSelectedEmails() { + return selectedEmails; } - public void setCurrentEmails(List<DemandeUIModel> currentEmails) { - Object oldValue = getCurrentEmails(); - this.currentEmails = currentEmails; - firePropertyChange(PROPERTY_CURRENT_EMAILS, oldValue, currentEmails); + public void setSelectedEmails(List<DemandeUIModel> selectedEmails) { + Object oldValue = getSelectedEmails(); + this.selectedEmails = selectedEmails; + firePropertyChange(PROPERTY_SELECTED_EMAILS, oldValue, selectedEmails); } public int getEmailNb() { @@ -207,7 +211,17 @@ this.archiveEnabled = archiveEnabled; firePropertyChange(PROPERTY_ARCHIVE_ENABLED, oldValue, archiveEnabled); } + + public boolean isTransmitEnabled() { + return transmitEnabled; + } + public void setTransmitEnabled(boolean transmitEnabled) { + Object oldValue = this.transmitEnabled; + this.transmitEnabled = transmitEnabled; + firePropertyChange(PROPERTY_TRANSMIT_ENABLED, oldValue, transmitEnabled); + } + public boolean isComputeQuantitiesByRangeEnabled() { return computeQuantitiesByRangeEnabled; } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java 2014-08-08 14:20:13 UTC (rev 503) @@ -24,7 +24,36 @@ * #L% */ +import static org.nuiton.i18n.I18n.t; + +import java.awt.Component; +import java.awt.Dimension; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Collections; +import java.util.List; + +import javax.swing.DefaultSingleSelectionModel; +import javax.swing.JComponent; +import javax.swing.JTabbedPane; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXUtil; +import jaxx.runtime.validator.swing.SwingValidator; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; +import org.nuiton.jaxx.application.swing.ApplicationUI; +import org.nuiton.jaxx.application.swing.tab.CustomTab; +import org.nuiton.jaxx.application.swing.tab.DelegateTabContainerHandler; +import org.nuiton.jaxx.application.swing.tab.TabContainerHandler; +import org.nuiton.jaxx.application.swing.tab.TabContentModel; +import org.nuiton.jaxx.application.swing.tab.TabHandler; +import org.nuiton.jaxx.application.swing.util.CloseableUI; + import com.franciaflex.faxtomail.persistence.entities.Configuration; +import com.franciaflex.faxtomail.persistence.entities.DemandStatus; import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.MailAction; @@ -38,30 +67,9 @@ import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUIModel; import com.franciaflex.faxtomail.ui.swing.content.search.SearchToGroupUI; import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUI; +import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUIModel; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailUIHandler; -import org.nuiton.jaxx.application.swing.util.CloseableUI; -import jaxx.runtime.JAXXUtil; -import jaxx.runtime.validator.swing.SwingValidator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; -import org.nuiton.jaxx.application.swing.ApplicationUI; -import org.nuiton.jaxx.application.swing.tab.CustomTab; -import org.nuiton.jaxx.application.swing.tab.DelegateTabContainerHandler; -import org.nuiton.jaxx.application.swing.tab.TabContainerHandler; -import org.nuiton.jaxx.application.swing.tab.TabContentModel; -import org.nuiton.jaxx.application.swing.tab.TabHandler; - -import javax.swing.*; - -import java.awt.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import static org.nuiton.i18n.I18n.t; - /** * @author Kevin Morin (Code Lutin) * @@ -330,7 +338,10 @@ closeButtonPopups(); DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); - MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, demandeUI.getModel()); + List<DemandeUIModel> demandes = Collections.singletonList(demandeUI.getModel()); + MailFolderChooserUIModel model = new MailFolderChooserUIModel(); + model.setDemandeUIModels(demandes); + MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, model); SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), true, dialogContent, Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/QuantitiesByRangeUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/QuantitiesByRangeUIModel.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/QuantitiesByRangeUIModel.java 2014-08-08 14:20:13 UTC (rev 503) @@ -24,18 +24,19 @@ * #L% */ -import com.franciaflex.faxtomail.persistence.entities.MailFolder; -import org.jdesktop.beans.AbstractSerializableBean; - import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.jdesktop.beans.AbstractBean; + +import com.franciaflex.faxtomail.persistence.entities.MailFolder; + /** * @author Kevin Morin (Code Lutin) * */ -public class QuantitiesByRangeUIModel extends AbstractSerializableBean { +public class QuantitiesByRangeUIModel extends AbstractBean { public static final String PROPERTY_ROOT_FOLDER = "rootFolder"; public static final String PROPERTY_RANGE_ROWS = "rangeRows"; Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUI.jaxx 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUI.jaxx 2014-08-08 14:20:13 UTC (rev 503) @@ -22,11 +22,9 @@ #L% --> <JPanel id='mailFolderChooser' layout='{new BorderLayout()}' - implements='com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI<com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel, MailFolderChooserUIHandler>'> + implements='com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI<MailFolderChooserUIModel, MailFolderChooserUIHandler>'> <import> - com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel - com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil @@ -34,15 +32,13 @@ </import> <script><![CDATA[ - - public MailFolderChooserUI(FaxToMailUI parentUI, DemandeUIModel model) { + public MailFolderChooserUI(FaxToMailUI parentUI, MailFolderChooserUIModel model) { FaxToMailUIUtil.setParentUI(this, parentUI); setContextValue(model); } - ]]></script> - <DemandeUIModel id='model' javaBean='getContextValue(DemandeUIModel.class)'/> + <MailFolderChooserUIModel id='model' initializer='getContextValue(MailFolderChooserUIModel.class)' /> <JLabel id="message" constraints='BorderLayout.NORTH'/> Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIHandler.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIHandler.java 2014-08-08 14:20:13 UTC (rev 503) @@ -24,32 +24,38 @@ * #L% */ +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.swing.JComponent; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; + +import jaxx.runtime.validator.swing.SwingValidator; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.application.swing.util.Cancelable; + +import com.franciaflex.faxtomail.persistence.entities.DemandType; import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.services.FaxToMailServiceContext; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailUIHandler; -import org.nuiton.jaxx.application.swing.util.Cancelable; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import com.franciaflex.faxtomail.ui.swing.util.FolderTreeNode; -import jaxx.runtime.validator.swing.SwingValidator; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import javax.swing.*; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultMutableTreeNode; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; - /** * @author Kevin Morin (Code Lutin) * */ -public class MailFolderChooserUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, MailFolderChooserUI> implements Cancelable { +public class MailFolderChooserUIHandler extends AbstractFaxToMailUIHandler<MailFolderChooserUIModel, MailFolderChooserUI> implements Cancelable { private static final Log log = LogFactory.getLog(MailFolderChooserUIHandler.class); @@ -57,15 +63,32 @@ public void afterInit(MailFolderChooserUI mailFolderChooserUI) { initUI(mailFolderChooserUI); - DemandeUIModel model = getModel(); + MailFolderChooserUIModel model = getModel(); - EtatAttente etatAttente = model.getEtatAttente(); - final Collection<MailFolder> foldersWithEtatAttente; + // fixme echatellier 20140808 : pour le dossier courant, on prend celui du premier mai + // ce n'est pas forcement très correct pour la recherche car les demandes peuvent + // provenir de dossier différents + MailFolder currentMailFolder = model.getDemandeUIModels().get(0).getMailFolder(); + + // on recupere seulement les dossiers qui accepte l'ensemble des états d'attentes + // et des types de demande de l'ensemble des demandes + Set<EtatAttente> allEtatsAttentes = new HashSet<EtatAttente>(); + Set<DemandType> allDemandTypes = new HashSet<DemandType>(); + for (DemandeUIModel demande : model.getDemandeUIModels()) { + if (demande.getEtatAttente() != null) { + allEtatsAttentes.add(demande.getEtatAttente()); + } + if (demande.getDemandType() != null) { + allDemandTypes.add(demande.getDemandType()); + } + } + FaxToMailServiceContext serviceContext = getContext().newServiceContext(); - if (etatAttente != null) { - foldersWithEtatAttente = serviceContext.getMailFolderService().getFoldersWithEtatAttente(etatAttente); - } else { - foldersWithEtatAttente = new HashSet<MailFolder>(); + Collection<MailFolder> foldersWithEtatAttente = null; + // foldersWithEtatAttente reste à null dans le cas ou l'arbre ne doit pas être filtré + // sinon l'appel peut renvoyer une liste de vide dans le cas où aucun dossier n'est selectionnable + if (!allEtatsAttentes.isEmpty() || !allDemandTypes.isEmpty()) { + foldersWithEtatAttente = serviceContext.getMailFolderService().getFoldersWithEtatAttenteAndDemandType(allEtatsAttentes, allDemandTypes); } // init tree @@ -75,7 +98,6 @@ Map<MailFolder, FolderTreeNode> nodesByFolder = FaxToMailUIUtil.initFolderTree(getContext(), navigationTree, folders, false); - MailFolder currentFolder = getModel().getMailFolder(); for (MailFolder folder : nodesByFolder.keySet()) { DefaultMutableTreeNode node = nodesByFolder.get(folder); @@ -84,15 +106,13 @@ FolderTreeNode folderTreeNode = (FolderTreeNode) node; MailFolder folderWithAllowMoveDemandIntoFolder = folder; - while (folderWithAllowMoveDemandIntoFolder.getAllowMoveDemandIntoFolder() == null - && folderWithAllowMoveDemandIntoFolder.getParent() != null) { - folderWithAllowMoveDemandIntoFolder = folderWithAllowMoveDemandIntoFolder.getParent(); - } - - folderTreeNode.setCanSelect(!currentFolder.equals(folder) && - Boolean.TRUE.equals(folderWithAllowMoveDemandIntoFolder.getAllowMoveDemandIntoFolder()) && - (CollectionUtils.isEmpty(foldersWithEtatAttente) - || foldersWithEtatAttente.contains(folder))); + // le dossier n'est pas grisé si: + // - le n'est pas le dossier courrant + // - l'utilsateur à les droits sur le dossier + // - le dossier cible à les mêmes etatAttente/typeDemande que toutes les demandes à bouger + folderTreeNode.setCanSelect(!currentMailFolder.equals(folder) && + folderWithAllowMoveDemandIntoFolder.isFolderMoveable() && + (foldersWithEtatAttente == null || foldersWithEtatAttente.contains(folder))); } } @@ -107,6 +127,9 @@ getModel().setMailFolder(folder); } }); + + // fix jaxx binding, apparement, il faut lui refaire un set null + getModel().setMailFolder(null); } @Override @@ -114,7 +137,7 @@ } @Override - public SwingValidator<DemandeUIModel> getValidator() { + public SwingValidator<MailFolderChooserUIModel> getValidator() { return null; } Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIModel.java (rev 0) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIModel.java 2014-08-08 14:20:13 UTC (rev 503) @@ -0,0 +1,68 @@ +package com.franciaflex.faxtomail.ui.swing.content.transmit; + +/* + * #%L + * FaxToMail :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import java.util.List; + +import org.jdesktop.beans.AbstractBean; + +import com.franciaflex.faxtomail.persistence.entities.MailFolder; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; + +/** + * Model for mail folder chooser UI. + * + * @author Eric Chatellier + */ +public class MailFolderChooserUIModel extends AbstractBean { + + protected static final String PROPERTY_MAIL_FOLDER = "mailFolder"; + protected static final String PROPERTY_DEMANDE_U_I_MODELS = "demandeUIModels"; + + /** Le dossier de destination du mail après validation de l'action .*/ + protected MailFolder mailFolder; + + /** L'ensemble des demandes concernées par le déplacement. */ + protected List<DemandeUIModel> demandeUIModels; + + public void setMailFolder(MailFolder mailFolder) { + MailFolder oldValue = this.mailFolder; + this.mailFolder = mailFolder; + firePropertyChange(PROPERTY_MAIL_FOLDER, oldValue, mailFolder); + } + + public MailFolder getMailFolder() { + return mailFolder; + } + + public void setDemandeUIModels(List<DemandeUIModel> demandeUIModels) { + this.demandeUIModels = demandeUIModels; + firePropertyChange(PROPERTY_DEMANDE_U_I_MODELS, null, demandeUIModels); + } + + public List<DemandeUIModel> getDemandeUIModels() { + return demandeUIModels; + } +} Property changes on: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIModel.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-08-08 14:20:13 UTC (rev 503) @@ -281,6 +281,9 @@ }; } + /** + * Auto select closest row near clic-mouse position and display popup menu. + */ @Override public void autoSelectRowInTable(MouseEvent e, JPopupMenu popup) { boolean rightClick = SwingUtilities.isRightMouseButton(e); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java 2014-08-08 14:20:13 UTC (rev 503) @@ -285,6 +285,8 @@ result.add((Component) dialogContent); result.setResizable(true); + + result.setSize(dim); final AbstractApplicationUIHandler handler = dialogContent.getHandler(); Modified: trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties =================================================================== --- trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-08-08 12:59:17 UTC (rev 502) +++ trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-08-08 14:20:13 UTC (rev 503) @@ -137,6 +137,8 @@ faxtomail.demandeList.action.print.tip=Imprimer faxtomail.demandeList.action.reply=Répondre faxtomail.demandeList.action.reply.tip=Répondre +faxtomail.demandeList.action.transmit=Déplacer +faxtomail.demandeList.action.transmit.tip=Déplacer faxtomail.demandeList.demandNbLabel=Nombre de demandes faxtomail.demandeList.goToNextPage=> faxtomail.demandeList.goToPreviousPage=<
participants (1)
-
echatellier@users.forge.codelutin.com