r235 - trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne
Author: echatellier Date: 2013-05-29 10:49:38 +0200 (Wed, 29 May 2013) New Revision: 235 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/235 Log: Make personn list table exportable Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/TypeDroitColumn.java Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/ListPersonnesPage.java Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/ListPersonnesPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/ListPersonnesPage.java 2013-05-28 13:05:00 UTC (rev 234) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/ListPersonnesPage.java 2013-05-29 08:49:38 UTC (rev 235) @@ -38,6 +38,7 @@ import nc.ird.cantharella.web.utils.CallerPage; import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn; import nc.ird.cantharella.web.utils.columns.LinkableImagePropertyColumn; +import nc.ird.cantharella.web.utils.data.TableExportToolbar; import nc.ird.cantharella.web.utils.models.LoadableDetachableSortableListDataProvider; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; @@ -135,20 +136,7 @@ } }); - columns.add(new AbstractColumn<Personne, String>(getStringModel("Utilisateur.typeDroit")) { - @Override - public void populateItem(Item<ICellPopulator<Personne>> item, String componentId, IModel<Personne> rowModel) { - String typeDroit; - if (rowModel.getObject() instanceof Utilisateur) { - Utilisateur util = (Utilisateur) rowModel.getObject(); - typeDroit = enumValueMessage(util.getTypeDroit()) - + (util.isValide() ? "" : " " + getString(getResource() + ".IsNotValid")); - } else { - typeDroit = getString(Personne.class.getSimpleName()); - } - item.add(new Label(componentId, typeDroit)); - } - }); + columns.add(new TypeDroitColumn(getStringModel("Utilisateur.typeDroit"), this)); columns.add(new DocumentTooltipColumn<Personne, String>(getStringModel("ListDocumentsPage.AttachedDocuments")) { @Override @@ -189,7 +177,8 @@ final DataTable<Personne, String> personnesDataTable = new AjaxFallbackDefaultDataTable<Personne, String>( "ListPersonnesPage.Personnes", columns, personnesDataProvider, WebContext.ROWS_PER_PAGE); - + personnesDataTable.addBottomToolbar(new TableExportToolbar(personnesDataTable, "personnes", getSession() + .getLocale())); personnesRefresh.add(personnesDataTable); } Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/TypeDroitColumn.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/TypeDroitColumn.java (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/TypeDroitColumn.java 2013-05-29 08:49:38 UTC (rev 235) @@ -0,0 +1,87 @@ +/* + * #%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.personne; + +import java.io.Serializable; + +import nc.ird.cantharella.data.model.Personne; +import nc.ird.cantharella.data.model.Utilisateur; +import nc.ird.cantharella.web.pages.TemplatePage; + +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.extensions.markup.html.repeater.data.table.export.IExportableColumn; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; + +/** + * Define TypeDroit column as exportable column. + * + * @author Eric Chatellier + */ +public class TypeDroitColumn extends AbstractColumn<Personne, String> implements + IExportableColumn<Personne, String, Serializable> { + + /** Template page. */ + protected TemplatePage templatePage; + + /** + * Constructor. + * + * @param displayModel model used to generate header text + * @param templatePage templatePage + */ + public TypeDroitColumn(IModel<String> displayModel, TemplatePage templatePage) { + super(displayModel); + this.templatePage = templatePage; + } + + /** {@inheritDoc} */ + @Override + public void populateItem(Item<ICellPopulator<Personne>> item, String componentId, IModel<Personne> rowModel) { + item.add(new Label(componentId, getDataModel(rowModel))); + } + + /** {@inheritDoc} */ + @Override + public IModel<Serializable> getDataModel(final IModel<Personne> rowModel) { + return new Model<Serializable>(rowModel) { + /** {@inheritDoc} */ + @Override + public String getObject() { + String typeDroit; + if (rowModel.getObject() instanceof Utilisateur) { + Utilisateur util = (Utilisateur) rowModel.getObject(); + typeDroit = templatePage.enumValueMessage(util.getTypeDroit()) + + (util.isValide() ? "" : " " + + templatePage.getString(templatePage.getClass().getSimpleName() + ".IsNotValid")); + } else { + typeDroit = templatePage.getString(Personne.class.getSimpleName()); + } + return typeDroit; + } + }; + } +} Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/personne/TypeDroitColumn.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL
participants (1)
-
echatellier@users.forge.codelutin.com