Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2013-11-21 04:03:14 -0500
committerVincent Lorenzo2013-11-21 04:03:14 -0500
commit03f3d2ff79a46a75e5f2c4080e11a9c3887c3829 (patch)
tree524e8586be58019728070ecc59f03b675f74bd67 /extraplugins
parentf3a4a0df2770eb08310b0685b0263baaa4a453ab (diff)
downloadorg.eclipse.papyrus-03f3d2ff79a46a75e5f2c4080e11a9c3887c3829.tar.gz
org.eclipse.papyrus-03f3d2ff79a46a75e5f2c4080e11a9c3887c3829.tar.xz
org.eclipse.papyrus-03f3d2ff79a46a75e5f2c4080e11a9c3887c3829.zip
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
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml4
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java11
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExcelExporter.java67
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExportBindings.java36
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/papyrusExcelExportHeader.txt53
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java3
6 files changed, 169 insertions, 5 deletions
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 @@
</category>
<command
categoryId="org.eclipse.papyrus.editor.category"
- description="Export Table to XLS"
+ description="Export Table to XLS Command"
id="org.eclipse.papyrus.infra.nattable.exporttoXLScommand"
- name="Export Table to XLS Command">
+ name="Export to XLS">
</command>
<command
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java
index b1ca4412e61..13506c41440 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java
@@ -15,6 +15,7 @@ package org.eclipse.papyrus.infra.nattable.configuration;
import org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultGridLayerConfiguration;
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
+import org.eclipse.papyrus.infra.nattable.export.PapyrusExportBindings;
/**
* We change the edit configuration
@@ -43,4 +44,14 @@ public class PapyrusGridLayerConfiguration extends DefaultGridLayerConfiguration
protected void addEditingHandlerConfig() {
addConfiguration(new EditConfiguration());
}
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultGridLayerConfiguration#addExcelExportUIBindings()
+ *
+ */
+ @Override
+ protected void addExcelExportUIBindings() {
+ addConfiguration(new PapyrusExportBindings());
+ }
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExcelExporter.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExcelExporter.java
new file mode 100644
index 00000000000..8e272077bad
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/export/PapyrusExcelExporter.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * 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 static org.eclipse.nebula.widgets.nattable.util.ObjectUtils.isNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.nebula.widgets.nattable.export.FileOutputStreamProvider;
+import org.eclipse.nebula.widgets.nattable.export.IOutputStreamProvider;
+import org.eclipse.nebula.widgets.nattable.export.excel.ExcelExporter;
+import org.eclipse.papyrus.infra.nattable.Activator;
+
+public class PapyrusExcelExporter extends ExcelExporter {
+
+ private static final String EXCEL_HEADER_FILE = "papyrusExcelExportHeader.txt"; //$NON-NLS-1$
+
+ public PapyrusExcelExporter() {
+ this(new FileOutputStreamProvider("table_export.xls", new String[]{ "Excel Workbok (*.xls)" }, new String[]{ "*.xls" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public PapyrusExcelExporter(IOutputStreamProvider outputStreamProvider) {
+ super(outputStreamProvider);
+ }
+
+ @Override
+ public void exportLayerBegin(OutputStream outputStream, String layerName) throws IOException {
+ writeHeader(outputStream);//no super!
+ outputStream.write(asBytes("<body><table border='1'>")); //$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 @@
+<html xmlns:o="urn:schemas-microsoft-com:office:office"
+xmlns:x="urn:schemas-microsoft-com:office:excel"
+xmlns="http://www.w3.org/TR/REC-html40">
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
+<meta name=ProgId content=Excel.Sheet>
+
+<!--[if gte mso 9]><xml>
+ <x:ExcelWorkbook>
+ <x:ExcelWorksheets>
+ <x:ExcelWorksheet>
+ <x:Name>Sheet1</x:Name>
+ <x:WorksheetOptions>
+ <x:Selected/>
+ <x:Panes>
+ <x:Pane>
+ <x:Number>0</x:Number>
+ <x:ActiveRow>0</x:ActiveRow>
+ <x:ActiveCol>0</x:ActiveCol>
+ </x:Pane>
+ </x:Panes>
+ <x:ProtectContents>False</x:ProtectContents>
+ <x:ProtectObjects>False</x:ProtectObjects>
+ <x:ProtectScenarios>False</x:ProtectScenarios>
+ </x:WorksheetOptions>
+ </x:ExcelWorksheet>
+ <x:ExcelWorksheet>
+ <x:Name>Sheet2</x:Name>
+ <x:WorksheetOptions>
+ <x:ProtectContents>False</x:ProtectContents>
+ <x:ProtectObjects>False</x:ProtectObjects>
+ <x:ProtectScenarios>False</x:ProtectScenarios>
+ </x:WorksheetOptions>
+ </x:ExcelWorksheet>
+ <x:ExcelWorksheet>
+ <x:Name>Sheet3</x:Name>
+ <x:WorksheetOptions>
+ <x:ProtectContents>False</x:ProtectContents>
+ <x:ProtectObjects>False</x:ProtectObjects>
+ <x:ProtectScenarios>False</x:ProtectScenarios>
+ </x:WorksheetOptions>
+ </x:ExcelWorksheet>
+ </x:ExcelWorksheets>
+ <x:WindowHeight>8895</x:WindowHeight>
+ <x:WindowWidth>13980</x:WindowWidth>
+ <x:WindowTopX>480</x:WindowTopX>
+ <x:WindowTopY>270</x:WindowTopY>
+ <x:ProtectStructure>False</x:ProtectStructure>
+ <x:ProtectWindows>False</x:ProtectWindows>
+ </x:ExcelWorkbook>
+</xml><![endif]-->
+</head>
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();

Back to the top