r750 - in trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing: actions content/demande content/demande/replies content/reply
Author: kmorin Date: 2015-01-13 15:33:28 +0000 (Tue, 13 Jan 2015) New Revision: 750 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/750 Log: fix ldap loading in forward Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/OpenReplyAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/OpenReplyFormAction.java Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveAction.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/replies/DemandRepliesUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveAction.java 2015-01-12 11:25:22 UTC (rev 749) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveAction.java 2015-01-13 15:33:28 UTC (rev 750) @@ -24,13 +24,6 @@ * #L% */ -import static org.nuiton.i18n.I18n.t; - -import java.util.Collection; -import java.util.Date; - -import javax.swing.JOptionPane; - import com.franciaflex.faxtomail.persistence.entities.DemandStatus; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIHandler; @@ -39,6 +32,12 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; +import javax.swing.*; +import java.util.Collection; +import java.util.Date; + +import static org.nuiton.i18n.I18n.t; + /** * Action d'archivage d'un mail. * @@ -69,9 +68,6 @@ @Override public void doAction() throws Exception { DemandeUIModel model = getModel(); - model.setArchiveDate(new Date()); - model.setDemandStatus(DemandStatus.ARCHIVED); - model.setTakenBy(null); // déplacement du mail dans le dossier d'archive le plus proche // cela permet de déplacer les archives dans d'autre dossier pour leur appliquer @@ -103,6 +99,10 @@ model.setMailFolder(archiveChild); } + model.setArchiveDate(new Date()); + model.setDemandStatus(DemandStatus.ARCHIVED); + model.setTakenBy(null); + super.doAction(); } Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/OpenReplyAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/OpenReplyAction.java (rev 0) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/OpenReplyAction.java 2015-01-13 15:33:28 UTC (rev 750) @@ -0,0 +1,108 @@ +package com.franciaflex.faxtomail.ui.swing.actions; + +import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.Reply; +import com.franciaflex.faxtomail.persistence.entities.ReplyContent; +import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; +import com.franciaflex.faxtomail.ui.swing.content.demande.replies.DemandRepliesUI; +import com.franciaflex.faxtomail.ui.swing.content.demande.replies.DemandRepliesUIHandler; +import com.franciaflex.faxtomail.ui.swing.content.demande.replies.DemandReplyItem; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUI; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUIModel; +import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.mail.util.MimeMessageUtils; + +import javax.mail.Message; +import javax.mail.internet.MimeMessage; +import javax.swing.*; +import java.awt.*; +import java.nio.charset.Charset; + +import static org.nuiton.i18n.I18n.t; + +/** + * @author Kevin Morin (Code Lutin) + * @since 1.1 + */ +public class OpenReplyAction extends AbstractFaxToMailAction<DemandeUIModel, DemandRepliesUI, DemandRepliesUIHandler> { + + protected DemandReplyItem item; + protected ReplyFormUI frameContent; + protected JFrame frame; + + public OpenReplyAction(DemandRepliesUIHandler handler) { + super(handler, false); + } + + public void setItem(DemandReplyItem item) { + this.item = item; + } + + @Override + public void doAction() throws Exception { + + DemandeUIModel demand = getModel(); + FaxToMailServiceContext serviceContext = getContext().newServiceContext(); + Email email = serviceContext.getEmailService().getFullEmailById(demand.getTopiaId(), getContext().getCurrentUser()); + demand.fromEntity(email); + + Reply reply = item.getReply(); + FaxToMailUIUtil.forceReplyContentLoading(getContext(), reply); + boolean editable = item.isEditable(); + + frameContent = new ReplyFormUI(getUI()); + // TODO echatellier 20140804 : c'est très technique et très bas niveau, ca devrait se trouver dans les services + ReplyContent replyContent = reply.getReplyContent(); + Message message = MimeMessageUtils.createMimeMessage(null, replyContent.getSource()); + ReplyFormUIModel replyModel = frameContent.getModel(); + replyModel.setEditable(editable); + replyModel.setOriginalDemand(demand); + replyModel.setReadonly(true); + replyModel.setReadSentDate(reply.getSentDate()); + replyModel.setSubject(message.getSubject()); + replyModel.setTo(StringUtils.join(message.getRecipients(MimeMessage.RecipientType.TO), " ; ")); + replyModel.setFrom(message.getFrom()[0].toString()); + if (ArrayUtils.isNotEmpty(message.getRecipients(MimeMessage.RecipientType.CC))) { + replyModel.setCc(StringUtils.join(message.getRecipients(MimeMessage.RecipientType.CC), " ; ")); + } + if (ArrayUtils.isNotEmpty(message.getRecipients(MimeMessage.RecipientType.BCC))) { + replyModel.setCci(StringUtils.join(message.getRecipients(MimeMessage.RecipientType.BCC), " ; ")); + } + + if (message.isMimeType("multipart/*")) { + handler.decomposeMultipartEmail(message, replyModel, reply.getTopiaId()); + + } else { + Charset charset = FaxToMailServiceUtils.getCharset(message); + String content = IOUtils.toString(message.getInputStream(), charset); + replyModel.setMessage(content); + } + } + + @Override + public void postSuccessAction() { + super.postSuccessAction(); + frame = getHandler().openModalFrame(frameContent, + t("faxtomail.reply.title", getModel().getTitle()), + new Dimension(800, 600)); + } + + @Override + protected void releaseAction() { + super.releaseAction(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (frame != null) { + frame.toFront(); + frame = null; + } + } + }); + } +} Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/OpenReplyFormAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/OpenReplyFormAction.java (rev 0) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/OpenReplyFormAction.java 2015-01-13 15:33:28 UTC (rev 750) @@ -0,0 +1,80 @@ +package com.franciaflex.faxtomail.ui.swing.actions; + +import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.MailFolder; +import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUI; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUIHandler; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUIModel; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUI; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUIModel; +import jaxx.runtime.JAXXUtil; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +import static org.nuiton.i18n.I18n.t; + +/** + * @author Kevin Morin (Code Lutin) + * @since 1.1 + */ +public class OpenReplyFormAction extends AbstractFaxToMailAction<DemandeListUIModel, DemandeListUI, DemandeListUIHandler> { + + protected ReplyFormUI frameContent; + protected JFrame frame; + + public OpenReplyFormAction(DemandeListUIHandler handler) { + super(handler, false); + } + + @Override + public void doAction() throws Exception { + DemandeUIModel demand = getModel().getSelectedEmails().get(0); + + if (StringUtils.isNotBlank(demand.getTopiaId())) { + FaxToMailServiceContext serviceContext = getContext().newServiceContext(); + Email email = serviceContext.getEmailService().getFullEmailById(demand.getTopiaId(), getContext().getCurrentUser()); + demand.fromEntity(email); + + getContext().setCurrentEmail(demand); + + frameContent = new ReplyFormUI(getUI()); + ReplyFormUIModel model = frameContent.getModel(); + + model.setOriginalDemand(demand); + + String sender = JAXXUtil.getStringValue(demand.getSender()); + if (demand.isFax()) { + MailFolder selectedFolder = getModel().getSelectedFolder(); + sender = FaxToMailServiceUtils.addFaxDomainToFaxNumber(sender, selectedFolder); + } + model.setTo(sender); + } + } + + @Override + public void postSuccessAction() { + super.postSuccessAction(); + frame = getHandler().openModalFrame(frameContent, + t("faxtomail.reply.title", getContext().getCurrentEmail().getTitle()), + new Dimension(800, 600)); + } + + @Override + protected void releaseAction() { + super.releaseAction(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (frame != null) { + frame.toFront(); + frame = null; + } + } + }); + } +} 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 2015-01-12 11:25:22 UTC (rev 749) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.css 2015-01-13 15:33:28 UTC (rev 750) @@ -105,6 +105,7 @@ text: "faxtomail.demandeList.action.reply"; toolTipText: "faxtomail.demandeList.action.reply.tip"; enabled: { model.isReplyEnabled() }; + _applicationAction: { com.franciaflex.faxtomail.ui.swing.actions.OpenReplyFormAction.class }; } #archiveMenu { @@ -112,6 +113,7 @@ text: "faxtomail.demandeList.action.archive"; toolTipText: "faxtomail.demandeList.action.archive.tip"; enabled: { model.isArchiveEnabled() }; + _applicationAction: { com.franciaflex.faxtomail.ui.swing.actions.ArchiveFromListAction.class }; } #moveMenu { @@ -119,6 +121,7 @@ text: "faxtomail.demandeList.action.transmit"; toolTipText: "faxtomail.demandeList.action.transmit.tip"; enabled: { model.isTransmitEnabled() }; + _applicationAction: { com.franciaflex.faxtomail.ui.swing.actions.OpenMailFolderChooserFromListAction.class }; } #totalDemandCountLabel { 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 2015-01-12 11:25:22 UTC (rev 749) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUI.jaxx 2015-01-13 15:33:28 UTC (rev 750) @@ -60,12 +60,9 @@ <JPopupMenu id='tablePopup'> <JMenuItem id='printMenu' onActionPerformed='handler.print()'/> - <JMenuItem id='replyMenu' - onActionPerformed='handler.reply()'/> - <JMenuItem id='archiveMenu' - onActionPerformed='handler.archive()'/> - <JMenuItem id='moveMenu' - onActionPerformed='handler.transmit()'/> + <JMenuItem id='replyMenu'/> + <JMenuItem id='archiveMenu'/> + <JMenuItem id='moveMenu'/> </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 2015-01-12 11:25:22 UTC (rev 749) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2015-01-13 15:33:28 UTC (rev 750) @@ -36,16 +36,11 @@ import com.franciaflex.faxtomail.persistence.entities.MailField; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.persistence.entities.OriginalEmailImpl; -import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; -import com.franciaflex.faxtomail.ui.swing.actions.ArchiveFromListAction; import com.franciaflex.faxtomail.ui.swing.actions.ComputeQuantitiesByRangeAction; import com.franciaflex.faxtomail.ui.swing.actions.LoadFolderEmailsAction; -import com.franciaflex.faxtomail.ui.swing.actions.OpenMailFolderChooserFromListAction; import com.franciaflex.faxtomail.ui.swing.actions.PrintOnDefaultPrinterAction; 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.util.AbstractFaxToMailDemandListHandler; import com.franciaflex.faxtomail.ui.swing.util.DemandeTableModel; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; @@ -98,8 +93,6 @@ import java.util.List; import java.util.Map; -import static org.nuiton.i18n.I18n.t; - /** * Handler of UI {@link com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUIHandler}. * @@ -775,39 +768,4 @@ getContext().getActionEngine().runAction(action); } - public void reply() { - DemandeUIModel demand = getModel().getSelectedEmails().get(0); - getContext().setCurrentEmail(demand); - - ReplyFormUI dialogContent = new ReplyFormUI(ui); - ReplyFormUIModel model = dialogContent.getModel(); - - model.setOriginalDemand(demand); - - String sender = JAXXUtil.getStringValue(demand.getSender()); - if (demand.isFax()) { - MailFolder selectedFolder = getModel().getSelectedFolder(); - sender = FaxToMailServiceUtils.addFaxDomainToFaxNumber(sender, selectedFolder); - } - model.setTo(sender); - - openModalFrame(dialogContent, t("faxtomail.reply.title", demand.getTitle()), new Dimension(800, 600)); - } - - public void archive() { - ArchiveFromListAction action = - getContext().getActionFactory().createLogicAction(this, - ArchiveFromListAction.class); - getContext().getActionEngine().runAction(action); - } - - /** - * Display move popup for user to chose where to move all selected demands. - */ - public void transmit() { - OpenMailFolderChooserFromListAction action = - getContext().getActionFactory().createLogicAction(this, - OpenMailFolderChooserFromListAction.class); - getContext().getActionEngine().runAction(action); - } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java 2015-01-12 11:25:22 UTC (rev 749) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java 2015-01-13 15:33:28 UTC (rev 750) @@ -32,6 +32,8 @@ import com.franciaflex.faxtomail.persistence.entities.Reply; import com.franciaflex.faxtomail.persistence.entities.ReplyContent; import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; +import com.franciaflex.faxtomail.ui.swing.actions.OpenReplyAction; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyAttachmentModel; import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUI; @@ -42,8 +44,6 @@ import jaxx.runtime.JAXXUtil; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.mail.util.MimeMessageUtils; @@ -55,7 +55,6 @@ import javax.mail.BodyPart; import javax.mail.Message; import javax.mail.Part; -import javax.mail.internet.MimeMessage.RecipientType; import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeUtility; import javax.swing.*; @@ -184,45 +183,10 @@ public void openReply(DemandReplyItem item) { closeEditor(); - Reply reply = item.getReply(); - FaxToMailUIUtil.forceReplyContentLoading(getContext(), reply); - boolean editable = item.isEditable(); - - try { - ReplyFormUI dialogContent = new ReplyFormUI(ui); - // TODO echatellier 20140804 : c'est très technique et très bas niveau, ca devrait se trouver dans les services - ReplyContent replyContent = reply.getReplyContent(); - Message message = MimeMessageUtils.createMimeMessage(null, replyContent.getSource()); - ReplyFormUIModel replyModel = dialogContent.getModel(); - replyModel.setEditable(editable); - replyModel.setReadonly(true); - replyModel.setReadSentDate(reply.getSentDate()); - replyModel.setSubject(message.getSubject()); - replyModel.setTo(StringUtils.join(message.getRecipients(RecipientType.TO), " ; ")); - replyModel.setFrom(message.getFrom()[0].toString()); - if (ArrayUtils.isNotEmpty(message.getRecipients(RecipientType.CC))) { - replyModel.setCc(StringUtils.join(message.getRecipients(RecipientType.CC), " ; ")); - } - if (ArrayUtils.isNotEmpty(message.getRecipients(RecipientType.BCC))) { - replyModel.setCci(StringUtils.join(message.getRecipients(RecipientType.BCC), " ; ")); - } - - if (message.isMimeType("multipart/*")) { - decomposeMultipartEmail(message, replyModel, reply.getTopiaId()); - - } else { - Charset charset = FaxToMailServiceUtils.getCharset(message); - String content = IOUtils.toString(message.getInputStream(), charset); - replyModel.setMessage(content); - } - log.info(replyModel.getMessage()); - - openFrame(dialogContent, replyModel.getSubject(), new Dimension(800, 600)); - - } catch (Exception e) { - getContext().getErrorHelper().showErrorDialog(t("faxtomail.demandReplies.error"), e); - } - + FaxToMailUIContext context = getContext(); + OpenReplyAction action = context.getActionFactory().createLogicAction(this, OpenReplyAction.class); + action.setItem(item); + context.getActionEngine().runActionAndWait(action); } public void openForward(DemandReplyItem item) { @@ -239,7 +203,7 @@ Message message = MimeMessageUtils.createMimeMessage(null, replyContent.getSource()); ReplyFormUIModel replyModel = dialogContent.getModel(); replyModel.setEditable(editable); -// replyModel.setOriginalDemand(ui.getModel()); + replyModel.setOriginalDemand(ui.getModel()); replyModel.setReadSentDate(reply.getSentDate()); replyModel.setSubject(t("faxtomail.reply.forwardsubject", message.getSubject())); @@ -275,7 +239,7 @@ * @param part the part to decompose * @throws Exception */ - protected void decomposeMultipartEmail(Part part, ReplyFormUIModel reply, String topiaId) throws Exception { + public void decomposeMultipartEmail(Part part, ReplyFormUIModel reply, String topiaId) throws Exception { DataSource dataSource = part.getDataHandler().getDataSource(); MimeMultipart mimeMultipart = new MimeMultipart(dataSource); int multiPartCount = mimeMultipart.getCount(); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java 2015-01-12 11:25:22 UTC (rev 749) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java 2015-01-13 15:33:28 UTC (rev 750) @@ -428,6 +428,7 @@ // clear fields that need to be filled by hand replyModel.setReadonly(false); + replyModel.setOriginalDemand(getModel().getOriginalDemand()); replyModel.setReadSentDate(null); replyModel.setTo(null); replyModel.setCc(null);
participants (1)
-
kmorin@users.forge.codelutin.com