This is an automated email from the git hooks/post-receive script. New commit to branch feature/7424 in repository faxtomail. See http://git.codelutin.com/faxtomail.git commit addb08a9f37064335721d15b478799ab19550c40 Author: Kevin Morin <morin@codelutin.com> Date: Sat Aug 15 07:34:08 2015 +0200 - finalisation de l'interface d'admin - ajout des tampons dans l'éditeur de PDF (fixes #7424) --- .../src/main/xmi/faxtomail.properties | 6 +- faxtomail-persistence/src/main/xmi/faxtomail.zargo | Bin 32024 -> 32016 bytes .../services/service/MailFolderServiceImpl.java | 2 +- .../h2/V1_4_0_150811__add_pdf_editor_stamps.sql | 2 +- .../V1_4_0_150811__add_pdf_editor_stamps.sql | 2 +- .../actions/GenerateAnnotatedAttachmentAction.java | 2 +- .../content/pdfeditor/PDFEditorStampImageUI.css | 35 +++ ...StampTextUI.jaxx => PDFEditorStampImageUI.jaxx} | 33 +-- .../content/pdfeditor/PDFEditorStampTextUI.jaxx | 2 +- .../content/pdfeditor/PDFEditorUIHandler.java | 293 ++++++++++++++------- .../swing/content/pdfeditor/PDFEditorUIModel.java | 29 +- .../web/action/admin/ConfigurationAction.java | 9 + .../WEB-INF/content/admin/configuration-input.jsp | 31 ++- .../src/main/webapp/js/configuration.js | 49 +++- pom.xml | 2 +- 15 files changed, 339 insertions(+), 158 deletions(-) diff --git a/faxtomail-persistence/src/main/xmi/faxtomail.properties b/faxtomail-persistence/src/main/xmi/faxtomail.properties index 11ab35c..f101632 100644 --- a/faxtomail-persistence/src/main/xmi/faxtomail.properties +++ b/faxtomail-persistence/src/main/xmi/faxtomail.properties @@ -131,8 +131,4 @@ com.franciaflex.faxtomail.persistence.entities.MailLock.attribute.lockOn.tagvalu com.franciaflex.faxtomail.persistence.entities.MailLock.attribute.lockOn.stereotype=unique # BrandsForDomain -com.franciaflex.faxtomail.persistence.entities.BrandsForDomain.attribute.domainName.tagvalue.notNull=true - -#Stamp -com.franciaflex.faxtomail.persistence.entities.Stamp.attribute.image.tagValue.hibernateAttributeType=binary -com.franciaflex.faxtomail.persistence.entities.Stamp.attribute.image.tagvalue.length=9999999 \ No newline at end of file +com.franciaflex.faxtomail.persistence.entities.BrandsForDomain.attribute.domainName.tagvalue.notNull=true \ No newline at end of file diff --git a/faxtomail-persistence/src/main/xmi/faxtomail.zargo b/faxtomail-persistence/src/main/xmi/faxtomail.zargo index 0ab28c0..2658cec 100644 Binary files a/faxtomail-persistence/src/main/xmi/faxtomail.zargo and b/faxtomail-persistence/src/main/xmi/faxtomail.zargo differ 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 13c7b87..592863d 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 @@ -357,7 +357,7 @@ public class MailFolderServiceImpl extends FaxToMailServiceSupport implements Ma @Override public Collection<Stamp> getPdfEditorStamps(String mailFolderId) { MailFolder folder = getMailFolder(mailFolderId); - while (folder != null && !folder.isUseCurrentLevelPdfEditorStamps()) { + while (folder.getParent() != null && !folder.isUseCurrentLevelPdfEditorStamps()) { folder = folder.getParent(); } diff --git a/faxtomail-service/src/main/resources/db/migration/h2/V1_4_0_150811__add_pdf_editor_stamps.sql b/faxtomail-service/src/main/resources/db/migration/h2/V1_4_0_150811__add_pdf_editor_stamps.sql index 1fafc64..b65551e 100644 --- a/faxtomail-service/src/main/resources/db/migration/h2/V1_4_0_150811__add_pdf_editor_stamps.sql +++ b/faxtomail-service/src/main/resources/db/migration/h2/V1_4_0_150811__add_pdf_editor_stamps.sql @@ -6,7 +6,7 @@ create table STAMP ( topiaCreateDate timestamp, label longvarchar, description longvarchar, - image binary(9999999), + image longvarchar, text longvarchar, primary key (topiaId) ); diff --git a/faxtomail-service/src/main/resources/db/migration/sqlserver/V1_4_0_150811__add_pdf_editor_stamps.sql b/faxtomail-service/src/main/resources/db/migration/sqlserver/V1_4_0_150811__add_pdf_editor_stamps.sql index fe74f52..103193b 100644 --- a/faxtomail-service/src/main/resources/db/migration/sqlserver/V1_4_0_150811__add_pdf_editor_stamps.sql +++ b/faxtomail-service/src/main/resources/db/migration/sqlserver/V1_4_0_150811__add_pdf_editor_stamps.sql @@ -6,7 +6,7 @@ create table STAMP ( topiaCreateDate datetime2, label varchar(MAX), description varchar(MAX), - image varbinary(MAX), + image varchar(MAX), text varchar(MAX), primary key (topiaId) ); diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java index 92188eb..48446c8 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java @@ -118,7 +118,7 @@ public class GenerateAnnotatedAttachmentAction extends AbstractFaxToMailAction<P addHighlightToPdf(zoom, rotation, cb, panel); } - for (PDFEditorStampTextUI panel : page.getStamps()) { + for (PDFEditorStampTextUI panel : page.getTextStamps()) { addStampToPdf(zoom, rotation, cb, panel); } } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampImageUI.css b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampImageUI.css new file mode 100644 index 0000000..30c5a77 --- /dev/null +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampImageUI.css @@ -0,0 +1,35 @@ +/* + * #%L + * FaxToMail :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Mac-Groupe, 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 o + * 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% + */ +#stampPanel { + scaleImageToFitPanel: true; +} + +#removeButton { + opaque: false; + background: { null }; + text: " X "; + border : { BorderFactory.createLineBorder(Color.BLACK, 1, false) }; + contentAreaFilled: false; + focusPainted: false; +} diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampTextUI.jaxx b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampImageUI.jaxx similarity index 55% copy from faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampTextUI.jaxx copy to faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampImageUI.jaxx index 297e52e..3191640 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampTextUI.jaxx +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampImageUI.jaxx @@ -21,7 +21,9 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> -<JPanel id='stampPanel' layout='{new BorderLayout()}' onComponentResized="pack()"> +<com.franciaflex.faxtomail.ui.swing.util.JImagePanel + id='stampPanel' + layout="{new java.awt.FlowLayout(java.awt.FlowLayout.TRAILING, 0, 0)}"> <import> java.awt.Color @@ -37,19 +39,6 @@ <script><![CDATA[ - public static final int DEFAULT_FONT_SIZE = 12; - - protected void pack() { - JPanel container = getParentContainer(JPanel.class); - Point location = getLocation(); - Insets containerInsets = container.getInsets(); - Dimension size = getPreferredSize(); - setBounds(location.x + containerInsets.left, - location.y + containerInsets.top, - size.width, // no real logical reason for 10, but otherwise, the text is sometimes cut in the end - size.height); - } - protected void removeStamp() { JPanel container = getParentContainer(JPanel.class); container.remove(this); @@ -58,17 +47,7 @@ ]]></script> - <String id="text" javaBean=""/> - <Float id="zoom" javaBean="1.0f"/> - - <JPanel layout='{ new BorderLayout() }' - constraints="BorderLayout.EAST"> - <JButton id="removeButton" - constraints="BorderLayout.NORTH" - onActionPerformed="removeStamp()"/> - </JPanel> - - <JLabel id="stampText" - constraints="BorderLayout.CENTER"/> + <JButton id="removeButton" + onActionPerformed="removeStamp()"/> -</JPanel> +</com.franciaflex.faxtomail.ui.swing.util.JImagePanel> diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampTextUI.jaxx b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampTextUI.jaxx index 297e52e..9ce60d3 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampTextUI.jaxx +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorStampTextUI.jaxx @@ -46,7 +46,7 @@ Dimension size = getPreferredSize(); setBounds(location.x + containerInsets.left, location.y + containerInsets.top, - size.width, // no real logical reason for 10, but otherwise, the text is sometimes cut in the end + size.width, size.height); } 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 0fd74c3..b90c4ae 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.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; @@ -129,7 +130,10 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo currentPage.addHighlighter((PDFEditorHighlighterUI) child); } else if (childClass.isAssignableFrom(PDFEditorStampTextUI.class)) { - currentPage.addStamp((PDFEditorStampTextUI) child); + currentPage.addTextStamp((PDFEditorStampTextUI) child); + + } else if (childClass.isAssignableFrom(PDFEditorStampImageUI.class)) { + currentPage.addImageStamp((PDFEditorStampImageUI) child); } } @@ -151,7 +155,10 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo currentPage.removeHighlighter((PDFEditorHighlighterUI) child); } else if (childClass.isAssignableFrom(PDFEditorStampTextUI.class)) { - currentPage.removeStamp((PDFEditorStampTextUI) child); + currentPage.removeTextStamp((PDFEditorStampTextUI) child); + + } else if (childClass.isAssignableFrom(PDFEditorStampImageUI.class)) { + currentPage.removeImageStamp((PDFEditorStampImageUI) child); } } }); @@ -344,10 +351,33 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo } public void addStamp(Stamp stamp, int x, int y) { - PDFEditorStampTextUI stampUI = new PDFEditorStampTextUI(); - stampUI.setText(stamp.getText()); - stampUI.setZoom(getModel().getZoom()); - addPanel(stampUI, x, y); + + float zoom = getModel().getZoom(); + + if (stamp.getImage() != null) { + String base64Image = stamp.getImage().split(",")[1]; + byte[] imageContent = Base64.decode(base64Image); + ImageIcon imageIcon = new ImageIcon(imageContent); + + PDFEditorStampImageUI stampUI = new PDFEditorStampImageUI(); + Image image = imageIcon.getImage(); + stampUI.setImage(image); + + int scaledWidth = (int) (image.getWidth(null) * zoom); + int scaledHeight = (int) (image.getHeight(null) * zoom); + Dimension scaledSize = new Dimension(scaledWidth, scaledHeight); + stampUI.setSize(scaledSize); + stampUI.setPreferredSize(scaledSize); + + addPanel(stampUI, x, y); + + } else { + PDFEditorStampTextUI stampUI = new PDFEditorStampTextUI(); + stampUI.setText(stamp.getText()); + stampUI.setZoom(zoom); + addPanel(stampUI, x, y); + } + } protected void addPanel(JPanel panel, int x, int y) { @@ -423,136 +453,206 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo Page p = getModel().getPage(pageNb); for (PDFEditorNoteUI panel : p.getNotes()) { - panel.setVisible(true); + displayPageNote(zoom, insets, rect, zoomRatio, rotationDiff, panel); + } - panel.setZoom(zoom); - Rectangle bounds = panel.getBounds(); - int x, y; + boolean orientation180 = Math.abs(rotationDiff) % 180 == 0; - if (rotationDiff == 0) { - x = bounds.x; - y = bounds.y; + for (PDFEditorCrossUI panel : p.getCrosses()) { + displayPageCross(insets, rect, zoomRatio, rotationDiff, orientation180, panel); + } - } else if (rotationDiff == 90 || rotationDiff == -270) { - x = rect.width - bounds.height / 2 - bounds.width / 2 - bounds.y; - y = bounds.x + bounds.width / 2 - bounds.height / 2; + List<PDFEditorLineUI> lines = p.getLines(); + cr.deregisterComponent(lines.toArray(new PDFEditorLineUI[lines.size()])); - } else { - x = bounds.y + bounds.height / 2 - bounds.width / 2; - y = rect.height - bounds.height / 2 - bounds.width / 2 - bounds.x; - } + for (PDFEditorLineUI panel : lines) { + displayPageLine(insets, rect, zoomRatio, rotationDiff, orientation180, panel); + } - panel.setBounds((int) (zoomRatio * x) + insets.left, - (int) (zoomRatio * y) + insets.top, - (int) (zoomRatio * bounds.width), (int) (zoomRatio * bounds.height)); + for (PDFEditorHighlighterUI panel : p.getHighlighters()) { + displayPageHighlighter(insets, rect, zoomRatio, rotationDiff, orientation180, panel); + } + for (PDFEditorStampTextUI panel : p.getTextStamps()) { + displayPageTextStamp(zoom, insets, rect, zoomRatio, rotationDiff, panel); } - boolean orientation180 = Math.abs(rotationDiff) % 180 == 0; + for (PDFEditorStampImageUI panel : p.getImageStamps()) { + displayPageImageStamp(zoom, insets, rect, zoomRatio, rotationDiff, panel); + } - for (PDFEditorCrossUI panel : p.getCrosses()) { - panel.setVisible(true); + container.updateUI(); - Rectangle bounds = panel.getBounds(); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("error while displaying pdf", e); + } + getContext().getErrorHelper().showErrorDialog(t("faxtomail.pdfEditor.readPdf.error")); + } + } - int newWidth = orientation180 ? bounds.width : bounds.height; - int newHeight = orientation180 ? bounds.height : bounds.width; + protected void displayPageNote(float zoom, Insets insets, Rectangle rect, float zoomRatio, int rotationDiff, PDFEditorNoteUI panel) { + panel.setVisible(true); - int x, y; + panel.setZoom(zoom); + Rectangle bounds = panel.getBounds(); + int x, y; - if (rotationDiff == 0) { - x = bounds.x; - y = bounds.y; + if (rotationDiff == 0) { + x = bounds.x; + y = bounds.y; - } else if (rotationDiff == 90 || rotationDiff == -270) { - x = rect.width - newWidth - bounds.y; - y = bounds.x; + } else if (rotationDiff == 90 || rotationDiff == -270) { + x = rect.width - bounds.height / 2 - bounds.width / 2 - bounds.y; + y = bounds.x + bounds.width / 2 - bounds.height / 2; - } else { - x = bounds.y; - y = rect.height - newHeight - bounds.x; - } + } else { + x = bounds.y + bounds.height / 2 - bounds.width / 2; + y = rect.height - bounds.height / 2 - bounds.width / 2 - bounds.x; + } - panel.setBounds((int) (zoomRatio * x) + insets.left, - (int) (zoomRatio * y) + insets.top, - (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight)); + panel.setBounds((int) (zoomRatio * x) + insets.left, + (int) (zoomRatio * y) + insets.top, + (int) (zoomRatio * bounds.width), (int) (zoomRatio * bounds.height)); + } - } + protected void displayPageHighlighter(Insets insets, Rectangle rect, float zoomRatio, int rotationDiff, boolean orientation180, PDFEditorHighlighterUI panel) { + panel.setVisible(true); - List<PDFEditorLineUI> lines = p.getLines(); - cr.deregisterComponent(lines.toArray(new PDFEditorLineUI[lines.size()])); + Rectangle bounds = panel.getBounds(); - for (PDFEditorLineUI panel : lines) { - panel.setVisible(true); + int newWidth = orientation180 ? bounds.width : bounds.height; + int newHeight = orientation180 ? bounds.height : bounds.width; - Rectangle bounds = panel.getBounds(); + int x, y; - boolean horizontal = panel.isHorizontal(); - panel.setHorizontal(orientation180 ? horizontal : !horizontal); + if (rotationDiff == 0) { + x = bounds.x; + y = bounds.y; - int newWidth = orientation180 ? bounds.width : bounds.height; - int newHeight = orientation180 ? bounds.height : bounds.width; + } else if (rotationDiff == 90 || rotationDiff == -270) { + x = rect.width - newWidth - bounds.y; + y = bounds.x; - int x, y; + } else { + x = bounds.y; + y = rect.height - newHeight - bounds.x; + } - if (rotationDiff == 0) { - x = bounds.x; - y = bounds.y; + panel.setBounds((int) (zoomRatio * x) + insets.left, + (int) (zoomRatio * y) + insets.top, + (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight)); + } - } else if (rotationDiff == 90 || rotationDiff == -270) { - x = rect.width - newWidth - bounds.y; - y = bounds.x; + protected void displayPageLine(Insets insets, Rectangle rect, float zoomRatio, int rotationDiff, boolean orientation180, PDFEditorLineUI panel) { + panel.setVisible(true); - } else { - x = bounds.y; - y = rect.height - newHeight - bounds.x; - } + Rectangle bounds = panel.getBounds(); - panel.setBounds((int) (zoomRatio * x) + insets.left, - (int) (zoomRatio * y) + insets.top, - (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight)); + boolean horizontal = panel.isHorizontal(); + panel.setHorizontal(orientation180 ? horizontal : !horizontal); - cr.registerComponent(panel.isHorizontal() ? ComponentResizer.DIRECTION_HORIZONTAL : ComponentResizer.DIRECTION_VERTICAL, - panel); - } + int newWidth = orientation180 ? bounds.width : bounds.height; + int newHeight = orientation180 ? bounds.height : bounds.width; - for (PDFEditorHighlighterUI panel : p.getHighlighters()) { - panel.setVisible(true); + int x, y; - Rectangle bounds = panel.getBounds(); + if (rotationDiff == 0) { + x = bounds.x; + y = bounds.y; - int newWidth = orientation180 ? bounds.width : bounds.height; - int newHeight = orientation180 ? bounds.height : bounds.width; + } else if (rotationDiff == 90 || rotationDiff == -270) { + x = rect.width - newWidth - bounds.y; + y = bounds.x; - int x, y; + } else { + x = bounds.y; + y = rect.height - newHeight - bounds.x; + } - if (rotationDiff == 0) { - x = bounds.x; - y = bounds.y; + panel.setBounds((int) (zoomRatio * x) + insets.left, + (int) (zoomRatio * y) + insets.top, + (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight)); - } else if (rotationDiff == 90 || rotationDiff == -270) { - x = rect.width - newWidth - bounds.y; - y = bounds.x; + cr.registerComponent(panel.isHorizontal() ? ComponentResizer.DIRECTION_HORIZONTAL : ComponentResizer.DIRECTION_VERTICAL, + panel); + } - } else { - x = bounds.y; - y = rect.height - newHeight - bounds.x; - } + protected void displayPageCross(Insets insets, Rectangle rect, float zoomRatio, int rotationDiff, boolean orientation180, PDFEditorCrossUI panel) { + panel.setVisible(true); - panel.setBounds((int) (zoomRatio * x) + insets.left, - (int) (zoomRatio * y) + insets.top, - (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight)); + Rectangle bounds = panel.getBounds(); - } + int newWidth = orientation180 ? bounds.width : bounds.height; + int newHeight = orientation180 ? bounds.height : bounds.width; - container.updateUI(); + int x, y; - } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("error while displaying pdf", e); - } - getContext().getErrorHelper().showErrorDialog(t("faxtomail.pdfEditor.readPdf.error")); + if (rotationDiff == 0) { + x = bounds.x; + y = bounds.y; + + } else if (rotationDiff == 90 || rotationDiff == -270) { + x = rect.width - newWidth - bounds.y; + y = bounds.x; + + } else { + x = bounds.y; + y = rect.height - newHeight - bounds.x; + } + + panel.setBounds((int) (zoomRatio * x) + insets.left, + (int) (zoomRatio * y) + insets.top, + (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight)); + } + + protected void displayPageTextStamp(float zoom, Insets insets, Rectangle rect, float zoomRatio, int rotationDiff, PDFEditorStampTextUI panel) { + panel.setVisible(true); + + panel.setZoom(zoom); + Rectangle bounds = panel.getBounds(); + int x, y; + + if (rotationDiff == 0) { + x = bounds.x; + y = bounds.y; + + } else if (rotationDiff == 90 || rotationDiff == -270) { + x = rect.width - bounds.height / 2 - bounds.width / 2 - bounds.y; + y = bounds.x + bounds.width / 2 - bounds.height / 2; + + } else { + x = bounds.y + bounds.height / 2 - bounds.width / 2; + y = rect.height - bounds.height / 2 - bounds.width / 2 - bounds.x; } + + panel.setBounds((int) (zoomRatio * x) + insets.left, + (int) (zoomRatio * y) + insets.top, + (int) (zoomRatio * bounds.width), (int) (zoomRatio * bounds.height)); + } + + protected void displayPageImageStamp(float zoom, Insets insets, Rectangle rect, float zoomRatio, int rotationDiff, PDFEditorStampImageUI panel) { + panel.setVisible(true); + + Rectangle bounds = panel.getBounds(); + int x, y; + + if (rotationDiff == 0) { + x = bounds.x; + y = bounds.y; + + } else if (rotationDiff == 90 || rotationDiff == -270) { + x = rect.width - bounds.height / 2 - bounds.width / 2 - bounds.y; + y = bounds.x + bounds.width / 2 - bounds.height / 2; + + } else { + x = bounds.y + bounds.height / 2 - bounds.width / 2; + y = rect.height - bounds.height / 2 - bounds.width / 2 - bounds.x; + } + + panel.setBounds((int) (zoomRatio * x) + insets.left, + (int) (zoomRatio * y) + insets.top, + (int) (zoomRatio * bounds.width), (int) (zoomRatio * bounds.height)); } protected void updateStamps(Collection<Stamp> stamps) { @@ -565,6 +665,7 @@ public class PDFEditorUIHandler extends AbstractFaxToMailUIHandler<PDFEditorUIMo for (Stamp stamp : stamps) { JToggleButton button = new JToggleButton(stamp.getLabel(), stampIcon); + button.setToolTipText(stamp.getDescription()); button.putClientProperty("$value", stamp); actionGroup.add(button); diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java index 2a2ca5f..dc47f19 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java @@ -68,7 +68,8 @@ public class PDFEditorUIModel extends AbstractFaxToMailBeanUIModel<Attachment, P protected List<PDFEditorCrossUI> crosses = new ArrayList<>(); protected List<PDFEditorLineUI> lines = new ArrayList<>(); protected List<PDFEditorHighlighterUI> highlighters = new ArrayList<>(); - protected List<PDFEditorStampTextUI> stamps = new ArrayList<>(); + protected List<PDFEditorStampTextUI> textStamps = new ArrayList<>(); + protected List<PDFEditorStampImageUI> imageStamps = new ArrayList<>(); public List<PDFEditorNoteUI> getNotes() { return notes; @@ -126,17 +127,31 @@ public class PDFEditorUIModel extends AbstractFaxToMailBeanUIModel<Attachment, P setModify(true); } - public List<PDFEditorStampTextUI> getStamps() { - return stamps; + public List<PDFEditorStampTextUI> getTextStamps() { + return textStamps; } - public void addStamp(PDFEditorStampTextUI stamp) { - stamps.add(stamp); + public void addTextStamp(PDFEditorStampTextUI stamp) { + textStamps.add(stamp); setModify(true); } - public void removeStamp(PDFEditorStampTextUI stamp) { - stamps.remove(stamp); + public void removeTextStamp(PDFEditorStampTextUI stamp) { + textStamps.remove(stamp); + setModify(true); + } + + public List<PDFEditorStampImageUI> getImageStamps() { + return imageStamps; + } + + public void addImageStamp(PDFEditorStampImageUI stamp) { + imageStamps.add(stamp); + setModify(true); + } + + public void removeImageStamp(PDFEditorStampImageUI stamp) { + imageStamps.remove(stamp); setModify(true); } } diff --git a/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java b/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java index 317d64e..d1f96b5 100644 --- a/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java +++ b/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java @@ -45,6 +45,8 @@ import com.franciaflex.faxtomail.services.service.UserService; import com.franciaflex.faxtomail.web.FaxToMailActionSupport; import com.google.gson.reflect.TypeToken; import com.opensymphony.xwork2.Preparable; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.InterceptorRefs; @@ -66,6 +68,11 @@ import java.util.Map; }) public class ConfigurationAction extends FaxToMailActionSupport implements Preparable { + /** + * Logger. + */ + private static final Log log = LogFactory.getLog(ConfigurationAction.class); + protected ConfigurationService configurationService; protected UserService userService; @@ -124,6 +131,7 @@ public class ConfigurationAction extends FaxToMailActionSupport implements Prepa users = userService.getAllActiveUsers(); groups = userService.getAllActiveUserGroups(); brandsForDomains = configurationService.getAllBrandsForDomains(); + return INPUT; } @@ -270,4 +278,5 @@ public class ConfigurationAction extends FaxToMailActionSupport implements Prepa } return result; } + } diff --git a/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp b/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp index 541426b..603baea 100644 --- a/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp +++ b/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp @@ -68,7 +68,7 @@ <h1 class="page-header">Configuration</h1> - <s:form id="main_form" action="configuration" method="post" ng-controller="ConfigurationController"> + <s:form id="main_form" action="configuration" method="post" ng-controller="ConfigurationController" enctype="multipart/form-data"> <!--<s:hidden name="activeTab"/>--> @@ -251,16 +251,41 @@ </div> <div class="col-md-8" ng-if="selectedStamp"> + <h3>Édition du tampon {{selectedStamp.label}}</h3> + <div class="form-group"> <label>Description :</label> <textarea name="description" class="form-control" ng-model="selectedStamp.description"></textarea> </div> + <div class="form-group"> - <label>Texte :</label> - <textarea name="text" class="form-control" ng-model="selectedStamp.text"></textarea> + <label><input type="radio" ng-model="selectedStamp.isImageType" ng-value="true" /> + Image :</label> + + <div ng-show="selectedStamp.isImageType"> + + <input type="file" accept="image/*" id="stampImage" + class="form-control" + onchange="angular.element(this).scope().imageChanged(this)"/> + + <output> + <img id="stampPreview"/> + </output> + + </div> + + </div> + + <div class="form-group"> + <label><input type="radio" ng-model="selectedStamp.isImageType" ng-value="false" /> Texte :</label> + <textarea name="text" class="form-control" + ng-model="selectedStamp.text" ng-show="!selectedStamp.isImageType"> + </textarea> </div> + </div> + <div class="col-md-8" ng-if="!selectedStamp"> <em>Sélectionnez un tampon.</em> </div> diff --git a/faxtomail-ui-web/src/main/webapp/js/configuration.js b/faxtomail-ui-web/src/main/webapp/js/configuration.js index db22c09..86a34c4 100644 --- a/faxtomail-ui-web/src/main/webapp/js/configuration.js +++ b/faxtomail-ui-web/src/main/webapp/js/configuration.js @@ -350,14 +350,20 @@ ConfigurationModule.controller('ConfigurationStampsController', ['$scope', '$win //{Object} tampon selectionné $scope.selectedStamp; + for (var i = 0 ; i < $scope.stamps.length ; i++) { + var stamp = $scope.stamps[i]; + stamp.isImageType = stamp.image != null; + console.log(stamp) + console.log(stamp.isImageType) + } + // edition d'un tampon $scope.editStamp = function(stamp) { + $scope.selectedStamp = stamp; + $('#stampImage').val(null); + $('#stampPreview').attr('src', stamp.image ? stamp.image : null); -// // initialize le tableau d'action si vide -// if (!$scope.selectedStamp.requiredFields) { -// $scope.selectedDemandType.requiredFields = []; -// } }; // ajout d'un nouveau tampon @@ -373,6 +379,7 @@ ConfigurationModule.controller('ConfigurationStampsController', ['$scope', '$win // check if already exists if ($scope.stamps.indexOfBy('label', newStamp) != -1) { $window.alert("Ce tampon existe déjà !"); + } else { $scope.stamps.push(newStamp); @@ -382,16 +389,30 @@ ConfigurationModule.controller('ConfigurationStampsController', ['$scope', '$win } }; -// // selection/deselection d'un champ -// $scope.changeDemandTypeField = function(mailField) { -// -// var index = $scope.selectedDemandType.requiredFields.indexOf(mailField); -// if (index != -1) { -// $scope.selectedDemandType.requiredFields.splice(index, 1); -// } else { -// $scope.selectedDemandType.requiredFields.push(mailField); -// } -// }; + $scope.imageChanged = function(input) { + var f = input.files[0]; // FileList object + + // Only process image files. + if (!f.type.match('image.*')) { + console.log("erorr"); + + $('#stampPreview').attr('src', null); + //TODO error + } + + var reader = new FileReader(); + + // Closure to capture the file information. + reader.onloadend = function() { + + $scope.selectedStamp.image = reader.result; + $('#stampPreview').attr('src', reader.result); + }; + + // Read in the image file as a data URL. + reader.readAsDataURL(f); + } + }]); diff --git a/pom.xml b/pom.xml index ccf076e..f7ac66e 100644 --- a/pom.xml +++ b/pom.xml @@ -622,7 +622,7 @@ <version>1.2.25-1</version> <scope>runtime</scope> </dependency> - + <dependency> <groupId>org.nuiton.js</groupId> <artifactId>nuiton-js-font-awesome</artifactId> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.