branch develop updated (cfd3aa8a -> 5d37f548)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git from cfd3aa8a fixes #9988 - Redimmensionnement à l'ouverture d'un élément new cbda83c2 refs #9988 - Redimmensionnement à l'ouverture d'un élément new 5d37f548 refs #9987 The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 5d37f548ac817b1fb6712e664a9a4ec5e5ac7267 Author: jcouteau <couteau@codelutin.com> Date: Sat Jun 23 07:44:27 2018 +0200 refs #9987 commit cbda83c269d7aba8f2cca04455d6bb2c92922d4f Author: jcouteau <couteau@codelutin.com> Date: Thu Jun 21 15:13:09 2018 +0200 refs #9988 - Redimmensionnement à l'ouverture d'un élément Summary of changes: .../faxtomail/ui/swing/FaxToMailUIContext.java | 16 ++++- .../ui/swing/actions/ShowDemandeAction.java | 2 + .../attachment/AttachmentEditorUIHandler.java | 1 - .../attachment/actions/EditAttachmentAction.java | 75 +++++++++++++--------- .../demande/replies/DemandRepliesUIHandler.java | 4 +- .../content/pdfeditor/PDFEditorUIHandler.java | 47 +++++++++----- .../pdfeditor/actions/DisplayPageAction.java | 7 +- .../ui/swing/util/AbstractFaxToMailUIHandler.java | 7 +- 8 files changed, 105 insertions(+), 54 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git commit 5d37f548ac817b1fb6712e664a9a4ec5e5ac7267 Author: jcouteau <couteau@codelutin.com> Date: Sat Jun 23 07:44:27 2018 +0200 refs #9987 --- .../faxtomail/ui/swing/FaxToMailUIContext.java | 16 ++++- .../ui/swing/actions/ShowDemandeAction.java | 2 + .../attachment/AttachmentEditorUIHandler.java | 1 - .../attachment/actions/EditAttachmentAction.java | 75 +++++++++++++--------- .../demande/replies/DemandRepliesUIHandler.java | 4 +- .../content/pdfeditor/PDFEditorUIHandler.java | 47 +++++++++----- .../pdfeditor/actions/DisplayPageAction.java | 7 +- 7 files changed, 99 insertions(+), 53 deletions(-) diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java index 09d711fb..e6d5b0ea 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java @@ -211,6 +211,8 @@ public class FaxToMailUIContext extends AbstractBean implements Closeable, UIMes protected Map<DemandeUIModel, JFrame> demandesFrames = new HashMap<>(); + protected Map<File, JFrame> fileEditorFrames = new HashMap<>(); + //FIXME rustine en attendant de trouver pourquoi ca rame autant protected boolean useFolderCache; @@ -918,7 +920,6 @@ public class FaxToMailUIContext extends AbstractBean implements Closeable, UIMes public JFrame getFrameForDemande(DemandeUIModel demande) { return demandesFrames.get(demande); } - public void setFrameForDemande(DemandeUIModel demande, JFrame frame) { demandesFrames.put(demande, frame); } @@ -927,6 +928,19 @@ public class FaxToMailUIContext extends AbstractBean implements Closeable, UIMes demandesFrames.remove(demande); } + public JFrame getFrameForFile(File file) { + return fileEditorFrames.get(file); + } + + public void setEditorFrameForFile (File file,JFrame frame) { + fileEditorFrames.put(file, frame); + + } + + public void removeFileEditor(File file) { + fileEditorFrames.remove(file); + } + public String getLastDisplayedMailFolder() { return lastDisplayedMailFolder; } 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 69704360..b97c51f0 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 @@ -253,6 +253,7 @@ public class ShowDemandeAction extends AbstractMainUIFaxToMailAction { public void run() { if (frame != null) { frame.toFront(); + frame.setVisible(true); frame = null; } } @@ -263,6 +264,7 @@ public class ShowDemandeAction extends AbstractMainUIFaxToMailAction { }); } else { frame.toFront(); + frame.setVisible(true); } } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java index 35bbb1be..2c3e0b6e 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java @@ -199,7 +199,6 @@ public class AttachmentEditorUIHandler extends AbstractToolbarPopupHandler<Attac AttachmentEditorUIModel model = getModel(); if (model.isEditable() && FaxToMailUIUtil.isFileTypeEditable(attachment.getOriginalFileName())) { - getContext().closeSecondaryFrame(); EditAttachmentAction editAttachmentAction = new EditAttachmentAction(this, attachment); // run Internal to prevent multiple successive execution (#5668) getContext().getActionEngine().runAction(editAttachmentAction); 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 38b9e2ab..5ea296c6 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 @@ -37,6 +37,7 @@ import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentEditorUIM import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorUI; import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorUIModel; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; +import org.nuiton.jaxx.application.swing.action.ApplicationActionUI; import javax.swing.*; import java.awt.event.WindowAdapter; @@ -64,6 +65,12 @@ public class EditAttachmentAction extends AbstractFaxToMailAction<AttachmentEdit setActionDescription(t("faxtomail.action.attachment.edit.tip", attachmentName)); } + @Override + public boolean prepareAction() throws Exception { + getContext().closeSecondaryFrame(); + return super.prepareAction(); + } + @Override public void doAction() throws Exception { getModel().fireAttachmentOpened(attachment, false); @@ -79,41 +86,49 @@ public class EditAttachmentAction extends AbstractFaxToMailAction<AttachmentEdit super.postSuccessAction(); final PDFEditorUI dialogContent = new PDFEditorUI(getUI()); + + MainUI mainUI = getContext().getMainUI(); + frame = getContext().getFrameForFile(attachment.getOriginalFile().getFile()); + if (frame == null){ + frame = getHandler().openFrame(dialogContent, attachment.getOriginalFileName(), mainUI.getSize()); + + getContext().setEditorFrameForFile(attachment.getOriginalFile().getFile(), frame); + + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + dialogContent.getModel().toEntity(attachment); + } + }); + + 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().setActionUI(new ApplicationActionUI(null, getContext())); + } + } + }); + getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); + } + } + }); + } + + getContext().setActionUI(new ApplicationActionUI(frame, getContext())); PDFEditorUIModel pdfEditorUIModel = dialogContent.getModel(); pdfEditorUIModel.fromEntity(attachment); pdfEditorUIModel.setDemand(getContext().getCurrentEmail()); pdfEditorUIModel.setStamps(stamps); - MainUI mainUI = getContext().getMainUI(); - frame = getHandler().openFrame(dialogContent, attachment.getOriginalFileName(), mainUI.getSize()); - - frame.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - dialogContent.getModel().toEntity(attachment); - } - }); - - getContext().addPropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (!getContext().isBusy()) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - //Why is there this bring to front operation, makes UI feel buggy ??? - //bringCurrentDemandToFront(); - - if (frame != null) { - frame.toFront(); - frame = null; - } - } - }); - getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, this); - } - } - }); + frame.setVisible(true); + frame.toFront(); } @Override diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java index 493574e6..847fda35 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java @@ -61,6 +61,7 @@ import javax.mail.internet.MimeUtility; import javax.swing.AbstractCellEditor; import javax.swing.JComponent; import javax.swing.JTable; +import javax.swing.JFrame; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.AbstractTableModel; @@ -233,7 +234,8 @@ public class DemandRepliesUIHandler extends AbstractToolbarPopupHandler<DemandeU replyModel.getMessage().replaceAll("\n", "<br/> ")); replyModel.setMessage(quotedReply); - openFrame(dialogContent, t("faxtomail.reply.forward", message.getSubject()), new Dimension(800, 600)); + JFrame frame = openFrame(dialogContent, t("faxtomail.reply.forward", message.getSubject()), new Dimension(800, 600)); + frame.setVisible(true); } catch (Exception e) { getContext().getErrorHelper().showErrorDialog(t("faxtomail.demandReplies.error"), e); diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java index 093da452..174f2afd 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java @@ -48,6 +48,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.rendering.PDFRenderer; import org.apache.xerces.impl.dv.util.Base64; import org.nuiton.jaxx.application.swing.util.Cancelable; import org.nuiton.jaxx.application.swing.util.CloseableUI; @@ -66,6 +67,7 @@ import java.awt.Insets; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; @@ -87,7 +89,9 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo protected ComponentMover cm = new ComponentMover(); protected ComponentResizer cr = new ComponentResizer(); - protected PDDocument pdDocument; + protected File file; + + protected int numberOfPages; protected PropertyChangeListener busyListener = new PropertyChangeListener() { @@ -214,7 +218,7 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo AttachmentFile attachmentFile = model.getNotNullFile(); if (attachmentFile != null) { - File file = attachmentFile.getFile(); + file = attachmentFile.getFile(); if (!FaxToMailUIUtil.isFileAPDF(attachmentFile)) { try { file = convertFileToPdf(attachmentFile); @@ -228,17 +232,8 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo } if (FaxToMailUIUtil.isFileAPDF(attachmentFile)) { - try { - pdDocument = PDDocument.load(file); - model.setPageNumber(pdDocument.getNumberOfPages()); + model.setPageNumber(getNumberOfPages()); model.setCurrentPageIndex(1); - - } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("error while converting file to pdf", e); - } - getContext().getErrorHelper().showErrorDialog(t("faxtomail.pdfEditor.readPdf.error")); - } } getUI().setCursor(Cursor.getDefaultCursor()); model.firePropertyChanged(PDFEditorUIModel.PROPERTY_CURRENT_PAGE_INDEX, null, 1); @@ -315,7 +310,6 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo @Override public void onCloseUI() { - IOUtils.closeQuietly(pdDocument); getContext().removePropertyChangeListener(FaxToMailUIContext.PROPERTY_BUSY, busyListener); } @@ -450,7 +444,7 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo } protected void displayPage(int pageNb, float previousZoom, int previousRotation) { - if (pageNb < 1 || pageNb > pdDocument.getNumberOfPages()) { + if (pageNb < 1 || pageNb > getNumberOfPages()) { return; } @@ -537,8 +531,29 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo closeFrame(); } - public PDDocument getPdDocument() { - return pdDocument; + public BufferedImage getPage(int pageNumber, float zoom){ + synchronized(PDFEditorUIHandler.class) { + try (PDDocument pdDocument = PDDocument.load(file)) { + PDFRenderer renderer = new PDFRenderer(pdDocument); + return renderer.renderImage(pageNumber - 1, zoom); + } catch (IOException eee) { + log.debug("Error getting page " + pageNumber, eee); + getContext().getErrorHelper().showErrorDialog(t("faxtomail.pdfEditor.readPdf.error")); + return null; + } + } + } + + public synchronized int getNumberOfPages(){ + if (numberOfPages == 0){ + try (PDDocument pdDocument = PDDocument.load(file)){ + numberOfPages = pdDocument.getNumberOfPages(); + } catch (IOException eee){ + log.info("Error getting number of pages", eee); + getContext().getErrorHelper().showErrorDialog(t("faxtomail.pdfEditor.readPdf.error")); + } + } + return numberOfPages; } public ComponentResizer getCr() { diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/actions/DisplayPageAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/actions/DisplayPageAction.java index a7d71426..6413a61e 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/actions/DisplayPageAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/actions/DisplayPageAction.java @@ -36,7 +36,6 @@ import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorUIHandler; import com.franciaflex.faxtomail.ui.swing.content.pdfeditor.PDFEditorUIModel; import com.franciaflex.faxtomail.ui.swing.util.JImagePanel; import jaxx.runtime.swing.ComponentResizer; -import org.apache.pdfbox.rendering.PDFRenderer; import javax.swing.JPanel; import java.awt.Dimension; @@ -65,12 +64,12 @@ public class DisplayPageAction extends AbstractFaxToMailAction<PDFEditorUIModel, @Override public void doAction() throws Exception { + // Thread.sleep(5000); + int rotation = getModel().getRotation(); float zoom = getModel().getZoom(); - PDFRenderer renderer = new PDFRenderer(handler.getPdDocument()); - - BufferedImage image = renderer.renderImage(pageNb - 1, zoom); + BufferedImage image = handler.getPage(pageNb, zoom); int width = image.getWidth(); int height = image.getHeight(); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm