r30 - in trunk: faxtomail-persistence/src/main/xmi faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment
Author: kmorin Date: 2014-04-04 17:42:36 +0200 (Fri, 04 Apr 2014) New Revision: 30 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/30 Log: refs #4665 [ECRAN] Transfert ajout de la gestion des etats d'attente Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/MailFolderChooserUI.jaxx trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/MailFolderChooserUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentEditorUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentItem.css trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentItem.jaxx Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo =================================================================== (Binary files differ) Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-04-03 16:13:47 UTC (rev 29) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-04-04 15:42:36 UTC (rev 30) @@ -64,6 +64,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Random; @@ -162,20 +163,20 @@ EtatAttenteTopiaDao etatAttenteDao = getPersistenceContext().getEtatAttenteDao(); List<EtatAttente> etatAttentes = Lists.newArrayList( - etatAttenteDao.create(Range.PROPERTY_LABEL, "REM Attente Remise-accord expo"), + etatAttenteDao.create(Range.PROPERTY_LABEL, "BAT attente retour BAT lettrage-logo"), + etatAttenteDao.create(Range.PROPERTY_LABEL, "CLT attente réponse client"), + etatAttenteDao.create(Range.PROPERTY_LABEL, "DAC attente pour assistance chantier"), + etatAttenteDao.create(Range.PROPERTY_LABEL, "DAV attente analyse avoir"), + etatAttenteDao.create(Range.PROPERTY_LABEL, "EXP attente expertise"), + etatAttenteDao.create(Range.PROPERTY_LABEL, "GAB attente reception gabarit"), + etatAttenteDao.create(Range.PROPERTY_LABEL, "GRA attente accord gratuit"), etatAttenteDao.create(Range.PROPERTY_LABEL, "ODC attente Ouverture de Compte"), - etatAttenteDao.create(Range.PROPERTY_LABEL, "GRA attente accord gratuit"), - etatAttenteDao.create(Range.PROPERTY_LABEL, "CLT attente réponse client"), etatAttenteDao.create(Range.PROPERTY_LABEL, "PPC attente chiffrage BEI PPC"), - etatAttenteDao.create(Range.PROPERTY_LABEL, "SIGN attente réponse BEI signature"), etatAttenteDao.create(Range.PROPERTY_LABEL, "PROFORMA attente paiement proforma"), - etatAttenteDao.create(Range.PROPERTY_LABEL, "BAT attente retour BAT lettrage-logo"), - etatAttenteDao.create(Range.PROPERTY_LABEL, "GAB attente reception gabarit"), etatAttenteDao.create(Range.PROPERTY_LABEL, "PROTO attente accord proto"), - etatAttenteDao.create(Range.PROPERTY_LABEL, "DAC attente pour assistance chantier"), - etatAttenteDao.create(Range.PROPERTY_LABEL, "DAV attente analyse avoir"), + etatAttenteDao.create(Range.PROPERTY_LABEL, "REM Attente Remise-accord expo"), etatAttenteDao.create(Range.PROPERTY_LABEL, "RET attente retour materiel"), - etatAttenteDao.create(Range.PROPERTY_LABEL, "EXP attente expertise") + etatAttenteDao.create(Range.PROPERTY_LABEL, "SIGN attente réponse BEI signature") ); PriorityTopiaDao priorityDao = getPersistenceContext().getPriorityDao(); @@ -232,7 +233,11 @@ HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao(); RangeRowTopiaDao rangeRowDao = getPersistenceContext().getRangeRowDao(); - MailFolder cyrilFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Cyril"); + int etatAttenteSize = etatAttentes.size(); + + Collections.shuffle(etatAttentes); + MailFolder cyrilFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Cyril", + MailFolder.PROPERTY_ETAT_ATTENTE, etatAttentes.subList(0, random.nextInt(etatAttenteSize - 8) + 2)); int r = random.nextInt(10) + 5; for (int i = 0 ; i < r ; i++) { createEmail(random, historyDao, rangeRowDao, emailDao, ranges, clients, types, priorities, cyrilFolder, cyril); @@ -244,7 +249,9 @@ createEmail(random, historyDao, rangeRowDao, emailDao, ranges, clients, types, priorities, claireFolder, claire); } - MailFolder agatheFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Agathe"); + Collections.shuffle(etatAttentes); + MailFolder agatheFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Agathe", + MailFolder.PROPERTY_ETAT_ATTENTE, etatAttentes.subList(0, random.nextInt(etatAttenteSize - 8) + 2)); r = random.nextInt(10) + 5; for (int i = 0 ; i < r ; i++) { createEmail(random, historyDao, rangeRowDao, emailDao, ranges, clients, types, priorities, agatheFolder, agathe); @@ -270,8 +277,10 @@ for (int i = 0 ; i < r ; i++) { createEmail(random, historyDao, rangeRowDao, emailDao, ranges, clients, types, priorities, jeanneFolder, jeanne); } + Collections.shuffle(etatAttentes); folders.add(folderDao.create(MailFolder.PROPERTY_NAME, "SAV", - MailFolder.PROPERTY_CHILDREN, Lists.newArrayList(marcFolder, fredericFolder, jeanneFolder))); + MailFolder.PROPERTY_CHILDREN, Lists.newArrayList(marcFolder, fredericFolder, jeanneFolder), + MailFolder.PROPERTY_ETAT_ATTENTE, etatAttentes.subList(0, random.nextInt(etatAttenteSize - 8) + 2))); // companies CompanyTopiaDao companyTopiaDao = getPersistenceContext().getCompanyDao(); 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-04-03 16:13:47 UTC (rev 29) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java 2014-04-04 15:42:36 UTC (rev 30) @@ -1,15 +1,19 @@ package com.franciaflex.faxtomail.services.service; +import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.persistence.entities.MailFolderTopiaDao; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaIdFactory; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; /** @@ -58,4 +62,42 @@ return result; } + public Collection<MailFolder> getFoldersWithEtatAttente(EtatAttente etatAttente) { + Collection<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)); + } + + return result; + } + + protected Collection<MailFolder> getFoldersWithEtatAttente(MailFolder folder, + Collection<EtatAttente> parentEtatAttente, + EtatAttente etatAttente) { + Collection<EtatAttente> etatAttentes = folder.getEtatAttente(); + if (CollectionUtils.isEmpty(etatAttentes)) { + etatAttentes = parentEtatAttente; + + } else { + parentEtatAttente = etatAttentes; + } + + Collection<MailFolder> result = new HashSet<>(); + Collection<MailFolder> children = folder.getChildren(); + for (MailFolder child : children) { + result.addAll(getFoldersWithEtatAttente(child, parentEtatAttente, etatAttente)); + } + + if (etatAttentes.contains(etatAttente)) { + result.add(folder); + } + + return result; + + } + } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-04-03 16:13:47 UTC (rev 29) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-04-04 15:42:36 UTC (rev 30) @@ -25,7 +25,10 @@ import com.franciaflex.faxtomail.persistence.entities.Attachment; import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.HistoryType; +import com.franciaflex.faxtomail.persistence.entities.MailFolder; +import com.franciaflex.faxtomail.persistence.entities.MailFolderTopiaDao; import com.franciaflex.faxtomail.persistence.entities.Range; import com.franciaflex.faxtomail.persistence.entities.RangeRow; import com.franciaflex.faxtomail.services.service.ReferentielService; @@ -37,6 +40,7 @@ import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import com.franciaflex.faxtomail.ui.swing.util.attachment.AttachmentEditorUIModel; 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.jdesktop.swingx.JXTable; @@ -112,12 +116,21 @@ initUI(ui); DemandeUIModel model = getModel(); + MailFolder folder = model.getMailFolder(); ReferentielService referentielService = getContext().getReferentielService(); initBeanFilterableComboBox(ui.getDocTypeComboBox(), referentielService.getAllDemandType(), model.getDemandType()); initBeanFilterableComboBox(ui.getPriorityComboBox(), referentielService.getAllPriority(), model.getPriority()); - initBeanFilterableComboBox(ui.getEtatAttenteComboBox(), referentielService.getAllEtatAttente(), model.getEtatAttente()); + List<EtatAttente> etatAttentes = new ArrayList<EtatAttente>(); + Collection<EtatAttente> folderEtatAttentes = getEtatAttenteForFolder(folder); + if (CollectionUtils.isEmpty(folderEtatAttentes)) { + etatAttentes.addAll(referentielService.getAllEtatAttente()); + } else { + etatAttentes.addAll(folderEtatAttentes); + } + initBeanFilterableComboBox(ui.getEtatAttenteComboBox(), etatAttentes, model.getEtatAttente()); + JEditorPane editor = ui.getMailBodyField(); HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); editor.setEditorKit(htmlEditorKit); @@ -381,6 +394,14 @@ return ui.getValidator(); } + public Collection<EtatAttente> getEtatAttenteForFolder(MailFolder folder) { + Collection<EtatAttente> result = null; + while (CollectionUtils.isEmpty(result) && folder != null) { + result = folder.getEtatAttente(); + folder = folder.getParent(); + } + return result; + } public BeanMonitor getMonitor() { return monitor; } @@ -390,8 +411,7 @@ } public void transmitDemande() { - MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui); - dialogContent.setModel(getModel()); + MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, getModel()); 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/MailFolderChooserUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/MailFolderChooserUI.jaxx 2014-04-03 16:13:47 UTC (rev 29) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/MailFolderChooserUI.jaxx 2014-04-04 15:42:36 UTC (rev 30) @@ -10,13 +10,14 @@ <script><![CDATA[ - public MailFolderChooserUI(FaxToMailUI parentUI) { + public MailFolderChooserUI(FaxToMailUI parentUI, DemandeUIModel model) { FaxToMailUIUtil.setParentUI(this, parentUI); + setContextValue(model); } ]]></script> - <DemandeUIModel id='model' javaBean='null'/> + <DemandeUIModel id='model' javaBean='getContextValue(DemandeUIModel.class)'/> <JScrollPane constraints='BorderLayout.CENTER'> <JTree id="navigationTree"/> Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/MailFolderChooserUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/MailFolderChooserUIHandler.java 2014-04-03 16:13:47 UTC (rev 29) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/MailFolderChooserUIHandler.java 2014-04-04 15:42:36 UTC (rev 30) @@ -1,6 +1,7 @@ package com.franciaflex.faxtomail.ui.swing.content.demande; import com.franciaflex.faxtomail.persistence.entities.Company; +import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.content.demande.MailFolderChooserUI; @@ -9,13 +10,19 @@ 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.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 javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreeNode; +import java.awt.*; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; /** @@ -24,17 +31,43 @@ */ public class MailFolderChooserUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, MailFolderChooserUI> implements Cancelable { + private static final Log log = LogFactory.getLog(MailFolderChooserUIHandler.class); + @Override public void afterInit(MailFolderChooserUI mailFolderChooserUI) { initUI(mailFolderChooserUI); + DemandeUIModel model = getModel(); + + EtatAttente etatAttente = model.getEtatAttente(); + final Collection<MailFolder> foldersWithEtatAttente; + if (etatAttente != null) { + foldersWithEtatAttente = getContext().getMailFolderService().getFoldersWithEtatAttente(etatAttente); + } else { + foldersWithEtatAttente = new HashSet<MailFolder>(); + } + // init tree Company franciaflex = getContext().getCurrentCompany(); Collection<MailFolder> folders = franciaflex.getMailFolder(); JTree navigationTree = ui.getNavigationTree(); + Map<MailFolder, DefaultMutableTreeNode> nodesByFolder = FaxToMailUIUtil.initFolderTree(getContext(), navigationTree, folders); + navigationTree.setCellRenderer(new DefaultTreeCellRenderer() { + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, + boolean expanded, boolean leaf, int row, boolean hasFocus) { + Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + setEnabled(foldersWithEtatAttente.isEmpty() || foldersWithEtatAttente.contains(node.getUserObject())); + + return component; + } + }); + navigationTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { @@ -64,25 +97,4 @@ return ui.getNavigationTree(); } - /** - * Creates the tree nodes and returns a map of the nodes by folder - * @param parent the node parent - * @param folder the folder to add to the tree - * @return the map of the nodes by folder - */ - protected Map<MailFolder, DefaultMutableTreeNode> createFolderTree(DefaultMutableTreeNode parent, MailFolder folder) { - Map<MailFolder, DefaultMutableTreeNode> result = new HashMap<MailFolder, DefaultMutableTreeNode>(); - - DefaultMutableTreeNode node = new FolderTreeNode(folder); - result.put(folder, node); - - parent.add(node); - if (folder.isChildrenNotEmpty()) { - for (MailFolder child : folder.getChildren()) { - result.putAll(createFolderTree(node, child)); - } - } - return result; - } - } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentEditorUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2014-04-03 16:13:47 UTC (rev 29) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2014-04-04 15:42:36 UTC (rev 30) @@ -230,6 +230,8 @@ label.setIcon(icon); } + setEditable(getModel().isEditable()); + return this; } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentItem.css =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentItem.css 2014-04-03 16:13:47 UTC (rev 29) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentItem.css 2014-04-04 15:42:36 UTC (rev 30) @@ -20,6 +20,5 @@ actionIcon: "delete"; toolTipText: "faxtomail.attachmentEditor.action.remove.tip"; enabled: { getAttachment() != null && getAttachment().getTopiaId() == null }; - //TODO check - visible: { getHandler().getModel().isEditable() }; + visible: { Boolean.TRUE.equals(isEditable()) }; } \ No newline at end of file Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentItem.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentItem.jaxx 2014-04-03 16:13:47 UTC (rev 29) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentItem.jaxx 2014-04-04 15:42:36 UTC (rev 30) @@ -10,6 +10,8 @@ <AttachmentEditorUIHandler id='handler' javaBean='null'/> + <Boolean id="editable" javaBean='null'/> + <JLabel id='attachmentNameLabel' constraints='BorderLayout.CENTER'/> <JToolBar id='toolbar' constraints='BorderLayout.EAST'>
participants (1)
-
kmorin@users.forge.codelutin.com