Author: echatellier Date: 2013-03-27 18:04:30 +0100 (Wed, 27 Mar 2013) New Revision: 192 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/192 Log: Add icone for csv export link Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar$ImageResourceLink.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar.html trunk/cantharella.web/src/main/webapp/images/csv_text.png Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar.java Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar$ImageResourceLink.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar$ImageResourceLink.html (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar$ImageResourceLink.html 2013-03-27 17:04:30 UTC (rev 192) @@ -0,0 +1,31 @@ +<!-- + #%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> + <img wicket:id="img" alt="i" /> + <a wicket:id="link" ></a> +</wicket:panel> +</body> +</html> \ No newline at end of file Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar.html (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar.html 2013-03-27 17:04:30 UTC (rev 192) @@ -0,0 +1,31 @@ +<!-- + #%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% + --> +<!-- overridden to remove duplicated <a> into another <a> --> +<wicket:panel xmlns:wicket="http://wicket.apache.org"> + <tr class="export-tr"> + <td wicket:id="td" class="export-td"> + <span wicket:id="exportTo">[export to message]</span> + <span wicket:id="linkContainer"><span wicket:id="exportLink">[data format name]</span></span> + </td> + </tr> +</wicket:panel> \ No newline at end of file Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar.java 2013-03-27 16:15:59 UTC (rev 191) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/data/TableExportToolbar.java 2013-03-27 17:04:30 UTC (rev 192) @@ -27,10 +27,26 @@ import java.util.Date; import java.util.Locale; +import nc.ird.cantharella.web.pages.domain.document.DocumentTooltipColumn; + +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.Component; import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; import org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter; import org.apache.wicket.extensions.markup.html.repeater.data.table.export.ExportToolbar; +import org.apache.wicket.extensions.markup.html.repeater.data.table.export.IDataExporter; +import org.apache.wicket.extensions.markup.html.repeater.data.table.export.ExportToolbar.DataExportResourceStreamWriter; +import org.apache.wicket.markup.html.WebComponent; +import org.apache.wicket.markup.html.image.Image; +import org.apache.wicket.markup.html.link.Link; +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.model.Model; +import org.apache.wicket.request.resource.ContextRelativeResource; +import org.apache.wicket.request.resource.IResource; +import org.apache.wicket.request.resource.ResourceStreamResource; +import org.apache.wicket.util.resource.IResourceStream; /** * Cantharella customisation of wicket {@link ExportToolbar}. @@ -68,4 +84,53 @@ } addDataExporter(csvDataExporter); } + + /** + * Creates a new link to the exported data for the provided {@link IDataExporter}. + * + * @param componentId + * The component of the link. + * @param dataExporter + * The data exporter to use to export the data. + * @return a new link to the exported data for the provided {@link IDataExporter}. + */ + protected Component createExportLink(String componentId, final IDataExporter dataExporter) + { + IResource resource = new ResourceStreamResource() + { + @Override + protected IResourceStream getResourceStream() + { + return new DataExportResourceStreamWriter(dataExporter, getTable()); + } + }.setFileName(getFileNameModel().getObject() + "." + dataExporter.getFileNameExtension()); + + return new ImageResourceLink(componentId, resource, dataExporter); + } + + /** + * Panel which include a image. Used with the LinkableImagePropertyColumn$LinkablePanel.html file + */ + public class ImageResourceLink extends Panel { + + /** + * Constructor + * @param id Component id + * @param resource link resource + * @param dataExporter data exporter + */ + public ImageResourceLink(String id, IResource resource, IDataExporter dataExporter) { + super(id); + + ResourceLink<Void> link = new ResourceLink<Void>("link", resource); + link.setBody(dataExporter.getDataFormatNameModel()); + add(link); + + // add a link on <type>_text.png image + // for CSV : csv_text.png image + String type = dataExporter.getDataFormatNameModel().getObject().toLowerCase(); + WebComponent img = new Image("img", new ContextRelativeResource("images/" + type + "_text.png")); + add(img); + } + } } Added: trunk/cantharella.web/src/main/webapp/images/csv_text.png =================================================================== (Binary files differ) Property changes on: trunk/cantharella.web/src/main/webapp/images/csv_text.png ___________________________________________________________________ Added: svn:mime-type + image/png