Author: echatellier Date: 2013-02-25 16:02:04 +0100 (Mon, 25 Feb 2013) New Revision: 155 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/155 Log: Display documents with custom table/listview Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.java Removed: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkColumn$RenderPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkColumn.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/AjaxButtonPropertyColumn$ButtonPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/AjaxButtonPropertyColumn.java Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ManageListDocumentsPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ManageListDocumentsPanel.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ReadListDocumentsPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ReadListDocumentsPanel.java Deleted: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkColumn$RenderPanel.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkColumn$RenderPanel.html 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkColumn$RenderPanel.html 2013-02-25 15:02:04 UTC (rev 155) @@ -1,32 +0,0 @@ -<!-- - #%L - Cantharella :: Web - $Id: SimpleTooltipPanel.html 133 2013-02-19 11:02:25Z echatellier $ - $HeadURL: http://svn.forge.codelutin.com/svn/cantharella/trunk/cantharella.web/src/mai... $ - %% - Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero 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 of - 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 Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --> -<!DOCTYPE html> -<html xmlns:wicket="http://wicket.apache.org"> -<body> -<wicket:panel> - <a wicket:id="link"> - <img wicket:id="image" alt="document" /> - </a> -</wicket:panel> -</body> -</html> \ No newline at end of file Deleted: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkColumn.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkColumn.java 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkColumn.java 2013-02-25 15:02:04 UTC (rev 155) @@ -1,95 +0,0 @@ -/* - * #%L - * Cantharella :: Web - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 of - * 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 Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package nc.ird.cantharella.web.pages.domain.document.panel; - -import nc.ird.cantharella.data.model.Document; - -import org.apache.commons.lang3.ArrayUtils; -import org.apache.wicket.AttributeModifier; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; -import org.apache.wicket.markup.html.WebComponent; -import org.apache.wicket.markup.html.image.Image; -import org.apache.wicket.markup.html.link.ResourceLink; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.model.IModel; -import org.apache.wicket.request.resource.ByteArrayResource; -import org.apache.wicket.request.resource.ContextRelativeResource; - -/** - * Document download link including thumbnail display for images. - * - * @author Eric Chatellier - * - * @param <S> the type of the sort property - */ -public class DocumentLinkColumn<S> extends AbstractColumn<Document, S> { - - /** - * Constructor. - * @param displayModel header display model - */ - public DocumentLinkColumn(IModel<String> displayModel) { - super(displayModel); - } - - /** {@inheritDoc} */ - @Override - public void populateItem(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) { - - RenderPanel panel = new RenderPanel(componentId, model); - item.add(panel); - } - - /** - * Panel which include a linkable image. Used with the LinkableImagePropertyColumn$LinkablePanel.html file - */ - public class RenderPanel extends Panel { - - /** - * Constructor - * @param id Component id - * @param model model - */ - public RenderPanel(String id, final IModel<Document> model) { - super(id); - - final Document document = model.getObject(); - ResourceLink<Document> link = new ResourceLink<Document>("link", new ByteArrayResource(document - .getFileMimetype(), document.getFileContent())); - add(link); - - WebComponent img; - if (ArrayUtils.isNotEmpty(document.getFileContentThumb())) { - link.add(new AttributeModifier("class", "colorbox")); - link.add(new AttributeModifier("title", document.getFileName())); - img = new Image("image", new ByteArrayResource("image/png", document.getFileContentThumb())); - } else { - img = new Image("image", new ContextRelativeResource("images/download.png")); - } - img.add(new AttributeModifier("title", document.getFileName())); - link.add(img); - } - } -} Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.html (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.html 2013-02-25 15:02:04 UTC (rev 155) @@ -0,0 +1,32 @@ +<!-- + #%L + Cantharella :: Web + $Id: SimpleTooltipPanel.html 133 2013-02-19 11:02:25Z echatellier $ + $HeadURL: http://svn.forge.codelutin.com/svn/cantharella/trunk/cantharella.web/src/mai... $ + %% + Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 of + 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 Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE html> +<html xmlns:wicket="http://wicket.apache.org"> +<body> +<wicket:panel> + <a wicket:id="link"> + <img wicket:id="image" alt="document" /> + </a> +</wicket:panel> +</body> +</html> \ No newline at end of file Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.java (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.java 2013-02-25 15:02:04 UTC (rev 155) @@ -0,0 +1,44 @@ +package nc.ird.cantharella.web.pages.domain.document.panel; + +import nc.ird.cantharella.data.model.Document; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.markup.html.WebComponent; +import org.apache.wicket.markup.html.image.Image; +import org.apache.wicket.markup.html.link.ResourceLink; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.resource.ByteArrayResource; +import org.apache.wicket.request.resource.ContextRelativeResource; + +/** + * Panel which include a linkable image. Used with the LinkableImagePropertyColumn$LinkablePanel.html file + */ +public class DocumentLinkPanel extends Panel { + + /** + * Constructor + * @param id Component id + * @param model model + */ + public DocumentLinkPanel(String id, final IModel<Document> model) { + super(id); + + final Document document = model.getObject(); + ResourceLink<Document> link = new ResourceLink<Document>("link", new ByteArrayResource(document + .getFileMimetype(), document.getFileContent())); + add(link); + + WebComponent img; + if (ArrayUtils.isNotEmpty(document.getFileContentThumb())) { + link.add(new AttributeModifier("class", "colorbox")); + link.add(new AttributeModifier("title", document.getFileName())); + img = new Image("image", new ByteArrayResource("image/png", document.getFileContentThumb())); + } else { + img = new Image("image", new ContextRelativeResource("images/download.png")); + } + img.add(new AttributeModifier("title", document.getFileName())); + link.add(img); + } +} Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/DocumentLinkPanel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ManageListDocumentsPanel.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ManageListDocumentsPanel.html 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ManageListDocumentsPanel.html 2013-02-25 15:02:04 UTC (rev 155) @@ -27,14 +27,54 @@ <form wicket:id="form"> <fieldset> - <legend><wicket:message key="ListDocumentsPage.AttachedDocuments" /></legend> - <div wicket:id="ListDocumentsPage.AttachedDocuments.Refresh"> - <table cellspacing="0" wicket:id="ListDocumentsPage.AttachedDocuments"/> - </div> - <a wicket:id="NewDocument" class="add"><wicket:message key="ListDocumentsPage.NewDocument" /></a> + <legend><wicket:message key="ListDocumentsPage.AttachedDocuments" /></legend> + <table cellspacing="0" wicket:id="ListDocumentsPage.AttachedDocuments.Table"> + <thead> + <tr> + <th> + <wicket:message key="Document.titre" /> + </th> + <th> + <wicket:message key="Document.typeDocument" /> + </th> + <th> + <wicket:message key="Document.createur" /> + </th> + <th> + <wicket:message key="Document.link" /> + </th> + <th> + <wicket:message key="Actions" /> + </th> + </tr> + </thead> + <tbody> + <tr wicket:id="ListDocumentsPage.AttachedDocuments.List"> + <td> + <a wicket:id="Document.titre.List"> + <span wicket:id="Document.titre.Label.List" /> + </a> + </td> + <td> + <span wicket:id="Document.typeDocument.List" /> + </td> + <td> + <span wicket:id="Document.createur.List" /> + </td> + <td> + <span wicket:id="Document.link.List" /> + </td> + <td> + <input type="button" wicket:id="Document.Delete.List" /> + </td> + </tr> + </tbody> + <tfoot> + <td colspan="5"><a wicket:id="NewDocument" class="add"><wicket:message key="ListDocumentsPage.NewDocument" /></a></td> + </tfoot> + </table> </fieldset> </form> - </wicket:panel> </body> </html> \ No newline at end of file Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ManageListDocumentsPanel.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ManageListDocumentsPanel.java 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ManageListDocumentsPanel.java 2013-02-25 15:02:04 UTC (rev 155) @@ -22,33 +22,29 @@ */ package nc.ird.cantharella.web.pages.domain.document.panel; -import java.util.ArrayList; import java.util.List; import nc.ird.cantharella.data.model.Document; import nc.ird.cantharella.data.model.utils.DocumentAttachable; -import nc.ird.cantharella.web.config.WebContext; import nc.ird.cantharella.web.pages.domain.document.ManageDocumentPage; import nc.ird.cantharella.web.pages.domain.document.ReadDocumentPage; import nc.ird.cantharella.web.utils.CallerPage; -import nc.ird.cantharella.web.utils.columns.AjaxButtonPropertyColumn; -import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn; -import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider; +import org.apache.wicket.AttributeModifier; import org.apache.wicket.MarkupContainer; import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxButton; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; -import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.markup.html.list.ListItem; +import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; +import org.apache.wicket.model.PropertyModel; /** * Display document list in manage mode. @@ -66,60 +62,57 @@ public ManageListDocumentsPanel(String id, final DocumentAttachable documentAttachable, final CallerPage currentPage) { super(id); - List<Document> documents = documentAttachable.getDocuments(); - Form<Void> formView = new Form<Void>("form"); add(formView); - // On englobe le "DataView" dans un composant neutre que l'on pourra - // rafraichir quand la liste évoluera - final MarkupContainer attachedDocumentRefresh = new WebMarkupContainer( - "ListDocumentsPage.AttachedDocuments.Refresh"); - attachedDocumentRefresh.setOutputMarkupId(true); - formView.add(attachedDocumentRefresh); + final List<Document> documents = documentAttachable.getDocuments(); - SimpleSortableListDataProvider<Document> attachedDocumentsDataProvider = new SimpleSortableListDataProvider<Document>( - documents, getSession().getLocale()); + final MarkupContainer documentsTable = new WebMarkupContainer("ListDocumentsPage.AttachedDocuments.Table"); + documentsTable.setOutputMarkupId(true); + formView.add(documentsTable); - List<IColumn<Document, String>> columns = new ArrayList<IColumn<Document, String>>(); - - columns.add(new LinkPropertyColumn<Document, String>(new Model<String>(getString("Document.titre")), "titre", - "titre") { + // Contenu tableaux provenance + ListView<Document> documentsListView = new ListView<Document>("ListDocumentsPage.AttachedDocuments.List", + documents) { @Override - public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) { - setResponsePage(new ReadDocumentPage(model.getObject(), documentAttachable, currentPage)); - } - }); + protected void populateItem(ListItem<Document> item) { + if (item.getIndex() % 2 == 1) { + item.add(new AttributeModifier("class", item.getIndex() % 2 == 0 ? "even" : "odd")); + } - columns.add(new PropertyColumn<Document, String>(new Model<String>(getString("Document.typeDocument")), - "typeDocument.nom", "typeDocument.nom")); + final IModel<Document> documentModel = item.getModel(); + // affichage + lien vers la fiche + Link<Document> documentLink = new Link<Document>("Document.titre.List") { + @Override + public void onClick() { + setResponsePage(new ReadDocumentPage(documentModel.getObject(), documentAttachable, currentPage)); + } + }; + documentLink.add(new Label("Document.titre.Label.List", new PropertyModel<Document>(documentModel, "titre"))); + item.add(documentLink); - columns.add(new PropertyColumn<Document, String>(new Model<String>(getString("Document.createur")), "createur", - "createur")); + item.add(new Label("Document.typeDocument.List", new PropertyModel<String>(documentModel, + "typeDocument.nom"))); + item.add(new Label("Document.createur.List", new PropertyModel<String>(documentModel, + "createur"))); + item.add(new DocumentLinkPanel("Document.link.List", documentModel)); + + item.add(new AjaxButton("Document.Delete.List", Model.of(getString("Delete"))) { + @Override + protected void onSubmit(AjaxRequestTarget target, Form<?> form) { + Document document = documentModel.getObject(); + documentAttachable.removeDocument(document); - columns.add(new DocumentLinkColumn<String>(new Model<String>(getString("Document.link")))); - - final DataTable<Document, String> attachedDocumentTable = new AjaxFallbackDefaultDataTable<Document, String>( - "ListDocumentsPage.AttachedDocuments", columns, attachedDocumentsDataProvider, WebContext.ROWS_PER_PAGE); - - columns.add(new AjaxButtonPropertyColumn<Document, String>(new Model<String>(getString("Actions")), - new Model<String>(getString("Delete")), formView) { - @Override - public void onSubmit(AjaxRequestTarget target, Form<?> form, IModel<Document> model) { - Document document = model.getObject(); - documentAttachable.removeDocument(document); - - if (target != null) { - target.add(attachedDocumentTable); - } + if (target != null) { + target.add(documentsTable); + } + } + }); } - }); - - attachedDocumentRefresh.add(attachedDocumentTable); - - // Action : création d'un nouveau document - // ajaxSubmitLink permet de sauvegarder l'état du formulaire - formView.add(new AjaxSubmitLink("NewDocument") { + }; + documentsTable.add(documentsListView); + + documentsTable.add(new AjaxSubmitLink("NewDocument") { @Override protected void onSubmit(AjaxRequestTarget request, Form<?> form) { setResponsePage(new ManageDocumentPage(currentPage, documentAttachable, false)); Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ReadListDocumentsPanel.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ReadListDocumentsPanel.html 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ReadListDocumentsPanel.html 2013-02-25 15:02:04 UTC (rev 155) @@ -26,7 +26,47 @@ <wicket:panel> <fieldset> <legend><wicket:message key="ListDocumentsPage.AttachedDocuments" /></legend> - <table cellspacing="0" wicket:id="ListDocumentsPage.AttachedDocuments"/> + + <table cellspacing="0" wicket:id="ListDocumentsPage.AttachedDocuments.Table"> + <thead> + <tr> + <th> + <wicket:message key="Document.titre" /> + </th> + <th> + <wicket:message key="Document.typeDocument" /> + </th> + <th> + <wicket:message key="Document.createur" /> + </th> + <th> + <wicket:message key="Document.link" /> + </th> + </tr> + </thead> + <tbody> + <tr wicket:id="ListDocumentsPage.AttachedDocuments.List"> + <td> + <a wicket:id="Document.titre.List"> + <span wicket:id="Document.titre.Label.List" /> + </a> + </td> + <td> + <span wicket:id="Document.typeDocument.List" /> + </td> + <td> + <span wicket:id="Document.createur.List" /> + </td> + <td> + <span wicket:id="Document.link.List" /> + </td> + </tr> + </tbody> + </table> + <div class="property" wicket:id="ListDocumentsPage.AttachedDocuments.noTable"> + <span class="label"> </span> + <span class="value"><wicket:message key="List.none" /></span> + </div> </fieldset> </wicket:panel> </body> Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ReadListDocumentsPanel.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ReadListDocumentsPanel.java 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/panel/ReadListDocumentsPanel.java 2013-02-25 15:02:04 UTC (rev 155) @@ -22,26 +22,23 @@ */ package nc.ird.cantharella.web.pages.domain.document.panel; -import java.util.ArrayList; import java.util.List; import nc.ird.cantharella.data.model.Document; import nc.ird.cantharella.data.model.utils.DocumentAttachable; -import nc.ird.cantharella.web.config.WebContext; import nc.ird.cantharella.web.pages.domain.document.ReadDocumentPage; import nc.ird.cantharella.web.utils.CallerPage; -import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn; -import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider; -import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.MarkupContainer; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.markup.html.list.ListItem; +import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; +import org.apache.wicket.model.PropertyModel; /** * Display document list in manage mode. @@ -57,31 +54,49 @@ */ public ReadListDocumentsPanel(String id, final DocumentAttachable documentAttachable, final CallerPage currentPage) { super(id); - List<Document> documents = documentAttachable.getDocuments(); + final List<Document> documents = documentAttachable.getDocuments(); - SimpleSortableListDataProvider<Document> attachedDocumentsDataProvider = new SimpleSortableListDataProvider<Document>( - documents, getSession().getLocale()); + final MarkupContainer documentsTable = new WebMarkupContainer("ListDocumentsPage.AttachedDocuments.Table"); + documentsTable.setOutputMarkupId(true); + add(documentsTable); - List<IColumn<Document, String>> columns = new ArrayList<IColumn<Document, String>>(); + // Contenu tableaux provenance + ListView<Document> documentsListView = new ListView<Document>("ListDocumentsPage.AttachedDocuments.List", + documents) { + @Override + protected void populateItem(ListItem<Document> item) { + if (item.getIndex() % 2 == 1) { + item.add(new AttributeModifier("class", item.getIndex() % 2 == 0 ? "even" : "odd")); + } - columns.add(new LinkPropertyColumn<Document, String>(new Model<String>(getString("Document.titre")), "titre", - "titre") { + final IModel<Document> documentModel = item.getModel(); + // affichage + lien vers la fiche + Link<Document> documentLink = new Link<Document>("Document.titre.List") { + @Override + public void onClick() { + setResponsePage(new ReadDocumentPage(documentModel.getObject(), documentAttachable, currentPage)); + } + }; + documentLink.add(new Label("Document.titre.Label.List", new PropertyModel<Document>(documentModel, "titre"))); + item.add(documentLink); + + item.add(new Label("Document.typeDocument.List", new PropertyModel<String>(documentModel, + "typeDocument.nom"))); + item.add(new Label("Document.createur.List", new PropertyModel<String>(documentModel, + "createur"))); + item.add(new DocumentLinkPanel("Document.link.List", documentModel)); + + } + }; + documentsTable.add(documentsListView); + + // Selon la non existence d'elements dans la liste on affiche le span + MarkupContainer noTableDocuments = new WebMarkupContainer("ListDocumentsPage.AttachedDocuments.noTable") { @Override - public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) { - setResponsePage(new ReadDocumentPage(model.getObject(), documentAttachable, currentPage)); + public boolean isVisible() { + return documents.isEmpty(); } - }); - - columns.add(new PropertyColumn<Document, String>(new Model<String>(getString("Document.typeDocument")), - "typeDocument.nom", "typeDocument.nom")); - - columns.add(new PropertyColumn<Document, String>(new Model<String>(getString("Document.createur")), "createur", - "createur")); - - columns.add(new DocumentLinkColumn<String>(new Model<String>(getString("Document.link")))); - - final DataTable<Document, String> attachedDocumentTable = new AjaxFallbackDefaultDataTable<Document, String>( - "ListDocumentsPage.AttachedDocuments", columns, attachedDocumentsDataProvider, WebContext.ROWS_PER_PAGE); - add(attachedDocumentTable); + }; + add(noTableDocuments); } } Deleted: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/AjaxButtonPropertyColumn$ButtonPanel.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/AjaxButtonPropertyColumn$ButtonPanel.html 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/AjaxButtonPropertyColumn$ButtonPanel.html 2013-02-25 15:02:04 UTC (rev 155) @@ -1,30 +0,0 @@ -<!-- - #%L - Cantharella :: Web - $Id$ - $HeadURL$ - %% - Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero 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 of - 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 Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --> -<!DOCTYPE html> -<html xmlns:wicket="http://wicket.apache.org"> -<body> -<wicket:panel> - <input type="submit" wicket:id="button" /> -</wicket:panel> -</body> -</html> \ No newline at end of file Deleted: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/AjaxButtonPropertyColumn.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/AjaxButtonPropertyColumn.java 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/AjaxButtonPropertyColumn.java 2013-02-25 15:02:04 UTC (rev 155) @@ -1,109 +0,0 @@ -/* - * #%L - * Cantharella :: Web - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 of - * 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 Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package nc.ird.cantharella.web.utils.columns; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.form.AjaxButton; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; - -/** - * Column embeded in a datatable which represent an linkable image - * @author Adrien Cheype - * @param <T> Generic type - * @param <S> the type of the sort property - */ -abstract public class AjaxButtonPropertyColumn<T, S> extends AbstractColumn<T, S> { - - /** Title displayed for the button */ - private Model<String> buttonLabel; - - /** Form. */ - private Form<?> form; - - /** - * Constructor - * @param buttonLabel Title displayed for the button - * @param form form - */ - public AjaxButtonPropertyColumn(Model<String> buttonLabel, Form<?> form) { - this(new Model<String>(), buttonLabel, form); - } - - /** - * Constructor - * @param displayModel header display model - * @param buttonLabel Title displayed for the button - * @param form form - */ - public AjaxButtonPropertyColumn(IModel<String> displayModel, Model<String> buttonLabel, Form<?> form) { - super(displayModel); - this.buttonLabel = buttonLabel; - this.form = form; - } - - /** {@inheritDoc} */ - @Override - public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> model) { - ButtonPanel panel = new ButtonPanel(item, componentId, model); - item.add(panel); - } - - /** - * Override this method to react to link clicks. Your own/internal row id will most likely be inside the model. - * @param target target - * @param form form - * @param model Model - */ - public abstract void onSubmit(AjaxRequestTarget target, Form<?> form, IModel<T> model); - - /** - * Panel which include a linkable image. Used with the LinkableImagePropertyColumn$LinkablePanel.html file - */ - public class ButtonPanel extends Panel { - - /** - * Constructor - * @param item Item - * @param componentId Component id - * @param model Model - */ - public ButtonPanel(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> model) { - super(componentId); - - AjaxButton button = new AjaxButton("button", buttonLabel, form) { - @Override - protected void onSubmit(AjaxRequestTarget target, Form<?> form) { - AjaxButtonPropertyColumn.this.onSubmit(target, form, model); - } - }; - - add(button); - } - } -} \ No newline at end of file