This is an automated email from the git hooks/post-receive script. New commit to branch feature/7421 in repository faxtomail. See http://git.codelutin.com/faxtomail.git commit 7ab85c3f2fe50e8905afa478d6d3e81f32a5c43a Author: Kevin Morin <morin@codelutin.com> Date: Mon Aug 31 17:08:07 2015 +0200 ui pour marque les pj comme non importantes (refs #7421) --- .../content/attachment/AttachmentEditorUI.css | 15 +++++++ .../content/attachment/AttachmentEditorUI.jaxx | 12 +++++- .../attachment/AttachmentEditorUIHandler.java | 31 +++++++++++++ .../attachment/AttachmentEditorUIModel.java | 48 ++++++++++++++++++++- .../ui/swing/content/attachment/AttachmentItem.css | 1 + .../swing/content/attachment/AttachmentItem.jaxx | 3 ++ .../i18n/faxtomail-ui-swing_fr_FR.properties | 4 ++ .../src/main/resources/icons/action-important.png | Bin 0 -> 672 bytes .../main/resources/icons/action-not-important.png | Bin 0 -> 671 bytes 9 files changed, 112 insertions(+), 2 deletions(-) diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.css b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.css index 565279d..e1522bc 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.css +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.css @@ -25,6 +25,20 @@ minimumSize: { new java.awt.Dimension(250, 0) }; } +#markItemAsLessImportantMenu { + actionIcon: not-important; + text: "faxtomail.attachmentEditor.action.markItemAsLessImportant"; + toolTipText: "faxtomail.attachmentEditor.action.markItemAsLessImportant.tip"; + visible: { !model.getSelectedAttachment().isLessImportant() }; +} + +#unmarkItemAsLessImportantMenu { + actionIcon: important; + text: "faxtomail.attachmentEditor.action.unmarkItemAsLessImportant"; + toolTipText: "faxtomail.attachmentEditor.action.unmarkItemAsLessImportant.tip"; + visible: { model.getSelectedAttachment().isLessImportant() }; +} + #body { title: "faxtomail.attachmentEditor.title"; } @@ -39,6 +53,7 @@ #attachments { editable: true; visible: { !model.getAttachment().isEmpty() }; + selectionMode: { ListSelectionModel.SINGLE_SELECTION }; } #formPanel { diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.jaxx b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.jaxx index a575b86..4702a90 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.jaxx +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.jaxx @@ -35,7 +35,9 @@ org.jdesktop.swingx.JXTable org.jdesktop.swingx.JXTitledPanel + javax.swing.JComponent + javax.swing.ListSelectionModel </import> <script><![CDATA[ @@ -49,6 +51,13 @@ <AttachmentEditorUIModel id='model' initializer='new AttachmentEditorUIModel()'/> + <JPopupMenu id='attachmentsPopup'> + <JMenuItem id='markItemAsLessImportantMenu' + onActionPerformed='handler.markItemAsLessImportant()'/> + <JMenuItem id='unmarkItemAsLessImportantMenu' + onActionPerformed='handler.unmarkItemAsLessImportant()'/> + </JPopupMenu> + <JXTitledPanel id='body'> <JScrollPane id='attachmentBodyScrollPane'> <JPanel id='mainPanel' layout="{new BorderLayout()}"> @@ -60,7 +69,8 @@ <row> <cell weightx="1.0"> - <JXTable id='attachments'/> + <JXTable id='attachments' + onMouseClicked='handler.autoSelectRowInTable(event, attachmentsPopup)'/> </cell> </row> 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 7c4f642..3ef6f6f 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 @@ -33,6 +33,8 @@ import com.google.common.collect.Iterables; import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.HighlighterFactory; @@ -59,6 +61,11 @@ import static org.nuiton.i18n.I18n.t; */ public class AttachmentEditorUIHandler extends AbstractToolbarPopupHandler<AttachmentEditorUIModel, AttachmentEditorUI> { + /** + * Logger. + */ + private static final Log log = LogFactory.getLog(AttachmentEditorUIHandler.class); + @Override public void afterInit(AttachmentEditorUI ui) { @@ -186,6 +193,30 @@ public class AttachmentEditorUIHandler extends AbstractToolbarPopupHandler<Attac return attachment != null && attachment.getTopiaId() == null; } + @Override + protected void beforeOpenPopup(int modelRowIndex, int modelColumnIndex) { + super.beforeOpenPopup(modelRowIndex, modelColumnIndex); + AttachmentEditorUIModel model = getModel(); + Attachment attachment = model.getAttachment().get(modelRowIndex); + model.setSelectedAttachment(attachment); + } + + public void markItemAsLessImportant() { + setSelectedAttachmentLessImportant(true); + } + + public void unmarkItemAsLessImportant() { + setSelectedAttachmentLessImportant(false); + } + + protected void setSelectedAttachmentLessImportant(boolean lessImportant) { + AttachmentEditorUIModel model = getModel(); + Attachment selectedAttachment = model.getSelectedAttachment(); + selectedAttachment.setLessImportant(lessImportant); + model.sortAttachments(); + model.setSelectedAttachment(null); + } + protected class AttachmentItemRenderer extends AttachmentItem implements TableCellRenderer { public AttachmentItemRenderer() { diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIModel.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIModel.java index 4fda891..dd6c583 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIModel.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIModel.java @@ -26,10 +26,14 @@ package com.franciaflex.faxtomail.ui.swing.content.attachment; import com.franciaflex.faxtomail.persistence.entities.Attachment; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailBeanUIModel; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; /** @@ -40,12 +44,39 @@ public class AttachmentEditorUIModel extends AbstractFaxToMailBeanUIModel<Attach //public static final String PROPERTY_FILE = "file"; public static final String PROPERTY_EDITABLE = "editable"; + public static final String PROPERTY_SELECTED_ATTACHMENT = "selectedAttachment"; + + public static final Comparator<Attachment> ATTACHMENT_COMPARATOR = new Comparator<Attachment>() { + @Override + public int compare(Attachment o1, Attachment o2) { + if (o1 == null) { + + if (o2 == null) { + return 0; + } + + return o2 == null ? 0 : -1; + } + if (o2 == null) { + return 1; + } + + if (o1.isLessImportant() ^ o2.isLessImportant()) { + return o1.isLessImportant() ? 1 : -1; + } + + return ObjectUtils.compare(StringUtils.lowerCase(o1.getOriginalFileName()), + StringUtils.lowerCase(o2.getOriginalFileName())); + } + }; //protected File file; protected boolean editable = true; protected final List<Attachment> attachments = new ArrayList<Attachment>(); + protected Attachment selectedAttachment; + protected List<AttachmentListener> openingListeners = new ArrayList<AttachmentListener>(); protected static Binder<AttachmentEditorUIModel, AttachmentModelAware> toBeanBinder = @@ -92,14 +123,29 @@ public class AttachmentEditorUIModel extends AbstractFaxToMailBeanUIModel<Attach } public void setAttachment(List<Attachment> attachments) { - Object oldValue = new ArrayList<Attachment>(getAttachment()); + Object oldValue = new ArrayList<>(getAttachment()); this.attachments.clear(); if (attachments != null) { this.attachments.addAll(attachments); + sortAttachments(); } firePropertyChange(AttachmentModelAware.PROPERTY_ATTACHMENT, oldValue, this.attachments); } + public void sortAttachments() { + Collections.sort(this.attachments, ATTACHMENT_COMPARATOR); + } + + public Attachment getSelectedAttachment() { + return selectedAttachment; + } + + public void setSelectedAttachment(Attachment selectedAttachment) { + Object oldValue = getSelectedAttachment(); + this.selectedAttachment = selectedAttachment; + firePropertyChange(PROPERTY_SELECTED_ATTACHMENT, oldValue, selectedAttachment); + } + @Override protected AttachmentModelAware newEntity() { return null; diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.css b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.css index 29a6dc4..55f6209 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.css +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.css @@ -27,6 +27,7 @@ #attachmentNameLabel { text: { attachment != null ? getAttachment().getOriginalFileName() : null }; + foreground: { attachment != null && getAttachment().isLessImportant() ? Color.LIGHT_GRAY : Color.BLACK }; } #toolbar { diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.jaxx b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.jaxx index b2477b1..2362bf0 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.jaxx +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.jaxx @@ -25,6 +25,9 @@ <import> com.franciaflex.faxtomail.persistence.entities.Attachment + + java.awt.Color + static org.nuiton.i18n.I18n.t static jaxx.runtime.JAXXUtil.getStringValue </import> 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 7ca77d6..dffb827 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 @@ -57,10 +57,14 @@ faxtomail.attachmentCellRenderer.text=(%s) faxtomail.attachmentEditor.action.add.tip=Ajouter une pièce jointe faxtomail.attachmentEditor.action.closeAttachment.tip=Fermer la fenêtre des pièces-jointes faxtomail.attachmentEditor.action.edit.tip=Editer la pièce jointe +faxtomail.attachmentEditor.action.markItemAsLessImportant=Non important +faxtomail.attachmentEditor.action.markItemAsLessImportant.tip=Marquer la pièce jointe comme non important faxtomail.attachmentEditor.action.open.tip=Ouvrir la pièce jointe faxtomail.attachmentEditor.action.openedited.tip=Ouvrir la pièce jointe éditée faxtomail.attachmentEditor.action.remove.tip=Supprimer la pièce jointe faxtomail.attachmentEditor.action.tip=Pièces jointes +faxtomail.attachmentEditor.action.unmarkItemAsLessImportant=Important +faxtomail.attachmentEditor.action.unmarkItemAsLessImportant.tip=Marquer la pièce jointe comme importante faxtomail.attachmentEditor.attachments.empty=Aucune pièce jointe faxtomail.attachmentEditor.deleteAttachment.message=Êtes-vous sûr de vouloir supprimer la pièce-jointe %s ? faxtomail.attachmentEditor.deleteAttachment.title=Suppression de pièce-jointe diff --git a/faxtomail-ui-swing/src/main/resources/icons/action-important.png b/faxtomail-ui-swing/src/main/resources/icons/action-important.png new file mode 100644 index 0000000..e4bc611 Binary files /dev/null and b/faxtomail-ui-swing/src/main/resources/icons/action-important.png differ diff --git a/faxtomail-ui-swing/src/main/resources/icons/action-not-important.png b/faxtomail-ui-swing/src/main/resources/icons/action-not-important.png new file mode 100644 index 0000000..14c89a5 Binary files /dev/null and b/faxtomail-ui-swing/src/main/resources/icons/action-not-important.png differ -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.