Class NatExporter
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.export.NatExporter
-
public class NatExporter extends Object
This class is used to perform exports of a NatTable orILayer
in a NatTable composition. The exporter to use can be configured viaIConfigRegistry
or directly given as method parameter.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
exportSucceeded
Flag that indicates that the export succeeded.protected boolean
openResult
Flag that indicates if the created export result should be opened after the export is finished.protected boolean
preRender
Flag to configure whether in-memory pre-rendering is enabled or not.protected org.eclipse.swt.widgets.Shell
shell
TheShell
that should be used to open sub-dialogs and perform export operations in a background thread.
-
Constructor Summary
Constructors Constructor Description NatExporter(org.eclipse.swt.widgets.Shell shell)
Create a newNatExporter
.NatExporter(org.eclipse.swt.widgets.Shell shell, boolean executeSynchronously)
Create a newNatExporter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disablePreRendering()
Disable in-memory pre-rendering.void
enablePreRendering()
Enable in-memory pre-rendering.protected void
exportLayer(ILayerExporter exporter, OutputStream outputStream, String layerName, ILayer layer, IConfigRegistry configRegistry)
Exports the given layer to the outputStream using the provided exporter.protected void
exportLayer(ILayerExporter exporter, OutputStream outputStream, String layerName, ILayer layer, IConfigRegistry configRegistry, boolean initExportLayer)
Exports the given layer to the outputStream using the provided exporter.protected void
exportLayer(ITableExporter exporter, OutputStream outputStream, ILayer layer, IConfigRegistry configRegistry)
void
exportMultipleNatTables(ILayerExporter exporter, Map<String,NatTable> natTablesMap)
Export multiple NatTable instances to one file by using the given ILayerExporter.void
exportMultipleNatTables(ILayerExporter exporter, Map<String,NatTable> natTablesMap, boolean exportOnSameSheet, String sheetName)
Export multiple NatTable instances to one file by using the given ILayerExporter.void
exportSingleLayer(ILayerExporter exporter, ILayer layer, IConfigRegistry configRegistry)
Exports a singleILayer
using the givenILayerExporter
.void
exportSingleLayer(ILayer layer, IConfigRegistry configRegistry)
Exports a singleILayer
using theILayerExporter
registered in theIConfigRegistry
for the keyExportConfigAttributes.EXPORTER
.void
exportSingleTable(ITableExporter exporter, ILayer layer, IConfigRegistry configRegistry)
Exports a singleILayer
using the givenITableExporter
.void
exportSingleTable(ILayer layer, IConfigRegistry configRegistry)
Exports a singleILayer
using theILayerExporter
registered in theIConfigRegistry
for the keyExportConfigAttributes.EXPORTER
.protected OutputStream
getOutputStream(IExporter exporter)
Method that is used to retrieve theOutputStream
to write the export to in a safe way.protected void
handleExportException(Exception e)
Method that is used to handle exceptions that are raised while processing the export.protected void
openExport(IExporter exporter)
Open the export result in the matching application.protected void
setClientAreaToMaximum(ILayer layer)
Increase the client area so it can include the wholeILayer
.void
setOpenResult(boolean openResult)
Sets the behavior after finishing the export.
-
-
-
Field Detail
-
shell
protected final org.eclipse.swt.widgets.Shell shell
TheShell
that should be used to open sub-dialogs and perform export operations in a background thread.- Since:
- 1.5
-
openResult
protected boolean openResult
Flag that indicates if the created export result should be opened after the export is finished.- Since:
- 1.5
-
exportSucceeded
protected boolean exportSucceeded
Flag that indicates that the export succeeded. Used to determine whether the export result can be opened or not.- Since:
- 1.5
-
preRender
protected boolean preRender
Flag to configure whether in-memory pre-rendering is enabled or not. This is necessary in case content painters are used that are configured for content based auto-resizing.- Since:
- 1.5
-
-
Constructor Detail
-
NatExporter
public NatExporter(org.eclipse.swt.widgets.Shell shell)
Create a newNatExporter
.- Parameters:
shell
- TheShell
that should be used to open sub-dialogs and perform export operations in a background thread. Can benull
but could lead toNullPointerException
s ifIExporter
are configured, that use aFileOutputStreamProvider
.
-
NatExporter
public NatExporter(org.eclipse.swt.widgets.Shell shell, boolean executeSynchronously)
Create a newNatExporter
.- Parameters:
shell
- TheShell
that should be used to open sub-dialogs and perform export operations in a background thread. Can benull
but could lead toNullPointerException
s ifIExporter
are configured, that use aFileOutputStreamProvider
.executeSynchronously
- Configure whether the export should be performed asynchronously or synchronously. By default the decision whether the execution should be performed synchronously or not is made based on whether aShell
is set or not. If aShell
is set and this flag is set totrue
the execution is performed synchronously.- Since:
- 1.6
-
-
Method Detail
-
exportSingleLayer
public void exportSingleLayer(ILayer layer, IConfigRegistry configRegistry)
Exports a singleILayer
using theILayerExporter
registered in theIConfigRegistry
for the keyExportConfigAttributes.EXPORTER
.- Parameters:
layer
- TheILayer
to export, usually a NatTable instance.configRegistry
- TheIConfigRegistry
of the NatTable instance to export, that contains the necessary export configurations.
-
exportSingleLayer
public void exportSingleLayer(ILayerExporter exporter, ILayer layer, IConfigRegistry configRegistry)
Exports a singleILayer
using the givenILayerExporter
.- Parameters:
exporter
- TheILayerExporter
to use for exporting.layer
- TheILayer
to export, usually a NatTable instance.configRegistry
- TheIConfigRegistry
of the NatTable instance to export, that contains the necessary export configurations.- Since:
- 1.5
-
exportSingleTable
public void exportSingleTable(ILayer layer, IConfigRegistry configRegistry)
Exports a singleILayer
using theILayerExporter
registered in theIConfigRegistry
for the keyExportConfigAttributes.EXPORTER
.- Parameters:
layer
- TheILayer
to export, usually a NatTable instance.configRegistry
- TheIConfigRegistry
of the NatTable instance to export, that contains the necessary export configurations.- Since:
- 1.5
-
exportSingleTable
public void exportSingleTable(ITableExporter exporter, ILayer layer, IConfigRegistry configRegistry)
Exports a singleILayer
using the givenITableExporter
.- Parameters:
exporter
- TheITableExporter
to use for exporting.layer
- TheILayer
to export, usually a NatTable instance.configRegistry
- TheIConfigRegistry
of the NatTable instance to export, that contains the necessary export configurations.- Since:
- 1.5
-
exportMultipleNatTables
public void exportMultipleNatTables(ILayerExporter exporter, Map<String,NatTable> natTablesMap)
Export multiple NatTable instances to one file by using the given ILayerExporter.- Parameters:
exporter
- The ILayerExporter to use for exporting.natTablesMap
- The NatTable instances to export. They keys in the map will be used as sheet titles while the values are the instances to export.
-
exportMultipleNatTables
public void exportMultipleNatTables(ILayerExporter exporter, Map<String,NatTable> natTablesMap, boolean exportOnSameSheet, String sheetName)
Export multiple NatTable instances to one file by using the given ILayerExporter.- Parameters:
exporter
- The ILayerExporter to use for exporting.natTablesMap
- The NatTable instances to export. They keys in the map will be used as sheet titles while the values are the instances to export.exportOnSameSheet
- Flag to configure whether multiple NatTable instances should be exported on the same sheet or not.sheetName
- The sheet name that should be used in case of exporting multiple NatTables on a single sheet.- Since:
- 1.5
-
exportLayer
protected void exportLayer(ILayerExporter exporter, OutputStream outputStream, String layerName, ILayer layer, IConfigRegistry configRegistry)
Exports the given layer to the outputStream using the provided exporter. TheILayerExporter.exportBegin(OutputStream)
method should be called before this method is invoked, andILayerExporter.exportEnd(OutputStream)
should be called after this method returns. If multiple layers are being exported as part of a single logical export operation, thenILayerExporter.exportBegin(OutputStream)
will be called once at the very beginning, followed by n calls to this method, and finally followed byILayerExporter.exportEnd(OutputStream)
.Note: This method calls
exportLayer(ILayerExporter, OutputStream, String, ILayer, IConfigRegistry, boolean)
with the parameter initExportLayer set totrue
.- Parameters:
exporter
- TheILayerExporter
that should be used for exporting.outputStream
- TheOutputStream
that should be used to write the export to.layerName
- The name that should be set as sheet name of the export.layer
- TheILayer
that should be exported.configRegistry
- TheIConfigRegistry
needed to retrieve the export configurations.
-
exportLayer
protected void exportLayer(ILayerExporter exporter, OutputStream outputStream, String layerName, ILayer layer, IConfigRegistry configRegistry, boolean initExportLayer)
Exports the given layer to the outputStream using the provided exporter. TheILayerExporter.exportBegin(OutputStream)
method should be called before this method is invoked, andILayerExporter.exportEnd(OutputStream)
should be called after this method returns. If multiple layers are being exported as part of a single logical export operation, thenILayerExporter.exportBegin(OutputStream)
will be called once at the very beginning, followed by n calls to this method, and finally followed byILayerExporter.exportEnd(OutputStream)
.- Parameters:
exporter
- TheILayerExporter
that should be used for exporting.outputStream
- TheOutputStream
that should be used to write the export to.layerName
- The name that should be set as sheet name of the export.layer
- TheILayer
that should be exported.configRegistry
- TheIConfigRegistry
needed to retrieve the export configurations.initExportLayer
- flag to configure whetherILayerExporter.exportLayerBegin(OutputStream, String)
andILayerExporter.exportLayerEnd(OutputStream, String)
should be called or not. Should be set totrue
if multiple NatTable instances should be exported on the same sheet.- Since:
- 1.5
-
exportLayer
protected void exportLayer(ITableExporter exporter, OutputStream outputStream, ILayer layer, IConfigRegistry configRegistry)
- Parameters:
exporter
- TheITableExporter
that should be used for exporting.outputStream
- TheOutputStream
that should be used to write the export to.layer
- TheILayer
that should be exported.configRegistry
- TheIConfigRegistry
needed to retrieve the export configurations.- Since:
- 1.5
-
setClientAreaToMaximum
protected void setClientAreaToMaximum(ILayer layer)
Increase the client area so it can include the wholeILayer
.- Parameters:
layer
- TheILayer
for which the client area should be maximized.- Since:
- 1.5
-
openExport
protected void openExport(IExporter exporter)
Open the export result in the matching application.- Parameters:
exporter
- TheIExporter
that was used to perform the export. Needed to access the export result.- Since:
- 1.5
-
setOpenResult
public void setOpenResult(boolean openResult)
Sets the behavior after finishing the export. The default is opening the created export file with the associated application. You can prevent the opening by setting openResult tofalse
.- Parameters:
openResult
- set totrue
to open the created export file,false
otherwise- Since:
- 1.5
-
getOutputStream
protected OutputStream getOutputStream(IExporter exporter)
Method that is used to retrieve theOutputStream
to write the export to in a safe way. Any occurring exception will be handled inside.- Parameters:
exporter
- TheILayerExporter
that should be used- Returns:
- The
OutputStream
that is used to write the export to ornull
if an error occurs. - Since:
- 1.5
-
handleExportException
protected void handleExportException(Exception e)
Method that is used to handle exceptions that are raised while processing the export.- Parameters:
e
- The exception that should be handled.- Since:
- 1.5
-
enablePreRendering
public void enablePreRendering()
Enable in-memory pre-rendering. This is necessary in case content painters are used that are configured for content based auto-resizing.- Since:
- 1.5
-
disablePreRendering
public void disablePreRendering()
Disable in-memory pre-rendering. You should consider to disable pre-rendering if no content painters are used that are configured for content based auto-resizing.- Since:
- 1.5
-
-