This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository faxtomail. See http://git.codelutin.com/faxtomail.git commit 6b46d51cdd0baaeb42eeb6d6f3cf3948f7a7338a Author: Kevin Morin <morin@codelutin.com> Date: Thu Nov 12 16:10:48 2015 +0100 affichage des différentes parties text/html de l'email à la suite (refs #7714) Conflicts: faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java --- .../ui/swing/content/demande/DemandeUI.css | 4 - .../ui/swing/content/demande/DemandeUI.jaxx | 6 +- .../ui/swing/content/demande/DemandeUIHandler.java | 4 +- .../ui/swing/content/demande/DemandeUIModel.java | 17 ++- .../faxtomail/ui/swing/util/FaxToMailUIUtil.java | 145 ++++++++++++--------- 5 files changed, 98 insertions(+), 78 deletions(-) diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css index 2dc88e5..31b1a9a 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css @@ -202,10 +202,6 @@ JTextField, JXTable, BeanFilterableComboBox, #commentField, ButtonAttachment, Bu verticalAlignment: { SwingConstants.TOP }; } -#mailBodyField { - editable: false; -} - .text-row { layout: { new FlowLayout(FlowLayout.LEADING) }; } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx index 6c263be..1c7883d 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx @@ -44,6 +44,7 @@ org.jdesktop.swingx.JXTitledPanel org.jdesktop.swingx.JXTable + javax.swing.BoxLayout javax.swing.ListSelectionModel javax.swing.SwingConstants @@ -319,8 +320,9 @@ <!--</row>--> <row> <cell weighty="1" columns="2"> - <JScrollPane id='mailBodyPane'> - <JTextPane id='mailBodyField'/> + <JScrollPane id='mailBodyScrollPane'> + <JPanel id="mailBodyPanel" layout="{new BoxLayout(mailBodyPanel, BoxLayout.PAGE_AXIS)}"> + </JPanel> </JScrollPane> </cell> </row> diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java index 71d12ed..0ee690f 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java @@ -213,8 +213,8 @@ public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, } initBeanFilterableComboBox(ui.getWaitingStateComboBox(), waitingStates, model.getWaitingState()); - JTextPane editor = ui.getMailBodyField(); - FaxToMailUIUtil.setEmailContentInTextPane(this, editor, model); + JPanel editorPanel = ui.getMailBodyPanel(); + FaxToMailUIUtil.setEmailContentInTextPane(this, model, editorPanel); // init table final JXTable table = ui.getRangeTable(); diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java index 21a3a08..dbdea19 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java @@ -112,7 +112,7 @@ public class DemandeUIModel extends AbstractFaxToMailBeanUIModel<Email, DemandeU protected boolean editable = true; - protected String htmlContent; + protected List<String> htmlContents; protected String plainContent; @@ -341,11 +341,11 @@ public class DemandeUIModel extends AbstractFaxToMailBeanUIModel<Email, DemandeU return plainContent; } - public String getHtmlContent() { - if (htmlContent == null) { + public List<String> getHtmlContent() { + if (htmlContents == null) { decomposeEmail(); } - return htmlContent; + return htmlContents; } public void setOriginalEmail(OriginalEmail originalEmail) { @@ -975,14 +975,21 @@ public class DemandeUIModel extends AbstractFaxToMailBeanUIModel<Email, DemandeU if (bp.isMimeType("text/plain")) { plainContent = content; + } else { - htmlContent = content; + if (htmlContents == null) { + htmlContents = new ArrayList<String>(); + } + + htmlContents.add(content); + } // if it is multipart part, decompose it } else if (bp.isMimeType("multipart/*")) { decomposeMultipartEmail(bp); } + } } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java index 2637715..53e13a4 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java @@ -341,77 +341,21 @@ public final class FaxToMailUIUtil extends ApplicationUIUtil { return EDITABLE_EXTENSIONS.contains(extension.toUpperCase()); } - public static void setEmailContentInTextPane(DemandeUIHandler handler, JTextPane textPane, DemandeUIModel demandeUIModel) { - String content = demandeUIModel.getHtmlContent(); - if (content != null) { - textPane.setContentType("text/html"); - HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); - textPane.setEditorKit(htmlEditorKit); - - textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); - Font font = new Font(Font.MONOSPACED, Font.PLAIN, 16); - textPane.setFont(font); - - textPane.addHyperlinkListener(new HyperlinkListener() { - @Override - public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - FaxToMailUIUtil.openLink(e.getURL()); - } - } - }); - - // the meta tag makes the content is not displayed - content = content.replaceAll("<meta (.*?)>(</meta>)?", ""); - - if (log.isTraceEnabled()) { - log.trace("Content before mail = " + content); - } - - for (Attachment attachment : demandeUIModel.getAttachment()) { - String key = attachment.getContentId(); - if (key == null) { - key = attachment.getOriginalFileName(); - } + public static void setEmailContentInTextPane(DemandeUIHandler handler, + DemandeUIModel demandeUIModel, + JPanel textPanePanel) { - // get file content - forceAttachmentFileLoading(handler.getContext(), attachment); - AttachmentFile attachmentFile = attachment.getOriginalFile(); - File file = attachmentFile.getFile(); - - // replace the inline attachments with the extracted attachment file url - // match les patterns: - // <td background="cid:bg.gif" height="52"> - // <img border=0 src="cid:bg.gif" /> - // <img src='cid:5e9ef859-ea65-4f9b-a9fa-30d4a2c5837c' - content = content.replaceAll("(\\w+)=([\"'])cid:" + Pattern.quote(key) + "([\"'])", "$1=$2" + file.toURI() + "$3"); - - if (log.isDebugEnabled()) { - log.debug("Mapping attachment id " + key + " to file " + file.toURI()); - } - } + List<String> contents = demandeUIModel.getHtmlContent(); - if (log.isTraceEnabled()) { - log.trace("Content after mail = " + content); + if (contents != null) { + for (String content : contents) { + addHtmlTextPane(handler, demandeUIModel, textPanePanel, content); } } else { - content = demandeUIModel.getPlainContent(); - } - - try { - textPane.setText(content); - - } catch (RuntimeException e) { - if (log.isErrorEnabled()) { - log.error("error while setting content in text pane " + textPane, e); - } - - StyledEditorKit kit = new StyledEditorKit(); - textPane.setEditorKit(kit); - textPane.setContentType(kit.getContentType()); - + JTextPane textPane = new JTextPane(); textPane.setText(demandeUIModel.getPlainContent()); + textPanePanel.add(textPane); } } @@ -829,4 +773,75 @@ public final class FaxToMailUIUtil extends ApplicationUIUtil { return demandType != null && FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.RANGE_ROW); } + protected static void addHtmlTextPane(DemandeUIHandler handler, + DemandeUIModel demandeUIModel, + JPanel textPanePanel, + String content) { + + JTextPane textPane = createHtmlTextPane(); + + // the meta tag makes the content is not displayed + content = content.replaceAll("<meta (.*?)>(</meta>)?", ""); + + if (log.isTraceEnabled()) { + log.trace("Content before mail = " + content); + } + + for (Attachment attachment : demandeUIModel.getAttachment()) { + String key = attachment.getContentId(); + if (key == null) { + key = attachment.getOriginalFileName(); + } + + // get file content + forceAttachmentFileLoading(handler.getContext(), attachment); + AttachmentFile attachmentFile = attachment.getOriginalFile(); + File file = attachmentFile.getFile(); + + // replace the inline attachments with the extracted attachment file url + // match les patterns: + // <td background="cid:bg.gif" height="52"> + // <img border=0 src="cid:bg.gif" /> + // <img src='cid:5e9ef859-ea65-4f9b-a9fa-30d4a2c5837c' + content = content.replaceAll("(\\w+)=([\"'])cid:" + Pattern.quote(key) + "([\"'])", "$1=$2" + file.toURI() + "$3"); + + if (log.isDebugEnabled()) { + log.debug("Mapping attachment id " + key + " to file " + file.toURI()); + } + } + + if (log.isTraceEnabled()) { + log.trace("Content after mail = " + content); + } + + textPane.setText(content); + + textPanePanel.add(textPane); + + textPanePanel.add(Box.createVerticalStrut(3)); + } + + protected static JTextPane createHtmlTextPane() { + JTextPane textPane = new JTextPane(); + textPane.setEditable(false); + + textPane.setContentType("text/html"); + HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); + textPane.setEditorKit(htmlEditorKit); + + textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); + Font font = new Font(Font.MONOSPACED, Font.PLAIN, 16); + textPane.setFont(font); + + textPane.addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + FaxToMailUIUtil.openLink(e.getURL()); + } + } + }); + return textPane; + } + } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.