Author: kmorin Date: 2014-08-13 17:56:39 +0200 (Wed, 13 Aug 2014) New Revision: 551 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/551 Log: am?\195?\169lioration diverses Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/AddAttachmentToReplyAction.java Removed: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveAndOpenDialogAction.java Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveFromListAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/CloseApplicationAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/EditAttachmentAction.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/actions/SaveDemandeAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java 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/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/demande/DemandesUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java 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/transmit/MailFolderChooserUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/AddAttachmentToReplyAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/AddAttachmentToReplyAction.java (rev 0) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/AddAttachmentToReplyAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -0,0 +1,46 @@ +package com.franciaflex.faxtomail.ui.swing.actions; + +import com.franciaflex.faxtomail.persistence.entities.Attachment; +import com.franciaflex.faxtomail.persistence.entities.AttachmentFile; +import com.franciaflex.faxtomail.services.service.EmailService; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyAttachmentModel; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUI; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUIHandler; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUIModel; + +/** + * @author Kevin Morin (Code Lutin) + */ +public class AddAttachmentToReplyAction extends AbstractFaxToMailAction<ReplyFormUIModel, ReplyFormUI, ReplyFormUIHandler> { + + protected ReplyAttachmentModel replyAttachmentModel; + + public AddAttachmentToReplyAction(ReplyFormUIHandler handler) { + super(handler, false); + setActionDescription("faxtomail.action.addAttachmentToReply.tip"); + } + + public ReplyAttachmentModel getReplyAttachmentModel() { + return replyAttachmentModel; + } + + public void setReplyAttachmentModel(ReplyAttachmentModel replyAttachmentModel) { + this.replyAttachmentModel = replyAttachmentModel; + } + + @Override + public void doAction() throws Exception { + Attachment attachment = replyAttachmentModel.getAttachment(); + if (replyAttachmentModel.getAttachmentFile() == null && attachment.isPersisted()) { + EmailService service = getContext().newServiceContext().getEmailService(); + boolean original = replyAttachmentModel.isOriginal(); + AttachmentFile file = service.getAttachmentFile(attachment.getTopiaId(), + original); + if (original) { + attachment.setOriginalFile(file); + } else { + attachment.setEditedFile(file); + } + } + } +} Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveFromListAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveFromListAction.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ArchiveFromListAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -26,8 +26,12 @@ import com.franciaflex.faxtomail.persistence.entities.DemandStatus; import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUIHandler; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import javax.swing.*; import java.util.Date; @@ -62,10 +66,39 @@ @Override public void doAction() throws Exception { List<DemandeUIModel> currentEmails = getModel().getSelectedEmails(); + + // 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 + // des droits différents + // les dossiers d'archive ne sont pas visible dans l'arbre des dossiers, mais les archives + // peuvent être consultées dans la recherche + MailFolder folder = currentEmails.get(0).getMailFolder(); + MailFolder archiveChild = null; + do { + if (folder.getChildren() != null) { + Optional<MailFolder> optArchiveChild = Iterables.tryFind(folder.getChildren(), new Predicate<MailFolder>() { + @Override + public boolean apply(MailFolder mailFolder) { + return mailFolder.isArchiveFolder(); + } + }); + if (optArchiveChild.isPresent()) { + archiveChild = optArchiveChild.get(); + } + } + folder = folder.getParent(); + + } while (archiveChild == null && folder != null); + for (DemandeUIModel email : currentEmails) { email.setArchiveDate(new Date()); email.setDemandStatus(DemandStatus.ARCHIVED); email.setTakenBy(null); + // le dossier d'archive peut ne pas exister. Dans ce cas on laisse le mail dans le dossier + // d'origine + if (archiveChild != null) { + email.setMailFolder(archiveChild); + } } modifiedProperties = new String[] { Email.PROPERTY_ARCHIVE_DATE }; Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/CloseApplicationAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/CloseApplicationAction.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/CloseApplicationAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -32,21 +32,18 @@ * * @author kmorin - morin@codelutin.com */ -public class CloseApplicationAction extends AbstractMainUIFaxToMailAction { +public class CloseApplicationAction extends AbstractChangeScreenAction { protected int exitCode = RunFaxToMail.NORMAL_EXIT_CODE; public CloseApplicationAction(MainUIHandler handler) { - super(handler, false); + super(handler, false, null); setActionDescription(t("faxtomail.action.exit.tip")); } - public void setExitCode(int exitCode) { - this.exitCode = exitCode; - } - @Override public void doAction() throws Exception { + super.doAction(); RunFaxToMail.closeFaxToMail(getHandler(), exitCode); } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/EditAttachmentAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/EditAttachmentAction.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/EditAttachmentAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -35,6 +35,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + import static org.nuiton.i18n.I18n.t; /** @@ -46,6 +49,7 @@ private static final Log log = LogFactory.getLog(EditAttachmentAction.class); protected Attachment attachment; + protected PDFEditorUI dialogContent; public EditAttachmentAction(AttachmentEditorUIHandler handler) { super(handler, false); @@ -59,23 +63,28 @@ @Override public void doAction() throws Exception { + getModel().fireAttachmentOpened(attachment, false); + FaxToMailUIUtil.forceAttachmentFileLoading(getContext(), attachment); + + dialogContent = new PDFEditorUI(getUI()); + PDFEditorUIModel pdfEditorUIModel = dialogContent.getModel(); + pdfEditorUIModel.fromEntity(attachment); + pdfEditorUIModel.setDemand(getContext().getCurrentEmail()); } @Override - public void postSuccessAction() { - super.postSuccessAction(); + protected void releaseAction() { + super.releaseAction(); MainUI mainUI = getContext().getMainUI(); - PDFEditorUI dialogContent = new PDFEditorUI(getUI()); - - PDFEditorUIModel pdfEditorUIModel = dialogContent.getModel(); - pdfEditorUIModel.fromEntity(attachment); - pdfEditorUIModel.setDemand(getContext().getCurrentEmail()); - - getHandler().openModalFrame(dialogContent, attachment.getOriginalFileName(), mainUI.getSize()); - //TODO kmorin 20140813 avant, c'était bloquant vu que c'etait un dialog - pdfEditorUIModel.toEntity(attachment); + getHandler().openModalFrame(dialogContent, attachment.getOriginalFileName(), mainUI.getSize()) + .addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + dialogContent.getModel().toEntity(attachment); + } + }); } } \ No newline at end of file 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-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -83,11 +83,10 @@ @Override public void doAction() throws Exception { - AttachmentFile attachmentFile = getModel().getNotNullFile(); + PDFEditorUIModel model = getModel(); + AttachmentFile attachmentFile = model.getNotNullFile(); File file = attachmentFile.getFile(); - PDFEditorUIModel model = getModel(); - InputStream inputStream = new FileInputStream(file); PdfReader pdfReader = new PdfReader(inputStream); @@ -254,9 +253,15 @@ FaxToMailServiceContext serviceContext = getContext().newServiceContext(); AttachmentFile attachmentFileNew = serviceContext.getEmailService().getAttachmentFileFromStream(is); attachmentFileNew.setRotation(rotation); - String fileName = getModel().getNotNullFile().getFilename(); + String fileName = model.getNotNullFile().getFilename(); attachmentFileNew.setFilename(FaxToMailUIUtil.getEditedFileName(fileName)); - getModel().setEditedFile(attachmentFileNew); + model.setEditedFile(attachmentFileNew); + + AttachmentEditorUI parentUI = (AttachmentEditorUI) getUI().getContextValue(JAXXContext.class, JAXXUtil.PARENT); + parentUI.getModel().fireAttachmentEdited(model.toEntity()); + + model.setModify(false); + model.fromEntity(null); } protected int[] computeCoordinates(Component panel, int rotation, float zoom) { @@ -331,8 +336,6 @@ @Override public void postSuccessAction() { super.postSuccessAction(); - - AttachmentEditorUI parentUI = (AttachmentEditorUI) getUI().getContextValue(JAXXContext.class, JAXXUtil.PARENT); - parentUI.getModel().fireAttachmentEdited(getModel().toEntity()); + getHandler().closeFrame(); } } Deleted: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveAndOpenDialogAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveAndOpenDialogAction.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveAndOpenDialogAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -1,75 +0,0 @@ -package com.franciaflex.faxtomail.ui.swing.actions; - -/* - * #%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% - */ - -import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIHandler; -import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; -import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI; - -import java.awt.*; - -/** - * @author Kevin Morin (Code Lutin) - * - */ -public class SaveAndOpenDialogAction extends SaveDemandeAction { - - protected FaxToMailUI dialogContent; - protected String title; - protected Dimension dimension; - protected boolean takeDemand; - - public SaveAndOpenDialogAction(DemandeUIHandler handler, - FaxToMailUI dialogContent, - String title, - Dimension dimension, - boolean takeDemand) { - super(handler); - this.dialogContent = dialogContent; - this.title = title; - this.dimension = dimension; - this.takeDemand = takeDemand; - } - - @Override - public void doAction() throws Exception { - DemandeUIModel model = getModel(); - if (takeDemand && model.getTakenBy() == null) { - model.setTakenBy(getContext().getCurrentUser()); - } - - if (getHandler().getMonitor().wasModified()) { - super.doAction(); - } - } - - @Override - public void postSuccessAction() { - super.postSuccessAction(); - - DemandeUIHandler handler = getHandler(); - handler.openModalFrame(dialogContent, title, dimension); - } -} Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAction.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -54,11 +54,21 @@ */ public class SaveDemandeAction extends AbstractFaxToMailAction<DemandeUIModel, DemandeUI, DemandeUIHandler> { + protected boolean takeIfNotTaken; + public SaveDemandeAction(DemandeUIHandler handler) { super(handler, false); setActionDescription(t("faxtomail.action.save.tip")); } + public boolean isTakeIfNotTaken() { + return takeIfNotTaken; + } + + public void setTakeIfNotTaken(boolean takeIfNotTaken) { + this.takeIfNotTaken = takeIfNotTaken; + } + @Override public void doAction() throws Exception { DemandeUIModel model = getModel(); @@ -75,6 +85,7 @@ Collection<RangeRowModel> rows = model.getValidRangeRowModels(); + //remove null range rows boolean cont = true; while (cont) { try { @@ -101,12 +112,15 @@ } FaxToMailUser currentUser = context.getCurrentUser(); + if (takeIfNotTaken && model.getTakenBy() == null) { + model.setTakenBy(getContext().getCurrentUser()); + } + Email email = model.toEntity(persistedEmail); Collection<Attachment> attachments = model.getAttachment(); String clientCode = model.getClientCode(); BeanMonitor monitor = getHandler().getMonitor(); - String[] modifiedProperties = monitor.getModifiedProperties(); email = serviceContext.getEmailService().saveEmail(email, attachments, clientCode, currentUser, modifiedProperties); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -37,9 +37,8 @@ } @Override - public void doAction() throws Exception { - super.doAction(); + public void postSuccessAction() { + super.postSuccessAction(); getActionEngine().runInternalAction(getContext().getMainUI().getHandler(), GoToPreviousScreenAction.class); } - } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java 2014-08-13 15:56:39 UTC (rev 551) @@ -90,7 +90,11 @@ public void postSuccessAction() { super.postSuccessAction(); MailFolderChooserUIHandler handler = getHandler(); - getActionEngine().runInternalAction(handler, GoToPreviousScreenAction.class); + //FIXME works but ugly + FaxToMailUI parentDemandeListUI = (FaxToMailUI) getUI().getContextValue(JAXXContext.class, JAXXUtil.PARENT); + if (parentDemandeListUI != null && !DemandeListUI.class.isAssignableFrom(parentDemandeListUI.getClass())) { + getActionEngine().runInternalAction(handler, GoToPreviousScreenAction.class); + } handler.closeFrame(); } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java 2014-08-13 15:56:39 UTC (rev 551) @@ -114,6 +114,7 @@ } else { filename = FaxToMailUIUtil.getEditedFileName(attachment.getOriginalFileName()); } + FaxToMailServiceContext serviceContext = context.newServiceContext(); Email email = serviceContext.getEmailService().addToHistory(topiaId, HistoryType.ATTACHMENT_OPENING, @@ -127,6 +128,7 @@ @Override public void onAttachmentEdited(Attachment attachment) { String topiaId = model.getTopiaId(); + //TODO kmorin 20140813 action FaxToMailServiceContext serviceContext = context.newServiceContext(); Email email = serviceContext.getEmailService().addToHistory(topiaId, HistoryType.ATTACHMENT_MODIFICATION, Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java 2014-08-13 15:56:39 UTC (rev 551) @@ -159,6 +159,7 @@ if (file != null) { try { // warning, this not NOT be closed (will be by blob on commit) + //TODO kmorin 20140813 action ? InputStream is = new FileInputStream(file); FaxToMailServiceContext serviceContext = getContext().newServiceContext(); AttachmentFile attachmentFile = serviceContext.getEmailService().getAttachmentFileFromStream(is); @@ -188,11 +189,11 @@ if (model.isEditable() && FaxToMailUIUtil.isFileTypeEditable(attachment.getOriginalFileName())) { editAttachmentAction.setAttachment(attachment); - getContext().getActionFactory().createUIAction(null, editAttachmentAction).actionPerformed(null); + getContext().getActionEngine().runAction(editAttachmentAction); } else if (attachment.getEditedFileName() != null) { openAttachmentAction.setAttachment(attachment, false); - getContext().getActionFactory().createUIAction(null, openAttachmentAction).actionPerformed(null); + getContext().getActionEngine().runAction(openAttachmentAction); } } 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 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2014-08-13 15:56:39 UTC (rev 551) @@ -558,6 +558,7 @@ for (Attachment attachment : demandeUIModel.getAttachment()) { // force lazy loading + // TODO kmorin 20140813 action ? FaxToMailUIUtil.forceAttachmentFileLoading(getContext(), attachment); AttachmentFile attachmentFile = attachment.getEditedFile(); 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-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-08-13 15:56:39 UTC (rev 551) @@ -195,7 +195,7 @@ // init range model final RangeTableModel rangeTableModel = new RangeTableModel(columnModel); - List<RangeRowModel> rangeRowModels = model.getValidRangeRowModels(); + List<RangeRowModel> rangeRowModels = new ArrayList<RangeRowModel>(model.getValidRangeRowModels()); // Collection<RangeRow> rangeRows = model.getRangeRow(); // if (rangeRows != null) { @@ -433,6 +433,8 @@ if (log.isDebugEnabled()) { log.debug("closing: " + ui); } + FaxToMailServiceContext serviceContext = getContext().newServiceContext(); + serviceContext.getEmailService().unlockEmail(getModel().getTopiaId()); clearValidators(); } @@ -454,12 +456,6 @@ getContext().getActionFactory().createLogicAction(this, SaveDemandeAction.class) ); - // mettre ca ici et non dans le close, car pour un onglet, le close n'est pas appelé - if (result) { - FaxToMailServiceContext serviceContext = getContext().newServiceContext(); - serviceContext.getEmailService().unlockEmail(getModel().getTopiaId()); - } - return result; } @@ -520,6 +516,7 @@ @Override public boolean onHideTab(int currentIndex, int newIndex) { closeButtonPopups(); + onCloseUI(); return true; } 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-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-08-13 15:56:39 UTC (rev 551) @@ -688,9 +688,9 @@ } public void setRangeRow(List<RangeRow> rangeRow) { - Object oldValue = null; + ArrayList<RangeRow> oldValue = new ArrayList<RangeRow>(); if (getRangeRow() != null) { - oldValue = new ArrayList<RangeRow>(getRangeRow()); + oldValue.addAll(getRangeRow()); } if (rangeRow == null) { rangeRow = new ArrayList<RangeRow>(); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java 2014-08-13 15:56:39 UTC (rev 551) @@ -37,7 +37,7 @@ import javax.swing.JComponent; import javax.swing.JTabbedPane; -import jaxx.runtime.JAXXContext; +import com.franciaflex.faxtomail.ui.swing.actions.SaveDemandeAction; import jaxx.runtime.JAXXUtil; import jaxx.runtime.validator.swing.SwingValidator; @@ -53,14 +53,12 @@ import org.nuiton.jaxx.application.swing.util.CloseableUI; import com.franciaflex.faxtomail.persistence.entities.Configuration; -import com.franciaflex.faxtomail.persistence.entities.DemandStatus; import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.MailAction; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; import com.franciaflex.faxtomail.ui.swing.actions.ArchiveAction; -import com.franciaflex.faxtomail.ui.swing.actions.SaveAndOpenDialogAction; import com.franciaflex.faxtomail.ui.swing.actions.SaveDemandeAndExitAction; import com.franciaflex.faxtomail.ui.swing.content.print.AttachmentToPrintChooserUI; import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUI; @@ -80,10 +78,10 @@ protected DelegateTabContainerHandler delegateTabHandler; protected Configuration config; + protected SaveDemandeAction saveDemandeAction; @Override public void beforeInit(DemandesUI ui) { - super.beforeInit(ui); DemandeUIModel currentEmail = getContext().getCurrentEmail(); @@ -312,6 +310,8 @@ handler = getTabHandler(newIndex); if (handler != null) { handler.onShowTab(currentIndex, newIndex); + saveDemandeAction = getContext().getActionFactory().createLogicAction((AbstractApplicationUIHandler) handler, + SaveDemandeAction.class); } } if (change) { @@ -337,38 +337,31 @@ public void transmitDemande() { closeButtonPopups(); + saveCurrentDemande(true); + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); List<DemandeUIModel> demandes = Collections.singletonList(demandeUI.getModel()); + MailFolderChooserUIModel model = new MailFolderChooserUIModel(); model.setDemandeUIModels(demandes); MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, model); - - SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), - dialogContent, - t("faxtomail.chooseMailFolder.title"), - new Dimension(350, 500), - true); - getContext().getActionEngine().runAction(action); + openModalFrame(dialogContent, t("faxtomail.chooseMailFolder.title"), new Dimension(350, 500)); } public void print() { closeButtonPopups(); - DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); - AttachmentToPrintChooserUI dialogContent = new AttachmentToPrintChooserUI(ui, demandeUI.getModel()); - MailFolder selectedFolder = getModel().getCurrentDemand().getMailFolder(); while (selectedFolder.getParent() != null && selectedFolder.getPrintActionEqualTakeAction() == null) { selectedFolder = selectedFolder.getParent(); } boolean take = Boolean.TRUE.equals(selectedFolder.getPrintActionEqualTakeAction()); + saveCurrentDemande(take); - SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), - dialogContent, - t("faxtomail.chooseAttachmentToPrint.title"), - new Dimension(350, 500), - take); - getContext().getActionEngine().runAction(action); + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); + AttachmentToPrintChooserUI dialogContent = new AttachmentToPrintChooserUI(ui, demandeUI.getModel()); + + openModalFrame(dialogContent, t("faxtomail.chooseAttachmentToPrint.title"), new Dimension(350, 500)); } public void archive() { @@ -381,6 +374,8 @@ public void reply() { closeButtonPopups(); + saveCurrentDemande(true); + ReplyFormUI dialogContent = new ReplyFormUI(ui); ReplyFormUIModel model = dialogContent.getModel(); DemandeUIModel currentDemand = getModel().getCurrentDemand(); @@ -394,26 +389,24 @@ } model.setTo(sender); - DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); - SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), - dialogContent, - t("faxtomail.reply.title", currentDemand.getTitle()), - new Dimension(800, 600), - true); - getContext().getActionEngine().runAction(action); + openModalFrame(dialogContent, t("faxtomail.reply.title", currentDemand.getTitle()), new Dimension(800, 600)); } public void group() { closeButtonPopups(); + saveCurrentDemande(false); + SearchToGroupUI dialogContent = new SearchToGroupUI(ui); DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); - SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), - dialogContent, - t("faxtomail.searchToGroup.title", demandeUI.getModel().getTitle()), - getContext().getMainUI().getSize(), - false); - getContext().getActionEngine().runAction(action); + openModalFrame(dialogContent, + t("faxtomail.searchToGroup.title", demandeUI.getModel().getTitle()), + getContext().getMainUI().getSize()); } + protected void saveCurrentDemande(boolean takeIfNotTaken) { + saveDemandeAction.setTakeIfNotTaken(takeIfNotTaken); + getContext().getActionEngine().runActionAndWait(saveDemandeAction); + } + } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java 2014-08-13 15:56:39 UTC (rev 551) @@ -65,6 +65,7 @@ DemandeUIModel demand = model.getDemand(); // add demand details + //TODO kmorin 20140813 action ? FaxToMailServiceContext serviceContext = getContext().newServiceContext(); EmailService emailService = serviceContext.getEmailService(); Email email = getModel().getDemand().toEntity(); 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-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java 2014-08-13 15:56:39 UTC (rev 551) @@ -29,6 +29,8 @@ import com.franciaflex.faxtomail.persistence.entities.AttachmentFileImpl; import com.franciaflex.faxtomail.persistence.entities.AttachmentImpl; import com.franciaflex.faxtomail.services.service.EmailService; +import com.franciaflex.faxtomail.ui.swing.actions.AddAttachmentToReplyAction; +import com.franciaflex.faxtomail.ui.swing.actions.OpenAttachmentAction; import com.google.common.base.Strings; import org.apache.commons.io.FileUtils; @@ -90,12 +92,17 @@ private static final Log log = LogFactory.getLog(ReplyFormUIHandler.class); + protected AddAttachmentToReplyAction addAttachmentToReplyAction; + @Override public void beforeInit(ReplyFormUI ui) { - super.beforeInit(ui); + addAttachmentToReplyAction = + getContext().getActionFactory().createLogicAction(this, AddAttachmentToReplyAction.class); + ReplyFormUIModel model = new ReplyFormUIModel(); + //TODO kmorin 20140813 action ? long maxSize = getContext().newServiceContext().getConfigurationService().getEmailMaxSize(); model.setMaxAttachmentLength(maxSize); @@ -240,21 +247,9 @@ if (ReplyAttachmentModel.class.isAssignableFrom(selectedItem.getClass())) { replyAttachmentModel = (ReplyAttachmentModel) selectedItem; + addAttachmentToReplyAction.setReplyAttachmentModel(replyAttachmentModel); + getContext().getActionEngine().runActionAndWait(addAttachmentToReplyAction); - Attachment attachment = replyAttachmentModel.getAttachment(); - if (replyAttachmentModel.getAttachmentFile() == null && attachment.isPersisted()) { - // TODO action ? - EmailService service = getContext().newServiceContext().getEmailService(); - boolean original = replyAttachmentModel.isOriginal(); - AttachmentFile file = service.getAttachmentFile(attachment.getTopiaId(), - original); - if (original) { - attachment.setOriginalFile(file); - } else { - attachment.setEditedFile(file); - } - } - } else if (File.class.isAssignableFrom(selectedItem.getClass())) { File file = (File) selectedItem; @@ -323,7 +318,7 @@ } public void openAttachment(ReplyAttachmentModel attachment) { - +//TODO kmorin 20140813 action ? FaxToMailUIUtil.openFile(getContext(), attachment.getAttachmentFile()); } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIHandler.java 2014-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIHandler.java 2014-08-13 15:56:39 UTC (rev 551) @@ -65,22 +65,18 @@ MailFolderChooserUIModel model = getModel(); - // fixme echatellier 20140808 : pour le dossier courant, on prend celui du premier mai + // fixme echatellier 20140808 : pour le dossier courant, on prend celui du premier mais // ce n'est pas forcement très correct pour la recherche car les demandes peuvent // provenir de dossier différents MailFolder currentMailFolder = model.getDemandeUIModels().get(0).getMailFolder(); - // on recupere seulement les dossiers qui accepte l'ensemble des états d'attentes - // et des types de demande de l'ensemble des demandes + // on recupere seulement les dossiers qui accepte l'ensemble des états d'attentes de l'ensemble des demandes Set<EtatAttente> allEtatsAttentes = new HashSet<EtatAttente>(); Set<DemandType> allDemandTypes = new HashSet<DemandType>(); for (DemandeUIModel demande : model.getDemandeUIModels()) { if (demande.getEtatAttente() != null) { allEtatsAttentes.add(demande.getEtatAttente()); } - if (demande.getDemandType() != null) { - allDemandTypes.add(demande.getDemandType()); - } } FaxToMailServiceContext serviceContext = getContext().newServiceContext(); 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-08-13 15:54:28 UTC (rev 550) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java 2014-08-13 15:56:39 UTC (rev 551) @@ -268,7 +268,7 @@ /** * Open frame and disable parent frame */ - public void openModalFrame(final ApplicationUI dialogContent, String title, Dimension dim) { + public JFrame openModalFrame(final ApplicationUI dialogContent, String title, Dimension dim) { JFrame result = getContext().getSecondaryFrame(); if (result == null) { result = new JFrame(); @@ -278,6 +278,7 @@ final JFrame parentContainer = getParentContainer(JFrame.class); parentContainer.setEnabled(false); + parentContainer.setFocusableWindowState(false); result.setTitle(title); result.setContentPane((Container) dialogContent); @@ -315,6 +316,7 @@ @Override public void windowClosed(WindowEvent e) { parentContainer.setEnabled(true); + parentContainer.setFocusableWindowState(true); Component ui = (Component) e.getSource(); if (log.isDebugEnabled()) { @@ -327,6 +329,8 @@ result.setSize(dim); SwingUtil.center(parentContainer, result); result.setVisible(true); + + return result; } /**