This is an automated email from the git hooks/post-receive script. New commit to branch feature/9526 in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git commit b42ebec7f8828f0eec2a695ca10d7b102be3f2ff Author: Jean Couteau <jean.couteau@gmail.com> Date: Tue Dec 12 14:08:37 2017 +0100 refs #9526 : Pris par sur le clic droit des demandes sélectionnées - WIP pour Kevin --- .../services/service/MailFolderService.java | 2 + .../services/service/MailFolderServiceImpl.java | 12 +++ .../content/demande/TakenByFormUIHandler.java | 11 ++- .../swing/content/demande/TakenByFormUIModel.java | 23 ++++- .../demande/actions/OpenTakenByFormAction.java | 100 +++++++++++++++++++-- .../i18n/faxtomail-ui-swing_fr_FR.properties | 6 ++ 6 files changed, 144 insertions(+), 10 deletions(-) diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java index a16656e7..2155cd8c 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java @@ -28,6 +28,7 @@ import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.MailFilter; import com.franciaflex.faxtomail.persistence.entities.MailFolder; +import com.franciaflex.faxtomail.persistence.entities.MailFolderTopiaDao; import com.franciaflex.faxtomail.persistence.entities.WaitingState; import com.franciaflex.faxtomail.services.FaxToMailService; @@ -67,4 +68,5 @@ public interface MailFolderService extends FaxToMailService { MailFilter findMailFilter(Email email, Set<String> modifiedProperties, List<Address> recipients); + Collection<FaxToMailUser> getUsersForFolder(String topiaId); } diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java index 6f1f27e9..85e33a11 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java @@ -353,4 +353,16 @@ public class MailFolderServiceImpl extends FaxToMailServiceSupport implements Ma return filter; } + @Override + public Collection<FaxToMailUser> getUsersForFolder(String topiaId) { + MailFolderTopiaDao dao = getPersistenceContext().getMailFolderDao(); + MailFolder mailFolder = dao.forTopiaIdEquals(topiaId) + .findUnique(); + System.out.println(mailFolder); + Hibernate.initialize(mailFolder.getWriteRightUsers()); + System.out.println(mailFolder.getWriteRightUsers()); + Collection<FaxToMailUser> users = mailFolder.getWriteRightUsers(); + return users; + } + } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/TakenByFormUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/TakenByFormUIHandler.java index 0371110c..6c3867fb 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/TakenByFormUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/TakenByFormUIHandler.java @@ -1,6 +1,8 @@ package com.franciaflex.faxtomail.ui.swing.content.demande; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.persistence.entities.MailFolder; +import com.franciaflex.faxtomail.services.service.MailFolderService; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailUIHandler; import jaxx.runtime.validator.swing.SwingValidator; import org.nuiton.jaxx.application.swing.util.Cancelable; @@ -9,10 +11,14 @@ import javax.swing.*; import java.awt.*; import java.util.ArrayList; +import java.util.Collection; import java.util.List; public class TakenByFormUIHandler extends AbstractFaxToMailUIHandler<TakenByFormUIModel, TakenByFormUI> implements Cancelable { + + + @Override public void beforeInit(TakenByFormUI ui) { super.beforeInit(ui); @@ -26,11 +32,8 @@ public class TakenByFormUIHandler extends AbstractFaxToMailUIHandler<TakenByForm public void afterInit(TakenByFormUI takenByFormUI) { initUI(ui); - List<FaxToMailUser> users = new ArrayList<>(); - //TODO JC get users - // users - initBeanFilterableComboBox(ui.getTakenByComboBox(), users, null); + initBeanFilterableComboBox(ui.getTakenByComboBox(), getModel().getUsers(), null); } @Override diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/TakenByFormUIModel.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/TakenByFormUIModel.java index b2b7ea76..460b5406 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/TakenByFormUIModel.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/TakenByFormUIModel.java @@ -4,6 +4,8 @@ package com.franciaflex.faxtomail.ui.swing.content.demande; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import org.jdesktop.beans.AbstractSerializableBean; +import java.util.List; + public class TakenByFormUIModel extends AbstractSerializableBean { public static final String PROPERTY_TAKENBY = "takenBy"; @@ -12,6 +14,10 @@ public class TakenByFormUIModel extends AbstractSerializableBean { protected FaxToMailUser takenBy; + protected List<DemandeUIModel> demandsToTake; + + protected List<FaxToMailUser> users; + protected FaxToMailUser getTakenBy() { return this.takenBy; } @@ -19,5 +25,20 @@ public class TakenByFormUIModel extends AbstractSerializableBean { public void setTakenBy(FaxToMailUser takenBy){ this.takenBy = takenBy; } - + + public List<DemandeUIModel> getDemandsToTake() { + return demandsToTake; + } + + public void setDemandsToTake(List<DemandeUIModel> demandsToTake) { + this.demandsToTake = demandsToTake; + } + + public List<FaxToMailUser> getUsers() { + return users; + } + + public void setUsers(List<FaxToMailUser> users) { + this.users = users; + } } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenTakenByFormAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenTakenByFormAction.java index 401833aa..ae1f9ee2 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenTakenByFormAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenTakenByFormAction.java @@ -2,8 +2,11 @@ package com.franciaflex.faxtomail.ui.swing.content.demande.actions; import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.persistence.entities.MailAction; +import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.persistence.entities.SigningForDomain; import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.services.service.MailFolderService; import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.actions.AbstractFaxToMailAction; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUI; @@ -20,6 +23,8 @@ import javax.swing.*; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -28,14 +33,63 @@ public class OpenTakenByFormAction extends AbstractFaxToMailAction<DemandeListUI protected TakenByFormUI frameContent; protected JFrame frame; + protected List<DemandeUIModel> demandsToTake; + public OpenTakenByFormAction(DemandeListUIHandler handler) { super(handler, false); } @Override + public boolean prepareAction() throws Exception { + boolean result; + + demandsToTake = new ArrayList<>(); + List<DemandeUIModel> currentEmails = getModel().getSelectedEmails(); + + String notTakableDemandTitles = ""; + for (DemandeUIModel demandeUIModel : currentEmails) { + // is the demand takable? + if (!demandeUIModel.isEditable() || + !handler.isActionEnabled(demandeUIModel, MailAction.TAKENBY)) { + notTakableDemandTitles += "- " + demandeUIModel.getTitle() + "<br/>"; + + } else { + demandsToTake.add(demandeUIModel); + } + } + + if (demandsToTake.isEmpty()) { + displayWarningMessage(t("faxtomail.alert.noDemandToTake.title"), + t("faxtomail.alert.noDemandToTake.message", notTakableDemandTitles)); + result = false; + + } else { + String message; + if (!notTakableDemandTitles.isEmpty()) { + message = t("faxtomail.alert.takesWithNotTakableConfirmation.message", notTakableDemandTitles); + + } else if (demandsToTake.size() == 1) { + message = t("faxtomail.alert.takeConfirmation.message"); + + } else { + message = t("faxtomail.alert.takesConfirmation.message"); + } + int i = JOptionPane.showConfirmDialog(null, + message, + t("faxtomail.alert.takeConfirmation.title"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + + result = i == JOptionPane.YES_OPTION; + } + + return result; + } + + @Override public void doAction() throws Exception { - DemandeUIModel demand = getModel().getSelectedEmails().get(0); + DemandeUIModel demand = demandsToTake.get(0); if (StringUtils.isNotBlank(demand.getTopiaId())) { FaxToMailServiceContext serviceContext = getContext().newServiceContext(); @@ -47,13 +101,49 @@ public class OpenTakenByFormAction extends AbstractFaxToMailAction<DemandeListUI frameContent = new TakenByFormUI(getUI()); TakenByFormUIModel model = frameContent.getModel(); - FaxToMailUser takenBy = demand.getTakenBy(); - if (takenBy != null) { - model.setTakenBy(takenBy); - } + model.setDemandsToTake(demandsToTake); + + + + + MailFolderService mailFolderService = getContext().newServiceContext().getMailFolderService(); + + System.out.println(getContext().getCurrentFolderEmails()); + MailFolder folder = demand.getMailFolder(); + System.out.println(folder); + + List<FaxToMailUser> users = (List<FaxToMailUser>)mailFolderService.getUsersForFolder(folder.getTopiaId()); + + + model.setUsers(users); } } + /**@Override + public void doAction() throws Exception { + List<DemandeUIModel> demands = getModel().getSelectedEmails(); + + if (StringUtils.isNotBlank(demand.getTopiaId())) { + FaxToMailServiceContext serviceContext = getContext().newServiceContext(); + Email email = serviceContext.getEmailService().getFullEmailById(demand.getTopiaId(), getContext().getCurrentUser()); + demand.fromEntity(email); + + getContext().setCurrentEmail(demand); + + frameContent = new ReplyFormUI(getUI()); + ReplyFormUIModel model = frameContent.getModel(); + + SigningForDomain signingForDomain = null; + if (!demand.isFax() && demand.getRecipient() != null) { + signingForDomain = getContext().newServiceContext().getConfigurationService().getSigningForEmailAddress(demand.getRecipient()).orNull(); + } + model.setSigning(signingForDomain); + + model.setForward(true); + model.setOriginalDemand(demand); + } + } **/ + @Override public void postSuccessAction() { super.postSuccessAction(); diff --git a/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties b/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties index e5534d98..ce267f90 100644 --- a/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties +++ b/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties @@ -47,8 +47,14 @@ faxtomail.alert.groupConfirmation.message=<html>Êtes vous sûr de vouloir group faxtomail.alert.groupConfirmation.title=Confirmation du groupement faxtomail.alert.noDemandToArchive.message=<html>Les éléments suivants ne peuvent pas être archivés car ils ne sont pas valides \:<br/>%sIl n'y a pas d'autres éléments à archiver.</html> faxtomail.alert.noDemandToArchive.title=Aucun élément à archiver +faxtomail.alert.noDemandToTake.message= +faxtomail.alert.noDemandToTake.title= faxtomail.alert.noDemandToTransmit.message=<html>Les éléments suivants ne seront pas déplacés \:<br/>%sIl n'y a pas d'autres éléments à déplacer.</html> faxtomail.alert.noDemandToTransmit.title=Aucun élément à déplacer +faxtomail.alert.takeConfirmation.message= +faxtomail.alert.takeConfirmation.title= +faxtomail.alert.takesConfirmation.message= +faxtomail.alert.takesWithNotTakableConfirmation.message= faxtomail.alert.transmit.groupedDemandsInSameFolder.message=<html>L'élément %1$s a un ou plusieurs éléments groupés dans le même dossier \:<br/>%2$sVoulez-vous les déplacer aussi ?</html> faxtomail.alert.transmit.groupedDemandsInSameFolder.title=Déplacer les éléments groupés faxtomail.alert.userNotAuthorizedToReadEmail.message=Vous n'avez pas le droit de lire les éléments du dossier %s -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.