This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository faxtomail. See http://git.codelutin.com/faxtomail.git commit d33398048bc38c2dbe2773946cf623e328a327ef Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 8 15:49:20 2015 +0200 Les demandes s'ouvrent derrière la fenêtre principale (fixes #7518) --- .../ui/swing/actions/ShowDemandeAction.java | 36 +++++++++++++--------- .../faxtomail/ui/swing/content/MainUIHandler.java | 8 +++++ .../attachment/actions/EditAttachmentAction.java | 32 +++++++++++++------ .../OpenMailFolderChooserFromListAction.java | 28 +++++++++++------ .../demande/actions/OpenReplyFormAction.java | 28 +++++++++++------ .../actions/SaveAndOpenModalFrameAction.java | 28 +++++++++++------ .../demande/replies/actions/OpenReplyAction.java | 26 ++++++++++------ .../search/actions/SearchToGroupAction.java | 31 ++++++++++--------- .../ui/swing/util/AbstractFaxToMailUIHandler.java | 17 ++++++++++ 9 files changed, 160 insertions(+), 74 deletions(-) diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java index ada86f0..31e5f66 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java @@ -30,6 +30,7 @@ import com.franciaflex.faxtomail.services.FaxToMailServiceContext; import com.franciaflex.faxtomail.services.service.EmailService; import com.franciaflex.faxtomail.services.service.exceptions.AlreadyLockedMailException; import com.franciaflex.faxtomail.services.service.exceptions.FolderNotReadableException; +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.content.MainUIHandler; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandesUI; @@ -43,7 +44,8 @@ import javax.swing.*; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; - +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -148,6 +150,7 @@ public class ShowDemandeAction extends AbstractMainUIFaxToMailAction { @Override public void doAction() throws Exception { + DemandeUIModel currentEmail = getContext().getCurrentEmail(); FaxToMailServiceContext serviceContext = getContext().newServiceContext(); @@ -216,21 +219,24 @@ public class ShowDemandeAction extends AbstractMainUIFaxToMailAction { } }); - } - } - - @Override - protected void releaseAction() { - super.releaseAction(); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (frame != null) { - frame.toFront(); - frame = null; + getContext().addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (!getContext().isBusy()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (frame != null) { + frame.toFront(); + frame = null; + } + } + }); + getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); + } } - } - }); + }); + } } } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java index 2035969..b8a7545 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java @@ -77,6 +77,7 @@ public class MainUIHandler extends AbstractFaxToMailUIHandler<FaxToMailUIContext ui.setContextValue(context); context.setMainUI(ui); context.setActionUI(new ApplicationActionUI(ui, context)); + context.addPropertyChangeListener(new RemoveablePropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { @@ -88,6 +89,13 @@ public class MainUIHandler extends AbstractFaxToMailUIHandler<FaxToMailUIContext }); ui.setContextValue(ui, MainUI.class.getName()); + ui.addWindowFocusListener(new WindowAdapter() { + @Override + public void windowGainedFocus(WindowEvent e) { + getContext().setActionUI(new ApplicationActionUI(getUI(), getContext())); + } + }); + // ecoute des changements de l'état busy context.addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new RemoveablePropertyChangeListener() { diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/actions/EditAttachmentAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/actions/EditAttachmentAction.java index d4e68db..47bd813 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/actions/EditAttachmentAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/actions/EditAttachmentAction.java @@ -28,6 +28,7 @@ import com.franciaflex.faxtomail.persistence.entities.Attachment; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.Stamp; import com.franciaflex.faxtomail.services.service.UserService; +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.actions.AbstractFaxToMailAction; import com.franciaflex.faxtomail.ui.swing.content.MainUI; import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentEditorUI; @@ -40,6 +41,8 @@ import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import javax.swing.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.Collection; import static org.nuiton.i18n.I18n.t; @@ -90,20 +93,31 @@ public class EditAttachmentAction extends AbstractFaxToMailAction<AttachmentEdit dialogContent.getModel().toEntity(attachment); } }); - } - @Override - protected void releaseAction() { - super.releaseAction(); - SwingUtilities.invokeLater(new Runnable() { + getContext().addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new PropertyChangeListener() { @Override - public void run() { - if (frame != null) { - frame.toFront(); - frame = null; + public void propertyChange(PropertyChangeEvent evt) { + if (!getContext().isBusy()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + getContext().getFrameForDemande(getContext().getCurrentEmail()).toFront(); + + if (frame != null) { + frame.toFront(); + frame = null; + } + } + }); + getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); } } }); + } + + @Override + protected void releaseAction() { + super.releaseAction(); stamps = null; } } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenMailFolderChooserFromListAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenMailFolderChooserFromListAction.java index bd4e991..3b1cd2a 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenMailFolderChooserFromListAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenMailFolderChooserFromListAction.java @@ -25,6 +25,7 @@ package com.franciaflex.faxtomail.ui.swing.content.demande.actions; */ import com.franciaflex.faxtomail.persistence.entities.MailAction; +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.actions.AbstractFaxToMailAction; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUI; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUIHandler; @@ -35,6 +36,8 @@ import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUIMo import javax.swing.*; import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; @@ -97,19 +100,26 @@ public class OpenMailFolderChooserFromListAction extends AbstractFaxToMailAction public void postSuccessAction() { super.postSuccessAction(); frame = getHandler().openModalFrame(frameContent, t("faxtomail.chooseMailFolder.title"), new Dimension(350, 500)); - } - @Override - protected void releaseAction() { - super.releaseAction(); - SwingUtilities.invokeLater(new Runnable() { + getContext().addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new PropertyChangeListener() { @Override - public void run() { - if (frame != null) { - frame.toFront(); - frame = null; + public void propertyChange(PropertyChangeEvent evt) { + if (!getContext().isBusy()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + getContext().getFrameForDemande(getContext().getCurrentEmail()).toFront(); + + if (frame != null) { + frame.toFront(); + frame = null; + } + } + }); + getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); } } }); } + } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenReplyFormAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenReplyFormAction.java index 92a5335..47f5573 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenReplyFormAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/OpenReplyFormAction.java @@ -28,6 +28,7 @@ import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.services.FaxToMailServiceContext; import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.actions.AbstractFaxToMailAction; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUI; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUIHandler; @@ -40,6 +41,8 @@ import org.apache.commons.lang3.StringUtils; import javax.swing.*; import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import static org.nuiton.i18n.I18n.t; @@ -87,19 +90,26 @@ public class OpenReplyFormAction extends AbstractFaxToMailAction<DemandeListUIMo frame = getHandler().openModalFrame(frameContent, t("faxtomail.reply.title", getContext().getCurrentEmail().getTitle()), new Dimension(800, 600)); - } - @Override - protected void releaseAction() { - super.releaseAction(); - SwingUtilities.invokeLater(new Runnable() { + getContext().addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new PropertyChangeListener() { @Override - public void run() { - if (frame != null) { - frame.toFront(); - frame = null; + public void propertyChange(PropertyChangeEvent evt) { + if (!getContext().isBusy()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + getContext().getFrameForDemande(getContext().getCurrentEmail()).toFront(); + + if (frame != null) { + frame.toFront(); + frame = null; + } + } + }); + getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); } } }); } + } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/SaveAndOpenModalFrameAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/SaveAndOpenModalFrameAction.java index 798de13..c2603b8 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/SaveAndOpenModalFrameAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/SaveAndOpenModalFrameAction.java @@ -24,11 +24,14 @@ package com.franciaflex.faxtomail.ui.swing.content.demande.actions; * #L% */ +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandesUIHandler; import org.nuiton.jaxx.application.swing.ApplicationUI; import javax.swing.*; import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; /** * @author Kevin Morin (Code Lutin) @@ -50,19 +53,26 @@ public abstract class SaveAndOpenModalFrameAction<FC extends ApplicationUI> exte public void postSuccessAction() { super.postSuccessAction(); frame = getHandler().openModalFrame(frameContent, getTitle(), getDimension()); - } - @Override - protected void releaseAction() { - super.releaseAction(); - SwingUtilities.invokeLater(new Runnable() { + getContext().addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new PropertyChangeListener() { @Override - public void run() { - if (frame != null) { - frame.toFront(); - frame = null; + public void propertyChange(PropertyChangeEvent evt) { + if (!getContext().isBusy()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + getContext().getFrameForDemande(getContext().getCurrentEmail()).toFront(); + + if (frame != null) { + frame.toFront(); + frame = null; + } + } + }); + getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); } } }); } + } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/actions/OpenReplyAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/actions/OpenReplyAction.java index 4d7b0ee..422caa6 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/actions/OpenReplyAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/actions/OpenReplyAction.java @@ -29,6 +29,7 @@ import com.franciaflex.faxtomail.persistence.entities.Reply; import com.franciaflex.faxtomail.persistence.entities.ReplyContent; import com.franciaflex.faxtomail.services.FaxToMailServiceContext; import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.actions.AbstractFaxToMailAction; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.content.demande.replies.DemandRepliesUI; @@ -46,6 +47,8 @@ import javax.mail.Message; import javax.mail.internet.MimeMessage; import javax.swing.*; import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.nio.charset.Charset; import static org.nuiton.i18n.I18n.t; @@ -115,19 +118,24 @@ public class OpenReplyAction extends AbstractFaxToMailAction<DemandeUIModel, Dem frame = getHandler().openModalFrame(frameContent, t("faxtomail.reply.title", getModel().getTitle()), new Dimension(800, 600)); - } - @Override - protected void releaseAction() { - super.releaseAction(); - SwingUtilities.invokeLater(new Runnable() { + getContext().addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new PropertyChangeListener() { @Override - public void run() { - if (frame != null) { - frame.toFront(); - frame = null; + public void propertyChange(PropertyChangeEvent evt) { + if (!getContext().isBusy()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (frame != null) { + frame.toFront(); + frame = null; + } + } + }); + getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); } } }); } + } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/actions/SearchToGroupAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/actions/SearchToGroupAction.java index 264056a..4751817 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/actions/SearchToGroupAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/actions/SearchToGroupAction.java @@ -25,14 +25,12 @@ package com.franciaflex.faxtomail.ui.swing.content.search.actions; */ import com.franciaflex.faxtomail.persistence.entities.Email; -import com.franciaflex.faxtomail.persistence.entities.MailFolder; -import com.franciaflex.faxtomail.persistence.entities.RangeRow; import com.franciaflex.faxtomail.persistence.entities.SearchFilter; import com.franciaflex.faxtomail.persistence.entities.WaitingState; import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.actions.AbstractFaxToMailAction; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; -import com.franciaflex.faxtomail.ui.swing.content.demande.RangeRowModel; import com.franciaflex.faxtomail.ui.swing.content.search.SearchToGroupUI; import com.franciaflex.faxtomail.ui.swing.content.search.SearchToGroupUIHandler; import com.franciaflex.faxtomail.ui.swing.content.search.SearchUIModel; @@ -42,8 +40,9 @@ import org.nuiton.topia.persistence.TopiaEntities; import org.nuiton.util.pagination.PaginationResult; import javax.swing.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -89,20 +88,24 @@ public class SearchToGroupAction extends AbstractFaxToMailAction<SearchUIModel, model.setResults(result); model.setPaginationParameter(paginationResult.getCurrentPage()); model.setPaginationResult(paginationResult); - } - - @Override - protected void releaseAction() { - super.releaseAction(); - final JFrame frame = getUI().getParentContainer(JFrame.class); - SwingUtilities.invokeLater(new Runnable() { + getContext().addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new PropertyChangeListener() { @Override - public void run() { - if (frame != null) { - frame.toFront(); + public void propertyChange(PropertyChangeEvent evt) { + if (!getContext().isBusy()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + final JFrame frame = getUI().getParentContainer(JFrame.class); + if (frame != null) { + frame.toFront(); + } + } + }); + getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); } } }); } + } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java index 37cf2be..156421a 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java @@ -48,6 +48,7 @@ import org.nuiton.jaxx.application.ApplicationDataUtil; import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; import org.nuiton.jaxx.application.swing.ApplicationUI; import org.nuiton.jaxx.application.swing.action.AbstractApplicationAction; +import org.nuiton.jaxx.application.swing.action.ApplicationActionUI; import org.nuiton.jaxx.application.swing.table.ColumnIdentifier; import org.nuiton.jaxx.application.swing.util.Cancelable; import org.nuiton.jaxx.application.swing.util.CloseableUI; @@ -240,6 +241,14 @@ public abstract class AbstractFaxToMailUIHandler<M, UI extends FaxToMailUI<M, ?> }); + result.addWindowFocusListener(new WindowAdapter() { + @Override + public void windowGainedFocus(WindowEvent e) { + log.warn("openframe : focus gained"); + getContext().setActionUI(new ApplicationActionUI(result, getContext())); + } + }); + getContext().getSwingSession().add(result, true); result.setVisible(true); @@ -310,6 +319,14 @@ public abstract class AbstractFaxToMailUIHandler<M, UI extends FaxToMailUI<M, ?> } }); + result.addWindowFocusListener(new WindowAdapter() { + @Override + public void windowGainedFocus(WindowEvent e) { + log.warn("openmodalframe : focus gained"); + getContext().setActionUI(new ApplicationActionUI(result, getContext())); + } + }); + getContext().getSwingSession().add(result, true); result.setVisible(true); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.