Author: echatellier Date: 2014-07-16 16:17:36 +0200 (Wed, 16 Jul 2014) New Revision: 398 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/398 Log: refs #5447: copier/coller no justu. Bon par contre, ca fonctionne pas, mais imposible de savoir pourquoi Added: trunk/faxtomail-ui-swing/src/main/resources/com/franciaflex/faxtomail/ui/swing/content/reply/ trunk/faxtomail-ui-swing/src/main/resources/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel-error-validation.xml Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUI.jaxx 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/ReplyFormUIModel.java trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUI.jaxx 2014-07-16 12:44:35 UTC (rev 397) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUI.jaxx 2014-07-16 14:17:36 UTC (rev 398) @@ -39,6 +39,10 @@ public ReplyFormUI(FaxToMailUI parentUI) { FaxToMailUIUtil.setParentUI(this, parentUI); + + // WFT echatellier 20140716 : aucune idée de ce à quoi ca sert, mais sinon ca fonctione pas + model = new ReplyFormUIModel(); + setContextValue(model); } ]]></script> @@ -50,6 +54,7 @@ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> <field name='from' component='fromComboBox'/> <field name='to' component='toField'/> + <field name='subject' component='subjectField'/> <field name='totalAttachmentLength' component="attachmentsPanel"/> </BeanValidator> 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 2014-07-16 12:44:35 UTC (rev 397) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java 2014-07-16 14:17:36 UTC (rev 398) @@ -55,7 +55,6 @@ import javax.swing.JTextField; import jaxx.runtime.JAXXUtil; -import jaxx.runtime.swing.renderer.DecoratorListCellRenderer; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.logging.Log; @@ -158,6 +157,7 @@ } ui.getFromComboBox().setModel(newComboModel(replyToAddresses.toArray())); + model.setSenderAllowedAddresses(replyToAddresses); } }); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel.java 2014-07-16 12:44:35 UTC (rev 397) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel.java 2014-07-16 14:17:36 UTC (rev 398) @@ -24,10 +24,14 @@ * #L% */ +import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.MailField; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; +import com.google.common.base.Preconditions; -import com.google.common.base.Preconditions; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.beans.AbstractSerializableBean; @@ -56,6 +60,7 @@ public static final String PROPERTY_TOTAL_ATTACHMENT_LENGTH = "totalAttachmentLength"; public static final String PROPERTY_VALID = "valid"; public static final String PROPERTY_SENDER_ALLOWED_DOMAINS = "senderAllowedDomains"; + public static final String PROPERTY_SENDER_ALLOWED_ADDRESSES = "senderAllowedAddresses"; protected String to; protected String from; @@ -67,6 +72,7 @@ protected boolean valid = true; protected boolean readonly = false; protected List<String> senderAllowedDomains; + protected List<String> senderAllowedAddresses; protected Set<ReplyAttachmentModel> attachments = new HashSet<ReplyAttachmentModel>(); protected Set<ReplyAttachmentModel> availableAttachments = new HashSet<ReplyAttachmentModel>(); @@ -130,7 +136,6 @@ public void addAttachment(ReplyAttachmentModel attachment) { attachments.add(attachment); firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachments()); - setTotalAttachmentLength(totalAttachmentLength + attachment.getLength()); } @@ -201,6 +206,57 @@ firePropertyChange(PROPERTY_VALID, oldValue, valid); } + /** + * Appelée par la validation. + * + * Voir le fichier src/main/resources/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel-error-validation.xml + * + * @param field field to validate + * @return validity + */ + public boolean isValid(String field) { + boolean result = true; + if (PROPERTY_FROM.equals(field)) { + // si les deux listes liste getSenderAllowedAddresses et getSenderAllowedDomains sont + // toutes les deux vides on ne valide pas + // sinon un des deux autres test doit forcement etre vrai sinon de n'est pas valide + result = getSenderAllowedAddresses().isEmpty() && getSenderAllowedDomains().isEmpty() || isEmailAllowed(getFrom()) || isDomainAllowed(getFrom()); + } + return result; + } + + /** + * Test si un email est present dans une liste (sans tenir compte de la casse). + * + * @param mail email to test + * @return true/false + */ + protected boolean isEmailAllowed(String mail) { + Preconditions.checkNotNull(mail); + for (String address : getSenderAllowedAddresses()) { + if (mail.equalsIgnoreCase(address)) { + return true; + } + } + return false; + } + + /** + * Test si un email se termine par un des domaines autorisés. + * + * @param mail email to test + * @return true/false + */ + protected boolean isDomainAllowed(String mail) { + Preconditions.checkNotNull(mail); + for (String domain : getSenderAllowedDomains()) { + if (mail.endsWith(domain)) { + return true; + } + } + return false; + } + // Do not remove the unused parameter, it is just for the validation // to bind the totalAttachmentLength property public boolean isAttachmentSizeValid(long totalAttachmentLength) { @@ -218,14 +274,13 @@ firePropertyChange(PROPERTY_SENDER_ALLOWED_DOMAINS, oldValue, senderAllowedDomains); } - public boolean isDomainAllowed(String from) { - Preconditions.checkNotNull(from); - for (String domain : getSenderAllowedDomains()) { - if (from.endsWith(domain)) { - return true; - } - } - return getSenderAllowedDomains().isEmpty(); + public void setSenderAllowedAddresses(List<String> senderAllowedAddresses) { + Object oldValue = getSenderAllowedAddresses(); + this.senderAllowedAddresses = senderAllowedAddresses; + firePropertyChange(PROPERTY_SENDER_ALLOWED_ADDRESSES, oldValue, senderAllowedAddresses); } + public List<String> getSenderAllowedAddresses() { + return senderAllowedAddresses; + } } Added: trunk/faxtomail-ui-swing/src/main/resources/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel-error-validation.xml =================================================================== --- trunk/faxtomail-ui-swing/src/main/resources/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel-error-validation.xml (rev 0) +++ trunk/faxtomail-ui-swing/src/main/resources/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel-error-validation.xml 2014-07-16 14:17:36 UTC (rev 398) @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%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% + --> + +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> + +<validators> + + <field name="to"> + <field-validator type="required" short-circuit="true"> + <message>faxtomail.validator.error.reply.to.required</message> + </field-validator> + <field-validator type="email" short-circuit="true"> + <message>faxtomail.validator.error.reply.to.email</message> + </field-validator> + </field> + + <field name="from"> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ isValid("from") ]]> + </param> + <message>faxtomail.validator.error.reply.from.invalidDomain</message> + </field-validator> + </field> + + <field name="subject"> + <field-validator type="required" short-circuit="true"> + <message>faxtomail.validator.error.reply.subject.required</message> + </field-validator> + </field> + +</validators> Property changes on: trunk/faxtomail-ui-swing/src/main/resources/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel-error-validation.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native 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-07-16 12:44:35 UTC (rev 397) +++ trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-07-16 14:17:36 UTC (rev 398) @@ -273,6 +273,8 @@ faxtomail.validator.error.email.rangeRow.required=Tableau des gammes requis faxtomail.validator.error.reply.from.invalidDomain= faxtomail.validator.error.reply.from.required= +faxtomail.validator.error.reply.subject.required= +faxtomail.validator.error.reply.to.email= faxtomail.validator.error.reply.to.required= faxtomail.validator.error.reply.totalAttachmentLength.required= jaxx.application.error.cannot.mail=
participants (1)
-
echatellier@users.forge.codelutin.com