Author: kmorin Date: 2014-08-12 18:46:21 +0200 (Tue, 12 Aug 2014) New Revision: 534 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/534 Log: fixes #5532 la fen?\195?\170tre d'ajout d'annotations ne contient pas les ?\195?\169l?\195?\169ments pour mettre en plein ?\195?\169cran/r?\195?\169duire facilement 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/SaveAndOpenDialogAction.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/demande/DemandeListUIHandler.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/pdfeditor/PDFEditorUI.jaxx trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.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/transmit/MailFolderChooserUIHandler.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/FaxToMailUIUtil.java 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/EditAttachmentAction.java 2014-08-12 16:46:21 UTC (rev 534) @@ -84,7 +84,7 @@ pdfEditorUIModel.fromEntity(attachment); pdfEditorUIModel.setDemand(getContext().getCurrentEmail()); - getHandler().openDialog(dialogContent, attachment.getOriginalFileName(), mainUI.getSize()); + getHandler().openModalFrame(dialogContent, attachment.getOriginalFileName(), mainUI.getSize()); pdfEditorUIModel.toEntity(attachment); } Modified: 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveAndOpenDialogAction.java 2014-08-12 16:46:21 UTC (rev 534) @@ -36,20 +36,17 @@ */ public class SaveAndOpenDialogAction extends SaveDemandeAction { - protected boolean modal; protected FaxToMailUI dialogContent; protected String title; protected Dimension dimension; protected boolean takeDemand; public SaveAndOpenDialogAction(DemandeUIHandler handler, - boolean modal, FaxToMailUI dialogContent, String title, Dimension dimension, boolean takeDemand) { super(handler); - this.modal = modal; this.dialogContent = dialogContent; this.title = title; this.dimension = dimension; @@ -73,11 +70,6 @@ super.postSuccessAction(); DemandeUIHandler handler = getHandler(); - if (modal) { - handler.openDialog(dialogContent, title, dimension); - - } else { - handler.openFrame(dialogContent, title, dimension); - } + handler.openModalFrame(dialogContent, title, dimension); } } 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java 2014-08-12 16:46:21 UTC (rev 534) @@ -39,11 +39,7 @@ @Override public void doAction() throws Exception { super.doAction(); - } - - @Override - 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/TransmitAction.java 2014-08-12 16:46:21 UTC (rev 534) @@ -86,4 +86,10 @@ } } } + + @Override + public void postSuccessAction() { + super.postSuccessAction(); + getHandler().closeFrame(); + } } 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2014-08-12 16:46:21 UTC (rev 534) @@ -611,6 +611,6 @@ model.setDemandeUIModels(selectedEmails); MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, model); - openDialog(dialogContent, t("faxtomail.chooseMailFolder.title"), new Dimension(350, 500)); + openModalFrame(dialogContent, t("faxtomail.chooseMailFolder.title"), new Dimension(350, 500)); } } 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java 2014-08-12 16:46:21 UTC (rev 534) @@ -343,7 +343,6 @@ model.setDemandeUIModels(demandes); MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, model); SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), - true, dialogContent, t("faxtomail.chooseMailFolder.title"), new Dimension(350, 500), @@ -365,7 +364,6 @@ boolean take = Boolean.TRUE.equals(selectedFolder.getPrintActionEqualTakeAction()); SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), - true, dialogContent, t("faxtomail.chooseAttachmentToPrint.title"), new Dimension(350, 500), @@ -399,7 +397,6 @@ DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), - false, dialogContent, t("faxtomail.reply.title", currentDemand.getTitle()), new Dimension(800, 600), @@ -414,7 +411,6 @@ SearchToGroupUI dialogContent = new SearchToGroupUI(ui); DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), - false, dialogContent, t("faxtomail.searchToGroup.title", demandeUI.getModel().getTitle()), getContext().getMainUI().getSize(), Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.jaxx 2014-08-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.jaxx 2014-08-12 16:46:21 UTC (rev 534) @@ -98,7 +98,7 @@ </JScrollPane> <JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'> - <JButton id='cancelButton' onActionPerformed='handler.closeDialog()'/> + <JButton id='cancelButton' onActionPerformed='handler.cancel()'/> <JButton id='validateButton'/> </JPanel> </JPanel> \ No newline at end of file Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java 2014-08-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java 2014-08-12 16:46:21 UTC (rev 534) @@ -67,6 +67,7 @@ import com.franciaflex.faxtomail.ui.swing.actions.GenerateAnnotatedAttachmentAction; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailUIHandler; +import org.nuiton.jaxx.application.swing.util.Cancelable; import org.nuiton.jaxx.application.swing.util.CloseableUI; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import com.franciaflex.faxtomail.ui.swing.util.JImagePanel; @@ -88,7 +89,7 @@ * @author Kevin Morin (Code Lutin) * */ -public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIModel, PDFEditorUI> implements CloseableUI { +public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIModel, PDFEditorUI> implements CloseableUI, Cancelable { private static final Log log = LogFactory.getLog(PDFEditorUIHandler.class); @@ -620,4 +621,9 @@ demand.setHistory(email.getHistory()); } } + + @Override + public void cancel() { + closeFrame(); + } } 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java 2014-08-12 16:46:21 UTC (rev 534) @@ -140,7 +140,7 @@ @Override public void cancel() { - closeDialog(); + closeFrame(); } @Override @@ -157,8 +157,8 @@ false, false); getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); - + showInformationMessage("faxtomail.print.success.message"); + closeFrame(); } - } 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/MailFolderChooserUIHandler.java 2014-08-12 16:46:21 UTC (rev 534) @@ -143,7 +143,7 @@ @Override public void cancel() { - closeDialog(); + closeFrame(); } @Override 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-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java 2014-08-12 16:46:21 UTC (rev 534) @@ -60,6 +60,7 @@ import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.editor.bean.BeanUIUtil; import jaxx.runtime.validator.swing.SwingValidator; +import org.nuiton.jaxx.application.swing.action.ApplicationActionUIHandler; import org.nuiton.jaxx.application.swing.util.CloseableUI; import org.apache.commons.logging.Log; @@ -265,26 +266,21 @@ } /** - * Surchargée pour temporairement ajouter un appel à ApplicationUI#onCloseUI on windowClosing. - * - * @deprecated overriden during waiting response for issue : http://nuiton.org/issues/3415 + * Open frame and disable parent frame */ - @Deprecated - @Override - public void openDialog(final ApplicationUI dialogContent, String title, Dimension dim) { - Component topestUI = getTopestUI(); - - final JDialog result; - if (topestUI instanceof Frame) { - result = new JDialog((Frame) topestUI, title, true); - } else { - result = new JDialog((Dialog) topestUI, title, true); + public void openModalFrame(final ApplicationUI dialogContent, String title, Dimension dim) { + JFrame result = getContext().getSecondaryFrame(); + if (result == null) { + result = new JFrame(); + result.setResizable(true); + getContext().setSecondaryFrame(result); } - result.add((Component) dialogContent); - result.setResizable(true); + final JFrame parentContainer = getParentContainer(JFrame.class); + parentContainer.setEnabled(false); - result.setSize(dim); + result.setTitle(title); + result.setContentPane((Container) dialogContent); final AbstractApplicationUIHandler handler = dialogContent.getHandler(); @@ -295,26 +291,31 @@ KeyStroke shortcutClosePopup = getContext().getConfiguration().getShortcutClosePopup(); - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcutClosePopup, "close"); + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( + shortcutClosePopup, "close"); rootPane.getActionMap().put("close", new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { - ((Cancelable) handler).cancel(); + ((org.nuiton.jaxx.application.swing.util.Cancelable) handler).cancel(); } }); } + SwingUtil.center(getContext().getMainUI(), result); + result.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); result.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - closeDialog(); + closeFrame(getContext().getSecondaryFrame(), handler); } @Override public void windowClosed(WindowEvent e) { + parentContainer.setEnabled(true); + Component ui = (Component) e.getSource(); if (log.isDebugEnabled()) { log.debug("Destroy ui " + ui); @@ -324,22 +325,11 @@ }); result.setSize(dim); - SwingUtil.center(topestUI, result); + result.setAlwaysOnTop(true); + SwingUtil.center(parentContainer, result); result.setVisible(true); } - @Override - public void closeDialog() { - JDialog dialog = getParentContainer(JDialog.class); - boolean canClose = true; - if (this instanceof CloseableUI) { - canClose = ((CloseableUI)this).quitUI(); - } - if (canClose) { - dialog.setVisible(false); - } - } - /** * Gros copier/coller de quitScreen() pour appeler runActionAndWait au lieu de saveAction.actionPerformed(null); par defaut * pour tenter de corriger un problème de concurrence entre l'action de sauvegarde de l'email @@ -394,9 +384,20 @@ } public void closeFrame() { - getParentContainer(JFrame.class).dispose(); + JFrame frame = getParentContainer(JFrame.class); + closeFrame(frame, this); } + protected void closeFrame(JFrame frame, AbstractApplicationUIHandler handler) { + boolean canClose = true; + if (this instanceof CloseableUI) { + canClose = ((CloseableUI) this).quitUI(); + } + if (canClose) { + frame.dispose(); + } + } + protected <HL extends HasLabel> void initCheckBoxComboBox(final JComboBox<HL> comboBox, java.util.List<HL> values, java.util.List<HL> selection, Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-08-12 16:40:45 UTC (rev 533) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-08-12 16:46:21 UTC (rev 534) @@ -161,31 +161,33 @@ boolean expanded, boolean leaf, int row, boolean hasFocus) { Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); - FolderTreeNode node = (FolderTreeNode) value; - setEnabled(node.isCanSelect()); + if (FolderTreeNode.class.isAssignableFrom(value.getClass())) { + FolderTreeNode node = (FolderTreeNode) value; + setEnabled(node.isCanSelect()); - // En italic si l'utilsateur n'a pas le droit de lecture (sur un parent par exemple) - Font font = component.getFont(); - if (node.isCanRead()) { - font = font.deriveFont(Font.PLAIN); - } else { - font = font.deriveFont(Font.ITALIC); - } - component.setFont(font); + // En italic si l'utilsateur n'a pas le droit de lecture (sur un parent par exemple) + Font font = component.getFont(); + if (node.isCanRead()) { + font = font.deriveFont(Font.PLAIN); + } else { + font = font.deriveFont(Font.ITALIC); + } + component.setFont(font); - // Affichage en gris par defaut, mais en noir si le dossier est vraiment affecté - // à l'utilisateur - Color foreground; - if (!colorNotAffectedFolders - || context.getCurrentUser().isAffectedFoldersEmpty() - || context.getCurrentUser().containsAffectedFolders(node.getMailFolder())) { + // Affichage en gris par defaut, mais en noir si le dossier est vraiment affecté + // à l'utilisateur + Color foreground; + if (!colorNotAffectedFolders + || context.getCurrentUser().isAffectedFoldersEmpty() + || context.getCurrentUser().containsAffectedFolders(node.getMailFolder())) { - foreground = sel ? Color.WHITE : Color.BLACK; + foreground = sel ? Color.WHITE : Color.BLACK; - } else { - foreground = Color.GRAY; + } else { + foreground = Color.GRAY; + } + component.setForeground(foreground); } - component.setForeground(foreground); return component; }