From 03f3d2ff79a46a75e5f2c4080e11a9c3887c3829 Mon Sep 17 00:00:00 2001 From: Vincent Lorenzo Date: Thu, 21 Nov 2013 10:03:14 +0100 Subject: 422219: [Table 2] Export to XLS : header of the exported file must not have the EPL licence https://bugs.eclipse.org/bugs/show_bug.cgi?id=422219 --- .../org.eclipse.papyrus.infra.nattable/plugin.xml | 4 +- .../PapyrusGridLayerConfiguration.java | 11 ++++ .../nattable/export/PapyrusExcelExporter.java | 67 ++++++++++++++++++++++ .../nattable/export/PapyrusExportBindings.java | 36 ++++++++++++ .../nattable/export/papyrusExcelExportHeader.txt | 53 +++++++++++++++++ .../table/AbstractNattableWidgetManager.java | 3 - 6 files changed, 169 insertions(+), 5 deletions(-) create mode 100644 extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExcelExporter.java create mode 100644 extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExportBindings.java create mode 100644 extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/papyrusExcelExportHeader.txt (limited to 'extraplugins') diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml b/extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml index eede999b073..98099b406d9 100644 --- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml +++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml @@ -628,9 +628,9 @@ + name="Export to XLS"> ")); //$NON-NLS-1$ + } + + //this method is private is NatTable... + private void writeHeader(OutputStream outputStream) throws IOException { + InputStream headerStream = null; + try { + headerStream = this.getClass().getResourceAsStream(EXCEL_HEADER_FILE); + int c; + while((c = headerStream.read()) != -1) { + outputStream.write(c); + } + } catch (Exception e) { + Activator.log.error(e); + } finally { + if(isNotNull(headerStream)) { + headerStream.close(); + } + } + } + + private byte[] asBytes(String string) { + return string.getBytes(); + } +} diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExportBindings.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExportBindings.java new file mode 100644 index 00000000000..553737e0f3a --- /dev/null +++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExportBindings.java @@ -0,0 +1,36 @@ +/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.nattable.export; + + +import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; +import org.eclipse.nebula.widgets.nattable.config.IConfiguration; +import org.eclipse.nebula.widgets.nattable.export.ILayerExporter; +import org.eclipse.nebula.widgets.nattable.export.action.ExportAction; +import org.eclipse.nebula.widgets.nattable.export.config.DefaultExportBindings; +import org.eclipse.nebula.widgets.nattable.export.excel.ExcelExporter; +import org.eclipse.nebula.widgets.nattable.layer.ILayer; +import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry; +import org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher; +import org.eclipse.swt.SWT; + +public class PapyrusExportBindings extends DefaultExportBindings { + + public void configureRegistry(IConfigRegistry configRegistry) { + configRegistry.registerConfigAttribute(ILayerExporter.CONFIG_ATTRIBUTE, new PapyrusExcelExporter()); + } + + +} diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/papyrusExcelExportHeader.txt b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/papyrusExcelExportHeader.txt new file mode 100644 index 00000000000..4f7b65b9172 --- /dev/null +++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/papyrusExcelExportHeader.txt @@ -0,0 +1,53 @@ + + + + + + + + diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java index 811fb97a7e0..4f6c12f5112 100644 --- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java +++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java @@ -61,7 +61,6 @@ import org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider; import org.eclipse.papyrus.infra.nattable.dataprovider.BodyDataProvider; import org.eclipse.papyrus.infra.nattable.dataprovider.ColumnHeaderDataProvider; import org.eclipse.papyrus.infra.nattable.dataprovider.RowHeaderDataProvider; -import org.eclipse.papyrus.infra.nattable.formatter.PapyrusExportFormatter; import org.eclipse.papyrus.infra.nattable.layer.PapyrusGridLayer; import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack; import org.eclipse.papyrus.infra.nattable.layerstack.ColumnHeaderLayerStack; @@ -222,8 +221,6 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan configRegistry.registerConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, getLabelProviderService(), DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID); //commented because seems generate several bugs with edition //newRegistry.registerConfigAttribute( CellConfigAttributes.DISPLAY_CONVERTER, new GenericDisplayConverter(), DisplayMode.NORMAL, GridRegion.BODY); - configRegistry.registerConfigAttribute(CellConfigAttributes.EXPORT_FORMATTER, new PapyrusExportFormatter()); - this.natTable.setConfigRegistry(configRegistry); this.natTable.setUiBindingRegistry(new UiBindingRegistry(this.natTable)); this.natTable.configure(); -- cgit v1.2.3