Author: kmorin Date: 2014-04-03 16:00:27 +0200 (Thu, 03 Apr 2014) New Revision: 26 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/26 Log: refs #4654 [ECRAN] Liste des mails / fax refs #4655 [ECRAN] D?\195?\169tail d'un mail / fax dernier utilisateur qui a visualis?\195?\169 une pi?\195?\168ce jointe refs #4666 [ECRAN] Pi?\195?\168ces jointes historique d'ouverture et d'?\195?\169dition des pi?\195?\168ces jointes Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/HistoryType.java trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_en_GB.properties trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx 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/DemandeUIModel.java 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/util/AbstractFaxToMailDemandListHandler.java 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/attachment/AttachmentCellEditor.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/AttachmentEditorUIModel.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/ButtonAttachment.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/ButtonHistory.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/HistoryListUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/HistoryListUIModel.java trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_en_GB.properties 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/HistoryType.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/HistoryType.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/HistoryType.java 2014-04-03 14:00:27 UTC (rev 26) @@ -38,7 +38,9 @@ MODIFICATION(n("faxtomail.historyType.modification")), REPLY(n("faxtomail.historyType.reply")), PRINTING(n("faxtomail.historyType.printing")), - ARCHIVED(n("faxtomail.historyType.archive")); + ARCHIVED(n("faxtomail.historyType.archive")), + ATTACHMENT_OPENING(n("faxtomail.historyType.attachmentOpening")), + ATTACHMENT_MODIFICATION(n("faxtomail.historyType.attachmentModification")); protected String labelKey; Modified: trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_en_GB.properties =================================================================== --- trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_en_GB.properties 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_en_GB.properties 2014-04-03 14:00:27 UTC (rev 26) @@ -26,6 +26,9 @@ faxtomail.demandStatus.transmittedToEdi= faxtomail.demandStatus.untreated= faxtomail.historyType.archive= +faxtomail.historyType.attachmentCreation= +faxtomail.historyType.attachmentModification= +faxtomail.historyType.attachmentOpening= faxtomail.historyType.creation= faxtomail.historyType.modification= faxtomail.historyType.opening= Modified: trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties =================================================================== --- trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties 2014-04-03 14:00:27 UTC (rev 26) @@ -26,6 +26,8 @@ faxtomail.demandStatus.transmittedToEdi=Transmis à l'EDI faxtomail.demandStatus.untreated=Non traité faxtomail.historyType.archive=Archivage +faxtomail.historyType.attachmentModification=Modification de pièce jointe +faxtomail.historyType.attachmentOpening=Ouverture de pièce jointe faxtomail.historyType.creation=Création faxtomail.historyType.modification=Modification faxtomail.historyType.opening=Ouverture Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-04-03 14:00:27 UTC (rev 26) @@ -133,13 +133,14 @@ return folders; } - public Email addToOpeningHistory(String emailId, FaxToMailUser user, Date date) { + public Email addToHistory(String emailId, HistoryType type, FaxToMailUser user, Date date, String... fields) { EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); Email email = emailDao.findByTopiaId(emailId); HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao(); - History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.OPENING, + History history = historyDao.create(History.PROPERTY_TYPE, type, History.PROPERTY_FAX_TO_MAIL_USER, user, + History.PROPERTY_FIELDS, Sets.newHashSet(fields), History.PROPERTY_MODIFICATION_DATE, date); email.addHistory(history); 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-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-04-03 14:00:27 UTC (rev 26) @@ -62,10 +62,6 @@ import org.nuiton.jaxx.application.ApplicationTechnicalException; import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -350,7 +346,7 @@ if (opened) { - getEmailService().addToOpeningHistory(email.getTopiaId(), user, now); + getEmailService().addToHistory(email.getTopiaId(), HistoryType.OPENING, user, now); email.setDemandType(types.get(random.nextInt(types.size()))); email.setPriority(priorities.get(random.nextInt(priorities.size()))); email.setRangeRow(rangeRows); @@ -383,7 +379,7 @@ if (opened) { - getEmailService().addToOpeningHistory(email.getTopiaId(), user, now); + getEmailService().addToHistory(email.getTopiaId(), HistoryType.OPENING, user, now); email.setDemandType(types.get(random.nextInt(types.size()))); email.setPriority(priorities.get(random.nextInt(priorities.size()))); email.setRangeRow(rangeRows); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-04-03 14:00:27 UTC (rev 26) @@ -2,6 +2,7 @@ import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import com.franciaflex.faxtomail.ui.swing.util.JImagePanel; +import com.franciaflex.faxtomail.ui.swing.util.attachment.AttachmentEditorUI; import com.franciaflex.faxtomail.ui.swing.util.attachment.PDFEditorCrossUI; import com.franciaflex.faxtomail.ui.swing.util.attachment.PDFEditorNoteUI; import com.franciaflex.faxtomail.ui.swing.util.attachment.PDFEditorUI; @@ -19,6 +20,7 @@ import com.itextpdf.text.pdf.PdfReader; import com.itextpdf.text.pdf.PdfStamper; import com.itextpdf.text.pdf.PdfWriter; +import jaxx.runtime.JAXXContext; import jaxx.runtime.JAXXUtil; import jaxx.runtime.SwingUtil; import org.apache.commons.io.FileUtils; @@ -154,5 +156,11 @@ getModel().setEditedFile(target); } + @Override + public void postSuccessAction() { + super.postSuccessAction(); + AttachmentEditorUI parentUI = (AttachmentEditorUI) getUI().getContextValue(JAXXContext.class, JAXXUtil.PARENT); + parentUI.getModel().fireAttachmentEdited(getModel().toEntity()); + } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css 2014-04-03 14:00:27 UTC (rev 26) @@ -204,6 +204,26 @@ text: { handler.decorate(model.getLastModificationDate()) }; } +#lastAttachmentOpeningLabel { + text: "faxtomail.demande.lastAttachmentOpening.label"; +} + +#lastAttachmentOpenedByLabel { + text: "faxtomail.common.by.label"; +} + +#lastAttachmentOpenedByField { + text: { handler.decorateUser(model.getLastAttachmentOpeningUser(), true) }; +} + +#lastAttachmentOpeningDateLabel { + text: "faxtomail.common.on.label"; +} + +#lastAttachmentOpeningDateField { + text: { handler.decorate(model.getLastAttachmentOpeningDate()) }; +} + #ediCodeNumberLabel { text: "faxtomail.demande.ediCodeNumber.label"; visible: { model.getEdiCodeNumber() != null }; Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx 2014-04-03 14:00:27 UTC (rev 26) @@ -231,6 +231,27 @@ <JLabel id="lastModificationDateField"/> </cell> </row> + <row> + <cell columns='4'> + <JLabel id="lastAttachmentOpeningLabel"/> + </cell> + </row> + <row> + <cell> + <JLabel id="lastAttachmentOpenedByLabel"/> + </cell> + <cell columns="3"> + <JLabel id="lastAttachmentOpenedByField"/> + </cell> + </row> + <row> + <cell> + <JLabel id="lastAttachmentOpeningDateLabel"/> + </cell> + <cell weightx='1' columns="3"> + <JLabel id="lastAttachmentOpeningDateField"/> + </cell> + </row> <row> <cell> 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-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-04-03 14:00:27 UTC (rev 26) @@ -24,6 +24,8 @@ import com.franciaflex.faxtomail.persistence.entities.Attachment; +import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.HistoryType; import com.franciaflex.faxtomail.persistence.entities.Range; import com.franciaflex.faxtomail.persistence.entities.RangeRow; import com.franciaflex.faxtomail.services.service.ReferentielService; @@ -33,7 +35,7 @@ import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailUIHandler; import com.franciaflex.faxtomail.ui.swing.util.CloseableUI; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; -import com.google.common.collect.Maps; +import com.franciaflex.faxtomail.ui.swing.util.attachment.AttachmentEditorUIModel; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -48,40 +50,25 @@ import org.nuiton.jaxx.application.swing.table.MoveToNextEditableRowAction; import org.nuiton.jaxx.application.swing.table.MoveToPreviousEditableCellAction; import org.nuiton.jaxx.application.swing.table.MoveToPreviousEditableRowAction; -import org.nuiton.topia.persistence.TopiaEntities; import org.nuiton.util.beans.BeanMonitor; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; import javax.swing.table.TableCellEditor; -import javax.swing.text.AbstractDocument; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.Element; -import javax.swing.text.LabelView; -import javax.swing.text.StyleConstants; -import javax.swing.text.View; -import javax.swing.text.ViewFactory; -import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLEditorKit; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.awt.print.PrinterJob; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import static org.nuiton.i18n.I18n.t; @@ -111,7 +98,7 @@ super.beforeInit(ui); DemandeUIModel model = getContext().getCurrentEmail(); - listModelIsModify(model); +// listModelIsModify(model); Set<String> propertiesToIgnore = getPropertiesToIgnore(); monitor = new BeanMonitor(true, propertiesToIgnore.toArray(new String[propertiesToIgnore.size()])); monitor.setBean(model); @@ -319,6 +306,39 @@ model.setModify(false); registerValidators(validator); + + ui.getAttachmentsButton().getBean().addAttachmentListener( + new AttachmentEditorUIModel.AttachmentListener() { + + @Override + public void onAttachmentOpened(Attachment attachment) { + String topiaId = getModel().getTopiaId(); + if (topiaId != null) { + Email email = getContext().getEmailService().addToHistory(topiaId, + HistoryType.ATTACHMENT_OPENING, + getContext().getCurrentUser(), + new Date(), + attachment.getOriginalFile().getName()); + getModel().fromEntity(email); + } + } + + @Override + public void onAttachmentEdited(Attachment attachment) { + String topiaId = getModel().getTopiaId(); + if (topiaId != null) { + Email email = getContext().getEmailService().addToHistory(topiaId, + HistoryType.ATTACHMENT_MODIFICATION, + getContext().getCurrentUser(), + new Date(), + attachment.getOriginalFile().getName()); + getModel().fromEntity(email); + } + } + + + } + ); } @Override @@ -330,6 +350,7 @@ protected Set<String> getPropertiesToIgnore() { Set<String> result = super.getPropertiesToIgnore(); result.add(DemandeUIModel.PROPERTY_EDITABLE); + result.add(Email.PROPERTY_HISTORY); return result; } @@ -347,7 +368,7 @@ public boolean quitUI() { boolean result = quitScreen( true, - getModel().isModify(), + getMonitor().wasModified(), t("faxtomail.demande.askCancelEditBeforeLeaving.cancelSave"), t("faxtomail.demande.askSaveBeforeLeaving.save"), getContext().getActionFactory().createUIAction(this, SaveDemandeAction.class) Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-04-03 14:00:27 UTC (rev 26) @@ -47,6 +47,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -73,6 +74,8 @@ protected History lastModificationHistory; + protected History lastAttachmentOpeningHistory; + protected int quotationNb; protected int pfNb; @@ -95,6 +98,7 @@ public void propertyChange(PropertyChangeEvent evt) { findFirstOpeningHistory(); findLastModificationHistory(); + findLastAttachmentOpeningHistory(); } }); @@ -316,9 +320,8 @@ } public void setHistory(Collection<History> history) { - Object oldValue = getHistory(); editObject.setHistory(history); - firePropertyChanged(Email.PROPERTY_HISTORY, oldValue, history); + firePropertyChanged(Email.PROPERTY_HISTORY, null, history); } public Collection<History> getHistory() { @@ -360,6 +363,23 @@ lastModificationHistory = result; } + public void findLastAttachmentOpeningHistory() { + History result = null; + Date date = null; + Collection<History> histories = getHistory(); + if (histories != null) { + for (History history : histories) { + if (HistoryType.ATTACHMENT_OPENING.equals(history.getType())) { + if (date == null || date.before(history.getModificationDate())) { + date = history.getModificationDate(); + result = history; + } + } + } + } + lastAttachmentOpeningHistory = result; + } + public History getFirstOpeningHistory() { return firstOpeningHistory; } @@ -388,6 +408,20 @@ return history != null ? history.getModificationDate() : null; } + public History getLastAttachmentOpeningHistory() { + return lastAttachmentOpeningHistory; + } + + public FaxToMailUser getLastAttachmentOpeningUser() { + History history = getLastAttachmentOpeningHistory(); + return history != null ? history.getFaxToMailUser() : null; + } + + public Date getLastAttachmentOpeningDate() { + History history = getLastAttachmentOpeningHistory(); + return history != null ? history.getModificationDate() : null; + } + @Override public Collection<Attachment> getAttachment() { return attachments; @@ -395,28 +429,32 @@ @Override public void addAllAttachment(Collection<Attachment> attachment) { + Object oldValue = new ArrayList<Attachment>(getAttachment()); attachments.addAll(attachment); - firePropertyChange(Email.PROPERTY_ATTACHMENT, null, getAttachment()); + firePropertyChange(Email.PROPERTY_ATTACHMENT, oldValue, getAttachment()); } @Override public void addAttachment(Attachment attachment) { + Object oldValue = new ArrayList<Attachment>(getAttachment()); attachments.add(attachment); - firePropertyChange(Email.PROPERTY_ATTACHMENT, null, getAttachment()); + firePropertyChange(Email.PROPERTY_ATTACHMENT, oldValue, getAttachment()); } @Override public void removeAttachment(Attachment attachment) { + Object oldValue = new ArrayList<Attachment>(getAttachment()); attachments.remove(attachment); - firePropertyChange(Email.PROPERTY_ATTACHMENT, null, getAttachment()); + firePropertyChange(Email.PROPERTY_ATTACHMENT, oldValue, getAttachment()); } public void setAttachment(Collection<Attachment> attachment) { + Object oldValue = new ArrayList<Attachment>(getAttachment()); attachments.clear(); if (attachment != null) { attachments.addAll(attachment); } - firePropertyChange(Email.PROPERTY_ATTACHMENT, null, getAttachment()); + firePropertyChange(Email.PROPERTY_ATTACHMENT, oldValue, getAttachment()); } public Collection<RangeRow> getRangeRow() { @@ -424,26 +462,30 @@ } public void addRangeRow(RangeRow rangeRow) { + Object oldValue = new ArrayList<RangeRow>(getRangeRow()); editObject.addRangeRow(rangeRow); - firePropertyChange(Email.PROPERTY_RANGE_ROW, null, getRangeRow()); + firePropertyChange(Email.PROPERTY_RANGE_ROW, oldValue, getRangeRow()); } public void addAllRangeRow(Collection<RangeRow> rangeRow) { + Object oldValue = new ArrayList<RangeRow>(getRangeRow()); editObject.addAllRangeRow(rangeRow); - firePropertyChange(Email.PROPERTY_RANGE_ROW, null, getRangeRow()); + firePropertyChange(Email.PROPERTY_RANGE_ROW, oldValue, getRangeRow()); } public void removeRangeRow(RangeRow rangeRow) { + Object oldValue = new ArrayList<RangeRow>(getRangeRow()); editObject.removeRangeRow(rangeRow); - firePropertyChange(Email.PROPERTY_RANGE_ROW, null, getRangeRow()); + firePropertyChange(Email.PROPERTY_RANGE_ROW, oldValue, getRangeRow()); } public void setRangeRow(Collection<RangeRow> rangeRow) { + Object oldValue = new ArrayList<RangeRow>(getRangeRow()); if (rangeRow == null) { rangeRow = new ArrayList<RangeRow>(); } editObject.setRangeRow(rangeRow); - firePropertyChange(Email.PROPERTY_RANGE_ROW, null, getRangeRow()); + firePropertyChange(Email.PROPERTY_RANGE_ROW, oldValue, getRangeRow()); } public MailFolder getMailFolder() { 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-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel.java 2014-04-03 14:00:27 UTC (rev 26) @@ -87,4 +87,5 @@ attachments.remove(attachment); firePropertyChange(AttachmentModelAware.PROPERTY_ATTACHMENT, null, getAttachment()); } + } 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-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-04-03 14:00:27 UTC (rev 26) @@ -5,17 +5,15 @@ import com.franciaflex.faxtomail.persistence.entities.DemandStatus; import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.HasLabel; +import com.franciaflex.faxtomail.persistence.entities.HistoryType; import com.franciaflex.faxtomail.persistence.entities.Priority; import com.franciaflex.faxtomail.persistence.entities.RangeRow; -import com.franciaflex.faxtomail.services.service.ValidationService; import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.actions.ShowDemandeAction; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; -import com.franciaflex.faxtomail.ui.swing.content.demande.RangeRowModel; import com.franciaflex.faxtomail.ui.swing.util.attachment.AttachmentCellEditor; import com.franciaflex.faxtomail.ui.swing.util.attachment.AttachmentCellRenderer; import com.google.common.base.Function; -import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,7 +32,6 @@ import javax.swing.*; import javax.swing.event.ChangeListener; import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; import java.awt.*; import java.awt.event.MouseAdapter; @@ -203,9 +200,10 @@ DemandeUIModel selectedEmail = tableModel.getEntry(rowIndex); onDoubleClickOnDemande(selectedEmail); FaxToMailUIContext context = getContext(); - Email email = context.getEmailService().addToOpeningHistory(selectedEmail.getTopiaId(), - context.getCurrentUser(), - new Date()); + Email email = context.getEmailService().addToHistory(selectedEmail.getTopiaId(), + HistoryType.OPENING, + context.getCurrentUser(), + new Date()); selectedEmail.fromEntity(email); openDemand(selectedEmail); } 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-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java 2014-04-03 14:00:27 UTC (rev 26) @@ -182,7 +182,9 @@ @Override public void propertyChange(PropertyChangeEvent evt) { - if (!excludeProperties.contains(evt.getPropertyName())) { + if (!excludeProperties.contains(evt.getPropertyName()) + //check that the new value and old value are not both null + && evt.getNewValue() != evt.getOldValue()) { ((AbstractFaxToMailBeanUIModel) evt.getSource()).setModify(true); } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentCellEditor.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentCellEditor.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentCellEditor.java 2014-04-03 14:00:27 UTC (rev 26) @@ -24,7 +24,10 @@ * #L% */ +import com.franciaflex.faxtomail.persistence.entities.Attachment; +import com.franciaflex.faxtomail.persistence.entities.HistoryType; import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailBeanUIModel; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI; import com.google.common.base.Preconditions; @@ -38,6 +41,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.table.TableCellEditor; import java.awt.*; +import java.util.Date; import java.util.EventObject; /** @@ -69,7 +73,12 @@ protected final ButtonAttachment editorButton; + protected FaxToMailUIContext context; + + protected AttachmentEditorUIModel.AttachmentListener listener; + public AttachmentCellEditor(FaxToMailUIContext context) { + this.context = context; this.editorButton = new ButtonAttachment("faxtomail.attachmentCellRenderer.text", null); this.editorButton.setBorder(new LineBorder(Color.BLACK)); @@ -99,11 +108,36 @@ rowIndex = row; columnIndex = column; - AttachmentModelAware model = - (AttachmentModelAware) tableModel.getEntry(row); + final DemandeUIModel model = (DemandeUIModel) tableModel.getEntry(row); editorButton.init(model); + listener = new AttachmentEditorUIModel.AttachmentListener() { + @Override + public void onAttachmentOpened(Attachment attachment) { + String topiaId = model.getTopiaId(); + if (topiaId != null) { + context.getEmailService().addToHistory(topiaId, + HistoryType.ATTACHMENT_OPENING, + context.getCurrentUser(), + new Date(), + attachment.getOriginalFile().getName()); + } + } + + @Override + public void onAttachmentEdited(Attachment attachment) { + String topiaId = model.getTopiaId(); + context.getEmailService().addToHistory(topiaId, + HistoryType.ATTACHMENT_MODIFICATION, + context.getCurrentUser(), + new Date(), + attachment.getOriginalFile().getName()); + } + }; + + editorButton.getBean().addAttachmentListener(listener); + return editorButton; } @@ -115,7 +149,7 @@ @Override public Object getCellEditorValue() { - AttachmentModelAware model = editorButton.getBean(); + AttachmentEditorUIModel model = editorButton.getBean(); Preconditions.checkNotNull(model, "No model found in editor."); Object result = model.getAttachment(); @@ -130,6 +164,7 @@ public boolean stopCellEditing() { boolean b = super.stopCellEditing(); if (b) { + editorButton.getBean().removeAttachmentListener(listener); editorButton.init(null); } return b; @@ -137,6 +172,7 @@ @Override public void cancelCellEditing() { + editorButton.getBean().removeAttachmentListener(listener); editorButton.init(null); super.cancelCellEditing(); } 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-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2014-04-03 14:00:27 UTC (rev 26) @@ -31,6 +31,7 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.util.Date; import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -53,7 +54,7 @@ initTable(ui.getAttachments()); - getModel().addPropertyChangeListener(AttachmentEditorUIModel.PROPERTY_ATTACHMENT, new PropertyChangeListener() { + getModel().addPropertyChangeListener(AttachmentModelAware.PROPERTY_ATTACHMENT, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { AbstractTableModel tableModel = (AbstractTableModel) getUI().getAttachments().getModel(); @@ -164,8 +165,10 @@ throw new ApplicationTechnicalException(t("faxtomail.attachmentEditor.fileNotFound", file.getAbsolutePath())); } + getModel().fireAttachmentOpened(attachment); + String extension = FileUtil.extension(file); - if (EDITABLE_EXTENSIONS.contains(extension.toUpperCase())) { + if (getModel().isEditable() && EDITABLE_EXTENSIONS.contains(extension.toUpperCase())) { PDFEditorUI dialogContent = new PDFEditorUI(ui); dialogContent.getModel().fromEntity(attachment); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentEditorUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentEditorUIModel.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/AttachmentEditorUIModel.java 2014-04-03 14:00:27 UTC (rev 26) @@ -8,13 +8,13 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.List; /** * @author Kevin Morin (Code Lutin) * @since x.x */ -public class AttachmentEditorUIModel extends AbstractFaxToMailBeanUIModel<AttachmentModelAware, AttachmentEditorUIModel> - implements AttachmentModelAware { +public class AttachmentEditorUIModel extends AbstractFaxToMailBeanUIModel<AttachmentModelAware, AttachmentEditorUIModel> { public static final String PROPERTY_FILE = "file"; public static final String PROPERTY_EDITABLE = "editable"; @@ -24,6 +24,8 @@ protected final Collection<Attachment> attachments = new ArrayList<Attachment>(); + protected List<AttachmentListener> openingListeners = new ArrayList<AttachmentListener>(); + protected static Binder<AttachmentEditorUIModel, AttachmentModelAware> toBeanBinder = BinderFactory.newBinder(AttachmentEditorUIModel.class, AttachmentModelAware.class); @@ -55,26 +57,22 @@ firePropertyChange(PROPERTY_EDITABLE, oldValue, editable); } - @Override public Collection<Attachment> getAttachment() { return attachments; } - @Override public void addAllAttachment(Collection<Attachment> attachments) { Object oldValue = new ArrayList<Attachment>(getAttachment()); this.attachments.addAll(attachments); firePropertyChange(AttachmentModelAware.PROPERTY_ATTACHMENT, oldValue, this.attachments); } - @Override public void addAttachment(Attachment attachment) { Object oldValue = new ArrayList<Attachment>(getAttachment()); attachments.add(attachment); firePropertyChange(AttachmentModelAware.PROPERTY_ATTACHMENT, oldValue, attachments); } - @Override public void removeAttachment(Attachment attachment) { Object oldValue = new ArrayList<Attachment>(getAttachment()); attachments.remove(attachment); @@ -94,4 +92,32 @@ protected AttachmentModelAware newEntity() { return null; } + + public void addAttachmentListener(AttachmentListener listener) { + openingListeners.add(listener); + } + + public void removeAttachmentListener(AttachmentListener listener) { + openingListeners.remove(listener); + } + + public void fireAttachmentOpened(Attachment attachment) { + for (AttachmentListener listener : openingListeners) { + listener.onAttachmentOpened(attachment); + } + } + + public void fireAttachmentEdited(Attachment attachment) { + for (AttachmentListener listener : openingListeners) { + listener.onAttachmentEdited(attachment); + } + } + + public static interface AttachmentListener { + + public void onAttachmentOpened(Attachment attachment); + + public void onAttachmentEdited(Attachment attachment); + + } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/ButtonAttachment.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/ButtonAttachment.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/attachment/ButtonAttachment.java 2014-04-03 14:00:27 UTC (rev 26) @@ -70,13 +70,13 @@ public void init(AttachmentModelAware model) { attachmentModelAware = model; - popup.getModel().removePropertyChangeListener(AttachmentEditorUIModel.PROPERTY_ATTACHMENT, listener); + popup.getModel().removePropertyChangeListener(AttachmentModelAware.PROPERTY_ATTACHMENT, listener); popup.getModel().fromEntity(model); - popup.getModel().addPropertyChangeListener(AttachmentEditorUIModel.PROPERTY_ATTACHMENT, listener); + popup.getModel().addPropertyChangeListener(AttachmentModelAware.PROPERTY_ATTACHMENT, listener); setText(getButtonText(model != null ? model.getAttachment() : null)); } - public AttachmentModelAware getBean() { + public AttachmentEditorUIModel getBean() { return popup.getModel(); } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/ButtonHistory.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/ButtonHistory.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/ButtonHistory.java 2014-04-03 14:00:27 UTC (rev 26) @@ -1,6 +1,8 @@ package com.franciaflex.faxtomail.ui.swing.util.history; import com.franciaflex.faxtomail.persistence.entities.Attachment; +import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.History; import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.util.AbstractToolbarPopupButton; import com.franciaflex.faxtomail.ui.swing.util.attachment.AttachmentEditorUI; @@ -18,6 +20,7 @@ import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.Collection; import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -34,6 +37,16 @@ setToolTipText(t("faxtomail.historyList.action.tip")); int historySize = popup.getModel().sizeHistory(); setText(t("faxtomail.historyList.text", historySize)); + + popup.getModel().addPropertyChangeListener(Email.PROPERTY_HISTORY, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Collection<History> history = (Collection<History>) evt.getNewValue(); + if (history != null) { + setText(t("faxtomail.historyList.text", history.size())); + } + } + }); } @Override Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/HistoryListUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/HistoryListUIHandler.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/HistoryListUIHandler.java 2014-04-03 14:00:27 UTC (rev 26) @@ -1,5 +1,6 @@ package com.franciaflex.faxtomail.ui.swing.util.history; +import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.History; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.util.AbstractToolbarPopupHandler; @@ -12,6 +13,7 @@ import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXList; import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.nuiton.i18n.I18n; import org.nuiton.util.StringUtil; import javax.swing.*; @@ -52,11 +54,20 @@ n("faxtomail.demande.rangeRow.label"); } + protected PropertyChangeListener historyChangeListener = new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Collection<History> history = (Collection<History>) evt.getNewValue(); + getModel().setHistory(history); + } + }; + @Override public void beforeInit(HistoryListUI ui) { super.beforeInit(ui); DemandeUIModel currentEmail = getContext().getCurrentEmail(); + currentEmail.addPropertyChangeListener(Email.PROPERTY_HISTORY, historyChangeListener); HistoryListUIModel model = new HistoryListUIModel(); model.fromBean(currentEmail); @@ -73,10 +84,19 @@ listModel.setAllElements(getModel().getHistory()); list.setModel(listModel); list.addHighlighter(HighlighterFactory.createAlternateStriping()); + + getModel().addPropertyChangeListener(Email.PROPERTY_HISTORY, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Collection<History> history = (Collection<History>) evt.getNewValue(); + ((JaxxDefaultListModel) getUI().getHistories().getModel()).setAllElements(history); + } + }); } @Override public void onCloseUI() { + getContext().getCurrentEmail().removePropertyChangeListener(Email.PROPERTY_HISTORY, historyChangeListener); } @Override @@ -93,7 +113,13 @@ List<String> fieldLabels = new ArrayList<String>(); if (fields != null) { for (String field : fields) { - fieldLabels.add(t("faxtomail.demande." + field + ".label")); + String label; + if (I18n.hasKey(field)) { + label = t("faxtomail.demande." + field + ".label"); + } else { + label = field; + } + fieldLabels.add(label); } } return StringUtils.join(fieldLabels, ", "); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/HistoryListUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/HistoryListUIModel.java 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/history/HistoryListUIModel.java 2014-04-03 14:00:27 UTC (rev 26) @@ -31,6 +31,7 @@ public void setHistory(Collection<History> history) { editObject.setHistory(history); + firePropertyChanged(Email.PROPERTY_HISTORY, null, history); } public Collection<History> getHistory() { Modified: trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_en_GB.properties =================================================================== --- trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_en_GB.properties 2014-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_en_GB.properties 2014-04-03 14:00:27 UTC (rev 26) @@ -132,6 +132,7 @@ faxtomail.demande.gamme.label= faxtomail.demande.group.button.label= faxtomail.demande.history.label= +faxtomail.demande.lastAttachmentOpening.label= faxtomail.demande.lastModificationDate.label= faxtomail.demande.lastModified.label= faxtomail.demande.lastModifiedBy.label= 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-04-02 15:46:04 UTC (rev 25) +++ trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-04-03 14:00:27 UTC (rev 26) @@ -56,6 +56,7 @@ faxtomail.demande.fax.label=Fax faxtomail.demande.firstOpened.label=Première ouverture faxtomail.demande.group.button.label=Grouper +faxtomail.demande.lastAttachmentOpening.label=Dernière ouverture de pièce-jointe faxtomail.demande.lastModified.label=Dernière modification faxtomail.demande.mailBody.label=Corps du mail faxtomail.demande.mailFolder.label=Dossier