Author: kmorin Date: 2014-05-21 20:23:57 +0200 (Wed, 21 May 2014) New Revision: 85 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/85 Log: refs #4662 prise en compte des colonnes de chaque dossier diff?\195?\169renciation de la modif et de l'ouverture des versions modifi?\195?\169es des pi?\195?\168ces jointes visualisation des pi?\195?\168ces jointes modifi?\195?\169es depuis la liste principale Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIModel.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.css 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/DemandeUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java 2014-05-21 18:23:57 UTC (rev 85) @@ -24,7 +24,7 @@ import com.franciaflex.faxtomail.FaxToMailConfiguration; import com.franciaflex.faxtomail.persistence.entities.Company; -import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.Configuration; import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaApplicationContext; import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; @@ -72,8 +72,6 @@ import org.nuiton.util.converter.ConverterUtil; import javax.swing.*; -import javax.swing.event.RowSorterEvent; -import javax.swing.tree.TreePath; import java.awt.*; import java.beans.PropertyChangeEvent; @@ -81,7 +79,6 @@ import java.io.Closeable; import java.io.File; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Locale; import java.util.Map; import java.util.Set; @@ -218,7 +215,7 @@ private final ApplicationActionEngine faxToMailActionEngine; - protected Company currentCompany; + protected Configuration faxToMailConfiguration; protected FaxToMailUser currentUser; @@ -455,8 +452,8 @@ // } // - Company franciaflex = getCompanyService().getCompanyByName("Franciaflex"); - setCurrentCompany(franciaflex); +// Company franciaflex = getCompanyService().getCompanyByName("Franciaflex"); +// setCurrentCompany(franciaflex); FaxToMailUser currentUser = getUserService().getUserByLogin("cbaillet"); setCurrentUser(currentUser); @@ -697,12 +694,12 @@ firePropertyChange(PROPERTY_LOCALE, null, locale); } - public Company getCurrentCompany() { - return currentCompany; + public Configuration getFaxToMailConfiguration() { + return faxToMailConfiguration; } - public void setCurrentCompany(Company currentCompany) { - this.currentCompany = currentCompany; + public void setFaxToMailConfiguration(Configuration faxToMailConfiguration) { + this.faxToMailConfiguration = faxToMailConfiguration; } public FaxToMailUser getCurrentUser() { Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-05-21 18:23:57 UTC (rev 85) @@ -34,6 +34,7 @@ import javax.swing.JTextArea; +import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import jaxx.runtime.JAXXContext; import jaxx.runtime.JAXXUtil; import jaxx.runtime.SwingUtil; @@ -246,7 +247,7 @@ // convert content to blob InputStream is = new BufferedInputStream(new FileInputStream(target)); AttachmentFile attachmentFileNew = getContext().getEmailService().getAttachmentFileFromStream(is); - attachmentFileNew.setFilename(getModel().getOriginalFile().getFilename() + "-annoté.pdf"); + attachmentFileNew.setFilename(FaxToMailUIUtil.getEditedFileName(getModel().getOriginalFile())); getModel().setEditedFile(attachmentFileNew); } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java 2014-05-21 18:23:57 UTC (rev 85) @@ -31,6 +31,7 @@ import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailBeanUIModel; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI; +import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import com.google.common.base.Preconditions; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -105,14 +106,20 @@ listener = new AttachmentEditorUIModel.AttachmentListener() { @Override - public void onAttachmentOpened(Attachment attachment) { + public void onAttachmentOpened(Attachment attachment, boolean original) { String topiaId = model.getTopiaId(); if (topiaId != null) { + String filename; + if (original) { + filename = attachment.getOriginalFile().getFilename(); + } else { + filename = FaxToMailUIUtil.getEditedFileName(attachment.getOriginalFile()); + } Email email = context.getEmailService().addToHistory(topiaId, HistoryType.ATTACHMENT_OPENING, context.getCurrentUser(), new Date(), - attachment.getOriginalFile().getFilename()); + filename); model.fromEntity(email); } } @@ -124,7 +131,7 @@ HistoryType.ATTACHMENT_MODIFICATION, context.getCurrentUser(), new Date(), - attachment.getOriginalFile().getFilename()); + FaxToMailUIUtil.getEditedFileName(attachment.getOriginalFile())); model.fromEntity(email); } }; Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java 2014-05-21 18:23:57 UTC (rev 85) @@ -178,7 +178,7 @@ public void openAttachment(Attachment attachment) { - getModel().fireAttachmentOpened(attachment); + getModel().fireAttachmentOpened(attachment, true); File file = attachment.getOriginalFile().getFile(); Desktop desktop = FaxToMailUIUtil.getDesktopForBrowse(); @@ -190,27 +190,41 @@ } public void editAttachment(Attachment attachment) { + AttachmentEditorUIModel model = getModel(); + AttachmentFile attachmentFile = attachment.getEditedFile(); if (attachmentFile == null) { + model.fireAttachmentOpened(attachment, true); attachmentFile = attachment.getOriginalFile(); + + } else { + model.fireAttachmentOpened(attachment, false); } - File file = attachmentFile.getFile(); - getModel().fireAttachmentEdited(attachment); - String extension = FileUtil.extension(attachmentFile.getFilename()); - if (getModel().isEditable() && EDITABLE_EXTENSIONS.contains(extension.toUpperCase())) { + if (model.isEditable()) { + String extension = FileUtil.extension(attachmentFile.getFilename()); + if (model.isEditable() && EDITABLE_EXTENSIONS.contains(extension.toUpperCase())) { - MainUI mainUI = getContext().getMainUI(); - mainUI.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - PDFEditorUI dialogContent = new PDFEditorUI(ui); - dialogContent.getModel().fromEntity(attachment); - mainUI.setCursor(Cursor.getDefaultCursor()); - openDialog(dialogContent, file.getName(), mainUI.getSize()); - dialogContent.getModel().toEntity(attachment); + MainUI mainUI = getContext().getMainUI(); + mainUI.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + PDFEditorUI dialogContent = new PDFEditorUI(ui); + dialogContent.getModel().fromEntity(attachment); + mainUI.setCursor(Cursor.getDefaultCursor()); + openDialog(dialogContent, file.getName(), mainUI.getSize()); + dialogContent.getModel().toEntity(attachment); + } else { + Desktop desktop = FaxToMailUIUtil.getDesktopForOpen(); + try { + desktop.open(file); + } catch (IOException e) { + getContext().getErrorHelper().showErrorDialog(t("swing.error.cannot.open.file")); + } + } + } else { - Desktop desktop = FaxToMailUIUtil.getDesktopForOpen(); + Desktop desktop = FaxToMailUIUtil.getDesktopForBrowse(); try { desktop.open(file); } catch (IOException e) { Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIModel.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIModel.java 2014-05-21 18:23:57 UTC (rev 85) @@ -125,9 +125,9 @@ openingListeners.remove(listener); } - public void fireAttachmentOpened(Attachment attachment) { + public void fireAttachmentOpened(Attachment attachment, boolean original) { for (AttachmentListener listener : openingListeners) { - listener.onAttachmentOpened(attachment); + listener.onAttachmentOpened(attachment, original); } } @@ -139,7 +139,7 @@ public static interface AttachmentListener { - public void onAttachmentOpened(Attachment attachment); + public void onAttachmentOpened(Attachment attachment, boolean original); public void onAttachmentEdited(Attachment attachment); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.css =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.css 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentItem.css 2014-05-21 18:23:57 UTC (rev 85) @@ -43,7 +43,7 @@ actionIcon: "edit"; toolTipText: "faxtomail.attachmentEditor.action.edit.tip"; enabled: { handler != null && handler.isAttachmentEditable(getAttachment()) }; - visible: { isEditable() }; + // visible: { isEditable() }; } #removeAttachmentButton { 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-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2014-05-21 18:23:57 UTC (rev 85) @@ -44,9 +44,11 @@ import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import com.franciaflex.faxtomail.ui.swing.util.FolderTreeNode; import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.TableColumnModelExt; import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; import javax.swing.*; @@ -107,8 +109,7 @@ super.beforeInit(ui); DemandeListUIModel model = new DemandeListUIModel(); - Company franciaflex = getContext().getCurrentCompany(); - Collection<MailFolder> folders = franciaflex.getMailFolder(); + Collection<MailFolder> folders = getContext().getMailFolderService().getRootMailFolders(); model.setFolders(new ArrayList<MailFolder>(folders)); model.addPropertyChangeListener(DemandeListUIModel.PROPERTY_SELECTED_FOLDER, new PropertyChangeListener() { @@ -116,6 +117,9 @@ public void propertyChange(PropertyChangeEvent evt) { DemandeListUIModel model = (DemandeListUIModel) evt.getSource(); MailFolder folder = (MailFolder) evt.getNewValue(); + + populateColumnModel(getUI().getDataTable(), false); + List<Email> emails = getContext().getEmailService().getEmailForFolder(folder); log.info(emails.size() + " emails in folder " + folder.getName()); List<DemandeUIModel> demands = new ArrayList<DemandeUIModel>(); @@ -142,7 +146,7 @@ // init table final JXTable dataTable = getUI().getDataTable(); - final AbstractApplicationTableModel<DemandeUIModel> tableModel = initDemandeTable(dataTable, false); + initDemandeTable(dataTable, false); final ITableFilter<JTable> tableFilter = new JTableFilter(dataTable) { @@ -150,9 +154,10 @@ protected boolean execute(int col, Collection<DistinctColumnItem> items) { boolean b = super.execute(col, items); List<DemandeUIModel> filteredEmails = new ArrayList<DemandeUIModel>(); + AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); for (int i = 0; i < dataTable.getRowCount(); i++) { int modelIndex = dataTable.convertRowIndexToModel(i); - filteredEmails.add(tableModel.getEntry(modelIndex)); + filteredEmails.add(dataTableModel.getEntry(modelIndex)); } getModel().setFilteredEmails(filteredEmails); return b; @@ -178,9 +183,10 @@ model.setCurrentEmails(null); } else { List<DemandeUIModel> selectedRows = new ArrayList<DemandeUIModel>(); + AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); for (int i = source.getMinSelectionIndex() ; i <= source.getMaxSelectionIndex() ; i++) { if (source.isSelectedIndex(i)) { - selectedRows.add(tableModel.getEntry(i)); + selectedRows.add(dataTableModel.getEntry(i)); } } model.setCurrentEmails(selectedRows); @@ -192,7 +198,8 @@ @Override public void propertyChange(PropertyChangeEvent evt) { List<DemandeUIModel> emails = (List<DemandeUIModel>) evt.getNewValue(); - tableModel.setRows(emails); + AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); + dataTableModel.setRows(emails); tableFilter.clear(); } }); @@ -252,7 +259,8 @@ DemandeUIModel currentEmail = getContext().getCurrentEmail(); if (currentEmail != null) { - int row = tableModel.getRowIndex(currentEmail); + AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); + int row = dataTableModel.getRowIndex(currentEmail); if (row > 0) { dataTable.setRowSelectionInterval(row, row); } @@ -274,6 +282,12 @@ } @Override + protected Collection<String> getColumns() { + MailFolder selectedFolder = getModel().getSelectedFolder(); + return selectedFolder != null ? selectedFolder.getTableColumns() : null; + } + + @Override protected String[] getEditableTableProperties() { return new String[] { Email.PROPERTY_PRIORITY, Email.PROPERTY_ATTACHMENT, Email.PROPERTY_REPLIES }; } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-05-21 18:23:57 UTC (rev 85) @@ -323,14 +323,20 @@ new AttachmentEditorUIModel.AttachmentListener() { @Override - public void onAttachmentOpened(Attachment attachment) { + public void onAttachmentOpened(Attachment attachment, boolean original) { String topiaId = getModel().getTopiaId(); if (topiaId != null) { + String filename; + if (original) { + filename = attachment.getOriginalFile().getFilename(); + } else { + filename = FaxToMailUIUtil.getEditedFileName(attachment.getOriginalFile()); + } Email email = getContext().getEmailService().addToHistory(topiaId, HistoryType.ATTACHMENT_OPENING, getContext().getCurrentUser(), new Date(), - attachment.getOriginalFile().getFilename()); + filename); getModel().setHistory(email.getHistory()); } } @@ -343,7 +349,7 @@ HistoryType.ATTACHMENT_MODIFICATION, getContext().getCurrentUser(), new Date(), - attachment.getOriginalFile().getFilename()); + FaxToMailUIUtil.getEditedFileName(attachment.getOriginalFile())); getModel().setHistory(email.getHistory()); } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java 2014-05-21 18:23:57 UTC (rev 85) @@ -59,6 +59,7 @@ import java.beans.PropertyChangeListener; import java.util.Arrays; import java.util.Calendar; +import java.util.Collection; import java.util.Date; import java.util.List; @@ -160,18 +161,19 @@ final JXTable dataTable = getUI().getDataTable(); dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - final AbstractApplicationTableModel<DemandeUIModel> tableModel = initDemandeTable(dataTable, true); + initDemandeTable(dataTable, true); model.addPropertyChangeListener(SearchUIModel.PROPERTY_RESULTS, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { List<DemandeUIModel> emails = (List<DemandeUIModel>) evt.getNewValue(); - tableModel.setRows(emails); + AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); + dataTableModel.setRows(emails); showInformationMessage(t("faxtomail.search.resultNb", emails.size())); DemandeUIModel currentEmail = getContext().getCurrentEmail(); if (currentEmail != null) { - int row = tableModel.getRowIndex(currentEmail); + int row = dataTableModel.getRowIndex(currentEmail); if (row > 0) { dataTable.setRowSelectionInterval(row, row); } @@ -199,7 +201,8 @@ ListSelectionModel selectionModel = (ListSelectionModel) e.getSource(); SearchUIModel model = getModel(); int selectedIndex = selectionModel.getLeadSelectionIndex(); - DemandeUIModel selectedModel = selectedIndex < 0 ? null : tableModel.getEntry(selectedIndex); + AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); + DemandeUIModel selectedModel = selectedIndex < 0 ? null : dataTableModel.getEntry(selectedIndex); model.setGroupEnabled(!selectionModel.isSelectionEmpty() && isDemandSelectable(selectedModel)); } } @@ -210,7 +213,8 @@ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { int viewRow = adapter.row; int modelRow = adapter.convertRowIndexToModel(viewRow); - DemandeUIModel row = tableModel.getEntry(modelRow); + AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); + DemandeUIModel row = dataTableModel.getEntry(modelRow); return !isDemandSelectable(row); } }; @@ -218,6 +222,12 @@ } + @Override + protected Collection<String> getColumns() { + //TODO kmorin 20140521 get the real search columns + return null; + } + protected boolean isDemandSelectable(DemandeUIModel demand) { DemandeUIModel currentDemand = getContext().getCurrentEmail(); return !currentDemand.equals(demand) && !currentDemand.getGroupedDemandes().contains(demand); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java 2014-05-21 18:23:57 UTC (rev 85) @@ -60,6 +60,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.Collection; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -160,18 +161,19 @@ final JXTable dataTable = getUI().getDataTable(); dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - final AbstractApplicationTableModel<DemandeUIModel> tableModel = initDemandeTable(dataTable, true); + initDemandeTable(dataTable, true); model.addPropertyChangeListener(SearchUIModel.PROPERTY_RESULTS, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { List<DemandeUIModel> emails = (List<DemandeUIModel>) evt.getNewValue(); - tableModel.setRows(emails); + AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel(); + dataTableModel.setRows(emails); showInformationMessage(t("faxtomail.search.resultNb", emails.size())); DemandeUIModel currentEmail = getContext().getCurrentEmail(); if (currentEmail != null) { - int row = tableModel.getRowIndex(currentEmail); + int row = dataTableModel.getRowIndex(currentEmail); if (row > 0) { dataTable.setRowSelectionInterval(row, row); } @@ -192,8 +194,12 @@ } } + } - + @Override + protected Collection<String> getColumns() { + //TODO kmorin 20140521 get the real search columns + return null; } @Override Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-05-21 18:23:57 UTC (rev 85) @@ -26,6 +26,7 @@ import com.franciaflex.faxtomail.persistence.entities.Attachment; import com.franciaflex.faxtomail.persistence.entities.Company; +import com.franciaflex.faxtomail.persistence.entities.Configuration; import com.franciaflex.faxtomail.persistence.entities.DemandStatus; import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; @@ -42,6 +43,8 @@ import com.franciaflex.faxtomail.ui.swing.content.demande.replies.RepliesCellEditor; import com.franciaflex.faxtomail.ui.swing.content.demande.replies.RepliesCellRenderer; import com.google.common.base.Function; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; @@ -80,39 +83,107 @@ private static final Log log = LogFactory.getLog(AbstractFaxToMailDemandListHandler.class); - public AbstractApplicationTableModel<DemandeUIModel> initDemandeTable(JXTable table, boolean sortable) { + public void initDemandeTable(final JXTable table, boolean sortable) { // table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); + populateColumnModel(table, sortable); + + table.getTableHeader().setReorderingAllowed(false); + + Highlighter highlighter = new Highlighter() { + @Override + public Component highlight(Component renderer, ComponentAdapter adapter) { + int viewRow = adapter.row; + int modelRow = adapter.convertRowIndexToModel(viewRow); + DemandeUIModel row = ((AbstractApplicationTableModel<DemandeUIModel>) table.getModel()).getEntry(modelRow); + boolean highlight = row.getTakenBy() == null; + if (highlight) { + Font font = renderer.getFont(); + renderer.setFont(font.deriveFont(Font.BOLD)); + } + highlight = row.getArchiveDate() != null; + if (highlight) { + Font font = renderer.getFont(); + renderer.setFont(font.deriveFont(Font.ITALIC)); + renderer.setForeground(adapter.isSelected() ? Color.WHITE : new Color(96, 96, 96)); + } + return renderer; + } + + @Override + public void addChangeListener(ChangeListener l) { + } + + @Override + public void removeChangeListener(ChangeListener l) { + } + + @Override + public ChangeListener[] getChangeListeners() { + return new ChangeListener[0]; + } + }; + table.addHighlighter(highlighter); + + HighlightPredicate rowIsInvalidPredicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + int viewRow = adapter.row; + int modelRow = adapter.convertRowIndexToModel(viewRow); + DemandeUIModel row = ((AbstractApplicationTableModel<DemandeUIModel>) table.getModel()).getEntry(modelRow); + return !row.isValid() && row.getTakenBy()!= null; + } + }; + Color color = new Color(255, 51, 51); + table.addHighlighter(new ColorHighlighter(rowIsInvalidPredicate, color, Color.WHITE, color.darker(), Color.WHITE)); + + HighlightPredicate testPredicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + int viewRow = adapter.row; + int modelRow = adapter.convertRowIndexToModel(viewRow); + DemandeUIModel row = ((AbstractApplicationTableModel<DemandeUIModel>) table.getModel()).getEntry(modelRow); + return row.getLastAttachmentOpeningInThisFolderUser() != null + && !row.getLastAttachmentOpeningInThisFolderUser().equals(row.getTakenBy()); + } + }; + color = Color.ORANGE; + table.addHighlighter(new ColorHighlighter(testPredicate, color, Color.WHITE, color.darker(), Color.WHITE)); + + table.addMouseListener(getDataTableMouseListener()); + } + + protected abstract Collection<String> getColumns(); + + protected void populateColumnModel(JXTable table, boolean sortable) { + Collection<String> columns = getColumns(); + TableColumnModelExt columnModel = new DefaultTableColumnModelExt(); - Company franciaflex = getContext().getCurrentCompany(); - String columns = franciaflex.getConfiguration().getTableColumns(); - if (columns == null) { - columns = StringUtils.join(new String[]{ - Email.PROPERTY_PRIORITY, - Email.PROPERTY_DEMAND_TYPE, - Email.PROPERTY_OBJECT, - DemandeUIModel.PROPERTY_CLIENT_CODE, - DemandeUIModel.PROPERTY_CLIENT_BRAND, - Email.PROPERTY_SENDER, - Email.PROPERTY_PROJECT_REFERENCE, - Email.PROPERTY_COMPANY_REFERENCE, - DemandeUIModel.PROPERTY_REFERENCE, - Email.PROPERTY_RECEPTION_DATE, - Email.PROPERTY_RECIPIENT, - Email.PROPERTY_DEMAND_STATUS, - Email.PROPERTY_ETAT_ATTENTE, - DemandeUIModel.PROPERTY_PF_NB, - DemandeUIModel.PROPERTY_SAV_NB, - Email.PROPERTY_TAKEN_BY, - DemandeUIModel.PROPERTY_LAST_ATTACHMENT_OPENING_IN_THIS_FOLDER_USER, - Email.PROPERTY_REPLIES, - Email.PROPERTY_ATTACHMENT - }, ','); + if (CollectionUtils.isEmpty(columns)) { + columns = Lists.newArrayList(Email.PROPERTY_PRIORITY, + Email.PROPERTY_DEMAND_TYPE, + Email.PROPERTY_OBJECT, + DemandeUIModel.PROPERTY_CLIENT_CODE, + DemandeUIModel.PROPERTY_CLIENT_BRAND, + Email.PROPERTY_SENDER, + Email.PROPERTY_PROJECT_REFERENCE, + Email.PROPERTY_COMPANY_REFERENCE, + DemandeUIModel.PROPERTY_REFERENCE, + Email.PROPERTY_RECEPTION_DATE, + Email.PROPERTY_RECIPIENT, + Email.PROPERTY_DEMAND_STATUS, + Email.PROPERTY_ETAT_ATTENTE, + DemandeUIModel.PROPERTY_PF_NB, + DemandeUIModel.PROPERTY_SAV_NB, + Email.PROPERTY_TAKEN_BY, + DemandeUIModel.PROPERTY_LAST_ATTACHMENT_OPENING_IN_THIS_FOLDER_USER, + Email.PROPERTY_REPLIES, + Email.PROPERTY_ATTACHMENT); } - String[] columnNames = columns.split(","); - for (String columnName : columnNames) { + for (String columnName : columns) { + if (Email.PROPERTY_PRIORITY.equals(columnName)) { addComboDataColumnToModel(columnModel, DemandeTableModel.COLUMN_IDENTIFIERS.get(columnName), @@ -188,71 +259,6 @@ getEditableTableProperties()); table.setModel(tableModel); table.setColumnModel(columnModel); - table.getTableHeader().setReorderingAllowed(false); - - Highlighter highlighter = new Highlighter() { - @Override - public Component highlight(Component renderer, ComponentAdapter adapter) { - int viewRow = adapter.row; - int modelRow = adapter.convertRowIndexToModel(viewRow); - DemandeUIModel row = tableModel.getEntry(modelRow); - boolean highlight = row.getTakenBy() == null; - if (highlight) { - Font font = renderer.getFont(); - renderer.setFont(font.deriveFont(Font.BOLD)); - } - highlight = row.getArchiveDate() != null; - if (highlight) { - Font font = renderer.getFont(); - renderer.setFont(font.deriveFont(Font.ITALIC)); - renderer.setForeground(adapter.isSelected() ? Color.WHITE : new Color(96, 96, 96)); - } - return renderer; - } - - @Override - public void addChangeListener(ChangeListener l) { - } - - @Override - public void removeChangeListener(ChangeListener l) { - } - - @Override - public ChangeListener[] getChangeListeners() { - return new ChangeListener[0]; - } - }; - table.addHighlighter(highlighter); - - HighlightPredicate rowIsInvalidPredicate = new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - int viewRow = adapter.row; - int modelRow = adapter.convertRowIndexToModel(viewRow); - DemandeUIModel row = tableModel.getEntry(modelRow); - return !row.isValid() && row.getTakenBy()!= null; - } - }; - Color color = new Color(255, 51, 51); - table.addHighlighter(new ColorHighlighter(rowIsInvalidPredicate, color, Color.WHITE, color.darker(), Color.WHITE)); - - HighlightPredicate testPredicate = new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - int viewRow = adapter.row; - int modelRow = adapter.convertRowIndexToModel(viewRow); - DemandeUIModel row = tableModel.getEntry(modelRow); - return row.getLastAttachmentOpeningInThisFolderUser() != null - && !row.getLastAttachmentOpeningInThisFolderUser().equals(row.getTakenBy()); - } - }; - color = Color.ORANGE; - table.addHighlighter(new ColorHighlighter(testPredicate, color, Color.WHITE, color.darker(), Color.WHITE)); - - table.addMouseListener(getDataTableMouseListener()); - - return tableModel; } protected MouseListener getDataTableMouseListener() { 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-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-05-21 18:23:57 UTC (rev 85) @@ -270,4 +270,7 @@ } } + public static String getEditedFileName(AttachmentFile originalFile) { + return t("faxtomail.attachment.editedFile.name", originalFile.getFilename()) + "-.pdf"; + } } Modified: trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties =================================================================== --- trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-05-21 16:53:25 UTC (rev 84) +++ trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-05-21 18:23:57 UTC (rev 85) @@ -16,6 +16,7 @@ faxtomail.alert.archiveConfirmation.title=Confirmation de l'archivage faxtomail.alert.groupConfirmation.message=<html>Êtes vous sûr de vouloir grouper les éléments<br/>%1$s et<br/>%2$s ?<br/>Le groupement est définitif.</html> faxtomail.alert.groupConfirmation.title=Confirmation du groupement +faxtomail.attachment.editedFile.name=%s-annoté 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