From echatellier@users.forge.codelutin.com Mon Feb 25 16:02:05 2013 From: echatellier@users.forge.codelutin.com To: cantharella-commits@list.forge.codelutin.com Subject: [Cantharella-commits] r155 - in trunk/cantharella.web/src/main/java/nc/ird/cantharella/web: pages/domain/document/panel utils/columns Date: Mon, 25 Feb 2013 16:02:05 +0100 Message-ID: <20130225150205.111C915A3E@nuiton.codelutin.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8924988059605362951==" --===============8924988059605362951== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/do= cument/panel/DocumentLinkPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/do= cument/panel/DocumentLinkPanel.java Removed: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/do= cument/panel/DocumentLinkColumn$RenderPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/do= cument/panel/DocumentLinkColumn.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/A= jaxButtonPropertyColumn$ButtonPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/A= jaxButtonPropertyColumn.java Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/do= cument/panel/ManageListDocumentsPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/do= cument/panel/ManageListDocumentsPanel.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/do= cument/panel/ReadListDocumentsPanel.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/do= cument/panel/ReadListDocumentsPanel.java Deleted: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/dom= ain/document/panel/DocumentLinkColumn$RenderPanel.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/DocumentLinkColumn$RenderPanel.html 2013-02-25 11:41:29 UTC (re= v 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/DocumentLinkColumn$RenderPanel.html 2013-02-25 15:02:04 UTC (re= v 155) @@ -1,32 +0,0 @@ - - - - - - - 3D"document" - - - - \ No newline at end of file Deleted: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/dom= ain/document/panel/DocumentLinkColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/DocumentLinkColumn.java 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/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 Developpemen= t) 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. - *=20 - * 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. - *=20 - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #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.ICellPopu= lator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.Abstract= Column; -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. - *=20 - * @author Eric Chatellier - * - * @param the type of the sort property - */ -public class DocumentLinkColumn extends AbstractColumn { - - /** - * Constructor. - * @param displayModel header display model - */ - public DocumentLinkColumn(IModel displayModel) { - super(displayModel); - } - - /** {@inheritDoc} */ - @Override - public void populateItem(Item> item, String com= ponentId, IModel model) { - - RenderPanel panel =3D new RenderPanel(componentId, model); - item.add(panel); - } - - /** - * Panel which include a linkable image. Used with the LinkableImageProp= ertyColumn$LinkablePanel.html file - */ - public class RenderPanel extends Panel { - - /** - * Constructor - * @param id Component id - * @param model model - */ - public RenderPanel(String id, final IModel model) { - super(id); - - final Document document =3D model.getObject(); - ResourceLink link =3D new ResourceLink("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 =3D new Image("image", new ByteArrayResource("image/png"= , document.getFileContentThumb())); - } else { - img =3D new Image("image", new ContextRelativeResource("imag= es/download.png")); - } - img.add(new AttributeModifier("title", document.getFileName())); - link.add(img); - } - } -} Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domai= n/document/panel/DocumentLinkPanel.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/DocumentLinkPanel.html (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/DocumentLinkPanel.html 2013-02-25 15:02:04 UTC (rev 155) @@ -0,0 +1,32 @@ + + + + + + + 3D"document" + + + + \ No newline at end of file Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domai= n/document/panel/DocumentLinkPanel.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/DocumentLinkPanel.java (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/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 LinkableImageProperty= Column$LinkablePanel.html file + */ +public class DocumentLinkPanel extends Panel { + + /** + * Constructor + * @param id Component id + * @param model model + */ + public DocumentLinkPanel(String id, final IModel model) { + super(id); + + final Document document =3D model.getObject(); + ResourceLink link =3D new ResourceLink("link", n= ew 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 =3D new Image("image", new ByteArrayResource("image/png", do= cument.getFileContentThumb())); + } else { + img =3D new Image("image", new ContextRelativeResource("images/d= ownload.png")); + } + img.add(new AttributeModifier("title", document.getFileName())); + link.add(img); + } +} Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/w= eb/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/do= main/document/panel/ManageListDocumentsPanel.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/ManageListDocumentsPanel.html 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/ManageListDocumentsPanel.html 2013-02-25 15:02:04 UTC (rev 155) @@ -27,14 +27,54 @@ =20
- -
- - - + =20 +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + +
- \ No newline at end of file Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/do= main/document/panel/ManageListDocumentsPanel.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/ManageListDocumentsPanel.java 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/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; =20 -import java.util.ArrayList; import java.util.List; =20 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; =20 +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.Aja= xFallbackDefaultDataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopu= lator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTabl= e; -import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.Property= Column; 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; =20 /** * Display document list in manage mode. @@ -66,60 +62,57 @@ public ManageListDocumentsPanel(String id, final DocumentAttachable docu= mentAttachable, final CallerPage currentPage) { super(id); =20 - List documents =3D documentAttachable.getDocuments(); - Form formView =3D new Form("form"); add(formView); =20 - // On englobe le "DataView" dans un composant neutre que l'on pourra - // rafraichir quand la liste =C3=A9voluera - final MarkupContainer attachedDocumentRefresh =3D new WebMarkupConta= iner( - "ListDocumentsPage.AttachedDocuments.Refresh"); - attachedDocumentRefresh.setOutputMarkupId(true); - formView.add(attachedDocumentRefresh); + final List documents =3D documentAttachable.getDocuments(); =20 - SimpleSortableListDataProvider attachedDocumentsDataProvid= er =3D new SimpleSortableListDataProvider( - documents, getSession().getLocale()); + final MarkupContainer documentsTable =3D new WebMarkupContainer("Lis= tDocumentsPage.AttachedDocuments.Table"); + documentsTable.setOutputMarkupId(true); + formView.add(documentsTable); =20 - List> columns =3D new ArrayList>(); - - columns.add(new LinkPropertyColumn(new Model(getString("Document.titre")), "titre", - "titre") { + // Contenu tableaux provenance + ListView documentsListView =3D new ListView("Lis= tDocumentsPage.AttachedDocuments.List", + documents) { @Override - public void onClick(Item> item, String = componentId, IModel model) { - setResponsePage(new ReadDocumentPage(model.getObject(), docu= mentAttachable, currentPage)); - } - }); + protected void populateItem(ListItem item) { + if (item.getIndex() % 2 =3D=3D 1) { + item.add(new AttributeModifier("class", item.getIndex() = % 2 =3D=3D 0 ? "even" : "odd")); + } =20 - columns.add(new PropertyColumn(new Model(g= etString("Document.typeDocument")), - "typeDocument.nom", "typeDocument.nom")); + final IModel documentModel =3D item.getModel(); + // affichage + lien vers la fiche + Link documentLink =3D new Link("Document= .titre.List") { + @Override + public void onClick() { + setResponsePage(new ReadDocumentPage(documentModel.g= etObject(), documentAttachable, currentPage)); + } + }; + documentLink.add(new Label("Document.titre.Label.List", new = PropertyModel(documentModel, "titre"))); + item.add(documentLink); =20 - columns.add(new PropertyColumn(new Model(g= etString("Document.createur")), "createur", - "createur")); + item.add(new Label("Document.typeDocument.List", new Propert= yModel(documentModel, + "typeDocument.nom"))); + item.add(new Label("Document.createur.List", new PropertyMod= el(documentModel, + "createur"))); + item.add(new DocumentLinkPanel("Document.link.List", documen= tModel)); + =20 + item.add(new AjaxButton("Document.Delete.List", Model.of(get= String("Delete"))) { + @Override + protected void onSubmit(AjaxRequestTarget target, Form form) { + Document document =3D documentModel.getObject(); + documentAttachable.removeDocument(document); =20 - columns.add(new DocumentLinkColumn(new Model(getStri= ng("Document.link")))); - - final DataTable attachedDocumentTable =3D new Ajax= FallbackDefaultDataTable( - "ListDocumentsPage.AttachedDocuments", columns, attachedDocu= mentsDataProvider, WebContext.ROWS_PER_PAGE); - - columns.add(new AjaxButtonPropertyColumn(new Model= (getString("Actions")), - new Model(getString("Delete")), formView) { - @Override - public void onSubmit(AjaxRequestTarget target, Form form, IMo= del model) { - Document document =3D model.getObject(); - documentAttachable.removeDocument(document); - - if (target !=3D null) { - target.add(attachedDocumentTable); - } + if (target !=3D null) { + target.add(documentsTable); + } + } + }); =20 } - }); - - attachedDocumentRefresh.add(attachedDocumentTable); - - // Action : cr=C3=A9ation d'un nouveau document - // ajaxSubmitLink permet de sauvegarder l'=C3=A9tat du formulaire - formView.add(new AjaxSubmitLink("NewDocument") { + }; + documentsTable.add(documentsListView); + =20 + documentsTable.add(new AjaxSubmitLink("NewDocument") { @Override protected void onSubmit(AjaxRequestTarget request, Form form)= { setResponsePage(new ManageDocumentPage(currentPage, document= Attachable, false)); Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/do= main/document/panel/ReadListDocumentsPanel.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/ReadListDocumentsPanel.html 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/ReadListDocumentsPanel.html 2013-02-25 15:02:04 UTC (rev 155) @@ -26,7 +26,47 @@
- + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + +
+
+   + +
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/do= main/document/panel/ReadListDocumentsPanel.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/panel/ReadListDocumentsPanel.java 2013-02-25 11:41:29 UTC (rev 154) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/d= ocument/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; =20 -import java.util.ArrayList; import java.util.List; =20 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; =20 -import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.Aja= xFallbackDefaultDataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopu= lator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTabl= e; -import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.Property= Column; +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; =20 /** * Display document list in manage mode. @@ -57,31 +54,49 @@ */ public ReadListDocumentsPanel(String id, final DocumentAttachable docume= ntAttachable, final CallerPage currentPage) { super(id); - List documents =3D documentAttachable.getDocuments(); + final List documents =3D documentAttachable.getDocuments(); =20 - SimpleSortableListDataProvider attachedDocumentsDataProvid= er =3D new SimpleSortableListDataProvider( - documents, getSession().getLocale()); + final MarkupContainer documentsTable =3D new WebMarkupContainer("Lis= tDocumentsPage.AttachedDocuments.Table"); + documentsTable.setOutputMarkupId(true); + add(documentsTable); =20 - List> columns =3D new ArrayList>(); + // Contenu tableaux provenance + ListView documentsListView =3D new ListView("Lis= tDocumentsPage.AttachedDocuments.List", + documents) { + @Override + protected void populateItem(ListItem item) { + if (item.getIndex() % 2 =3D=3D 1) { + item.add(new AttributeModifier("class", item.getIndex() = % 2 =3D=3D 0 ? "even" : "odd")); + } =20 - columns.add(new LinkPropertyColumn(new Model(getString("Document.titre")), "titre", - "titre") { + final IModel documentModel =3D item.getModel(); + // affichage + lien vers la fiche + Link documentLink =3D new Link("Document= .titre.List") { + @Override + public void onClick() { + setResponsePage(new ReadDocumentPage(documentModel.g= etObject(), documentAttachable, currentPage)); + } + }; + documentLink.add(new Label("Document.titre.Label.List", new = PropertyModel(documentModel, "titre"))); + item.add(documentLink); + + item.add(new Label("Document.typeDocument.List", new Propert= yModel(documentModel, + "typeDocument.nom"))); + item.add(new Label("Document.createur.List", new PropertyMod= el(documentModel, + "createur"))); + item.add(new DocumentLinkPanel("Document.link.List", documen= tModel)); + =20 + } + }; + documentsTable.add(documentsListView); + =20 + // Selon la non existence d'elements dans la liste on affiche le span + MarkupContainer noTableDocuments =3D new WebMarkupContainer("ListDoc= umentsPage.AttachedDocuments.noTable") { @Override - public void onClick(Item> item, String = componentId, IModel model) { - setResponsePage(new ReadDocumentPage(model.getObject(), docu= mentAttachable, currentPage)); + public boolean isVisible() { + return documents.isEmpty(); } - }); - - columns.add(new PropertyColumn(new Model(g= etString("Document.typeDocument")), - "typeDocument.nom", "typeDocument.nom")); - - columns.add(new PropertyColumn(new Model(g= etString("Document.createur")), "createur", - "createur")); - - columns.add(new DocumentLinkColumn(new Model(getStri= ng("Document.link")))); - - final DataTable attachedDocumentTable =3D new Ajax= FallbackDefaultDataTable( - "ListDocumentsPage.AttachedDocuments", columns, attachedDocu= mentsDataProvider, WebContext.ROWS_PER_PAGE); - add(attachedDocumentTable); + }; + add(noTableDocuments); } } Deleted: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/col= umns/AjaxButtonPropertyColumn$ButtonPanel.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 @@ - - - - - - - - - \ No newline at end of file Deleted: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/col= umns/AjaxButtonPropertyColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 Developpemen= t) 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. - *=20 - * 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. - *=20 - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #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.ICellPopu= lator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.Abstract= Column; -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 Generic type - * @param the type of the sort property - */ -abstract public class AjaxButtonPropertyColumn extends AbstractColumn<= T, S> { - - /** Title displayed for the button */ - private Model buttonLabel; - - /** Form. */ - private Form form; - - /** - * Constructor - * @param buttonLabel Title displayed for the button - * @param form form - */ - public AjaxButtonPropertyColumn(Model buttonLabel, Form form)= { - this(new Model(), buttonLabel, form); - } - - /** - * Constructor - * @param displayModel header display model - * @param buttonLabel Title displayed for the button - * @param form form - */ - public AjaxButtonPropertyColumn(IModel displayModel, Model buttonLabel, Form form) { - super(displayModel); - this.buttonLabel =3D buttonLabel; - this.form =3D form; - } - - /** {@inheritDoc} */ - @Override - public void populateItem(Item> item, String componentI= d, IModel model) { - ButtonPanel panel =3D new ButtonPanel(item, componentId, model); - item.add(panel); - } - - /** - * Override this method to react to link clicks. Your own/internal row i= d will most likely be inside the model. - * @param target target - * @param form form - * @param model Model - */ - public abstract void onSubmit(AjaxRequestTarget target, Form form, IM= odel model); - - /** - * Panel which include a linkable image. Used with the LinkableImageProp= ertyColumn$LinkablePanel.html file - */ - public class ButtonPanel extends Panel { - - /** - * Constructor - * @param item Item - * @param componentId Component id - * @param model Model - */ - public ButtonPanel(final Item> item, final String = componentId, final IModel model) { - super(componentId); - - AjaxButton button =3D new AjaxButton("button", buttonLabel, form= ) { - @Override - protected void onSubmit(AjaxRequestTarget target, Form fo= rm) { - AjaxButtonPropertyColumn.this.onSubmit(target, form, mod= el); - } - }; - - add(button); - } - } -} \ No newline at end of file --===============8924988059605362951==--