Class NatExporter
java.lang.Object
org.eclipse.nebula.widgets.nattable.export.NatExporter
This class is used to perform exports of a NatTable or
ILayer in a
NatTable composition. The exporter to use can be configured via
IConfigRegistry or directly given as method parameter.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag that indicates that the export succeeded.protected booleanFlag that indicates if the created export result should be opened after the export is finished.protected booleanFlag to configure whether in-memory pre-rendering is enabled or not.protected final org.eclipse.swt.widgets.ShellTheShellthat should be used to open sub-dialogs and perform export operations in a background thread. -
Constructor Summary
ConstructorsConstructorDescriptionNatExporter(org.eclipse.swt.widgets.Shell shell) Create a newNatExporter.NatExporter(org.eclipse.swt.widgets.Shell shell, boolean executeSynchronously) Create a newNatExporter.NatExporter(org.eclipse.swt.widgets.Shell shell, boolean executeSynchronously, boolean useProgressDialog) Create a newNatExporter. -
Method Summary
Modifier and TypeMethodDescriptionvoidDisable in-memory pre-rendering.voidEnable in-memory pre-rendering.protected voidexportLayer(ILayerExporter exporter, OutputStream outputStream, String layerName, ILayer layer, IConfigRegistry configRegistry) Exports the given layer to the outputStream using the provided exporter.protected voidexportLayer(ILayerExporter exporter, OutputStream outputStream, String layerName, ILayer layer, IConfigRegistry configRegistry, boolean initExportLayer) Exports the given layer to the outputStream using the provided exporter.protected voidexportLayer(ILayerExporter exporter, OutputStream outputStream, org.eclipse.core.runtime.IProgressMonitor monitor, String layerName, ILayer layer, IConfigRegistry configRegistry, boolean initExportLayer) /** Exports the given layer to the outputStream using the provided exporter.protected voidexportLayer(ITableExporter exporter, OutputStream outputStream, org.eclipse.core.runtime.IProgressMonitor monitor, ILayer layer, IConfigRegistry configRegistry) protected voidexportLayer(ITableExporter exporter, OutputStream outputStream, ILayer layer, IConfigRegistry configRegistry) voidexportMultipleNatTables(ILayerExporter exporter, Map<String, NatTable> natTablesMap) Export multiple NatTable instances to one file by using the given ILayerExporter.voidexportMultipleNatTables(ILayerExporter exporter, Map<String, NatTable> natTablesMap, boolean exportOnSameSheet, String sheetName) Export multiple NatTable instances to one file by using the given ILayerExporter.voidexportSingleLayer(ILayerExporter exporter, ILayer layer, IConfigRegistry configRegistry) Exports a singleILayerusing the givenILayerExporter.voidexportSingleLayer(ILayer layer, IConfigRegistry configRegistry) Exports a singleILayerusing theILayerExporterregistered in theIConfigRegistryfor the keyExportConfigAttributes.EXPORTER.voidexportSingleTable(ITableExporter exporter, ILayer layer, IConfigRegistry configRegistry) Exports a singleILayerusing the givenITableExporter.voidexportSingleTable(ILayer layer, IConfigRegistry configRegistry) Exports a singleILayerusing theILayerExporterregistered in theIConfigRegistryfor the keyExportConfigAttributes.EXPORTER.protected voidfinalizeExportProcess(ILayer layer, IClientAreaProvider originalClientAreaProvider) Reset the table state.protected Stringprotected OutputStreamgetOutputStream(IExporter exporter) Method that is used to retrieve theOutputStreamto write the export to in a safe way.protected Stringprotected org.eclipse.jface.dialogs.ProgressMonitorDialogprotected voidMethod that is used to handle exceptions that are raised while processing the export.booleanprotected voidopenExport(IExporter exporter) Open the export result in the matching application.protected voidprepareExportProcess(ILayer layer, IConfigRegistry configRegistry) Prepare the table for the export process.protected voidsetClientAreaToMaximum(ILayer layer) Increase the client area so it can include the wholeILayer.voidsetOpenResult(boolean openResult) Sets the behavior after finishing the export.voidsetUseProgressDialog(boolean useProgressDialog) Configure how the export progress should be visualized.
-
Field Details
-
shell
protected final org.eclipse.swt.widgets.Shell shellTheShellthat should be used to open sub-dialogs and perform export operations in a background thread.- Since:
- 1.5
-
openResult
protected boolean openResultFlag that indicates if the created export result should be opened after the export is finished.- Since:
- 1.5
-
exportSucceeded
protected boolean exportSucceededFlag that indicates that the export succeeded. Used to determine whether the export result can be opened or not.- Since:
- 1.5
-
preRender
protected boolean preRenderFlag 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 Details
-
NatExporter
public NatExporter(org.eclipse.swt.widgets.Shell shell) Create a newNatExporter.- Parameters:
shell- TheShellthat should be used to open sub-dialogs and perform export operations in a background thread. Can benullbut could lead toNullPointerExceptions ifIExporterare configured, that use aFileOutputStreamProvider.
-
NatExporter
public NatExporter(org.eclipse.swt.widgets.Shell shell, boolean executeSynchronously) Create a newNatExporter.- Parameters:
shell- TheShellthat should be used to open sub-dialogs and perform export operations in a background thread. Can benullbut could lead toNullPointerExceptions ifIExporterare 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 aShellis set or not. If aShellis set and this flag is set totruethe execution is performed synchronously.- Since:
- 1.6
-
NatExporter
public NatExporter(org.eclipse.swt.widgets.Shell shell, boolean executeSynchronously, boolean useProgressDialog) Create a newNatExporter.- Parameters:
shell- TheShellthat should be used to open sub-dialogs and perform export operations in a background thread. Can benullbut could lead toNullPointerExceptions ifIExporterare 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 aShellis set or not. If aShellis set and this flag is set totruethe execution is performed synchronously.- Since:
- 2.3
-
-
Method Details
-
exportSingleLayer
Exports a singleILayerusing theILayerExporterregistered in theIConfigRegistryfor the keyExportConfigAttributes.EXPORTER.- Parameters:
layer- TheILayerto export, usually a NatTable instance.configRegistry- TheIConfigRegistryof the NatTable instance to export, that contains the necessary export configurations.
-
exportSingleLayer
public void exportSingleLayer(ILayerExporter exporter, ILayer layer, IConfigRegistry configRegistry) Exports a singleILayerusing the givenILayerExporter.- Parameters:
exporter- TheILayerExporterto use for exporting.layer- TheILayerto export, usually a NatTable instance.configRegistry- TheIConfigRegistryof the NatTable instance to export, that contains the necessary export configurations.- Since:
- 1.5
-
getProgressMonitorDialog
protected org.eclipse.jface.dialogs.ProgressMonitorDialog getProgressMonitorDialog()- Returns:
- The
ProgressMonitorDialogthat is used to report the export progress to a user, in caseuseProgressDialogistrue. - Since:
- 2.3
- See Also:
-
useProgressDialog
-
exportSingleTable
Exports a singleILayerusing theILayerExporterregistered in theIConfigRegistryfor the keyExportConfigAttributes.EXPORTER.- Parameters:
layer- TheILayerto export, usually a NatTable instance.configRegistry- TheIConfigRegistryof 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 singleILayerusing the givenITableExporter.- Parameters:
exporter- TheITableExporterto use for exporting.layer- TheILayerto export, usually a NatTable instance.configRegistry- TheIConfigRegistryof the NatTable instance to export, that contains the necessary export configurations.- Since:
- 1.5
-
exportMultipleNatTables
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- TheILayerExporterthat should be used for exporting.outputStream- TheOutputStreamthat should be used to write the export to.layerName- The name that should be set as sheet name of the export.layer- TheILayerthat should be exported.configRegistry- TheIConfigRegistryneeded 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- TheILayerExporterthat should be used for exporting.outputStream- TheOutputStreamthat should be used to write the export to.layerName- The name that should be set as sheet name of the export.layer- TheILayerthat should be exported.configRegistry- TheIConfigRegistryneeded 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 totrueif multiple NatTable instances should be exported on the same sheet.- Since:
- 1.5
-
exportLayer
protected void exportLayer(ILayerExporter exporter, OutputStream outputStream, org.eclipse.core.runtime.IProgressMonitor monitor, 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- TheILayerExporterthat should be used for exporting.outputStream- TheOutputStreamthat should be used to write the export to.monitor- TheIProgressMonitorused to report the export process to the user. Can benull.layerName- The name that should be set as sheet name of the export.layer- TheILayerthat should be exported.configRegistry- TheIConfigRegistryneeded 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 totrueif multiple NatTable instances should be exported on the same sheet.- Since:
- 2.3
-
exportLayer
protected void exportLayer(ITableExporter exporter, OutputStream outputStream, ILayer layer, IConfigRegistry configRegistry) - Parameters:
exporter- TheITableExporterthat should be used for exporting.outputStream- TheOutputStreamthat should be used to write the export to.layer- TheILayerthat should be exported.configRegistry- TheIConfigRegistryneeded to retrieve the export configurations.- Since:
- 1.5
-
exportLayer
protected void exportLayer(ITableExporter exporter, OutputStream outputStream, org.eclipse.core.runtime.IProgressMonitor monitor, ILayer layer, IConfigRegistry configRegistry) - Parameters:
exporter- TheITableExporterthat should be used for exporting.outputStream- TheOutputStreamthat should be used to write the export to.monitor- TheIProgressMonitorused to report the export process to the user. Can benull.layer- TheILayerthat should be exported.configRegistry- TheIConfigRegistryneeded to retrieve the export configurations.- Since:
- 2.3
-
prepareExportProcess
Prepare the table for the export process. This involves disabling the viewport for example.- Parameters:
layer- TheILayerthat should be exported.configRegistry- TheIConfigRegistryneeded to retrieve the export configurations.- Since:
- 2.3
-
finalizeExportProcess
Reset the table state. This means to set back the state that was changed inprepareExportProcess(ILayer, IConfigRegistry), e.g. enable the viewport for example.- Parameters:
layer- TheILayerthat should be exported.originalClientAreaProvider- The originalIClientAreaProvider, which was replaced viasetClientAreaToMaximum(ILayer).- Since:
- 2.3
-
getPrepareSubTaskName
- Returns:
- The name that should be shown for the "prepare" subtask in the
ProgressMonitorDialog. - Since:
- 2.3
- See Also:
-
useProgressDialog
-
getExportSubTaskName
- Returns:
- The name that should be shown for the "export data" subtask in
the
ProgressMonitorDialog. - Since:
- 2.3
- See Also:
-
useProgressDialog
-
setClientAreaToMaximum
Increase the client area so it can include the wholeILayer.- Parameters:
layer- TheILayerfor which the client area should be maximized.- Since:
- 1.5
-
openExport
Open the export result in the matching application.- Parameters:
exporter- TheIExporterthat 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 totrueto open the created export file,falseotherwise- Since:
- 1.5
-
getOutputStream
Method that is used to retrieve theOutputStreamto write the export to in a safe way. Any occurring exception will be handled inside.- Parameters:
exporter- TheILayerExporterthat should be used- Returns:
- The
OutputStreamthat is used to write the export to ornullif an error occurs. - Since:
- 1.5
-
handleExportException
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
-
isUseProgressDialog
public boolean isUseProgressDialog()- Returns:
trueif the progress is reported viaProgressMonitorDialog,falseif a custom shell with aProgressBarwill be shown.- Since:
- 2.3
-
setUseProgressDialog
public void setUseProgressDialog(boolean useProgressDialog) Configure how the export progress should be visualized. Will only have an effect if theNatExporterwas created with aShell.- Parameters:
useProgressDialog-trueif the progress should be reported viaProgressMonitorDialog,falseif a custom shell with aProgressBarshould be shown.- Since:
- 2.3
-