|
19 | 19 | */
|
20 | 20 | package com.flowingcode.vaadin.addons.gridexporter;
|
21 | 21 |
|
| 22 | +import com.flowingcode.vaadin.addons.demo.DemoSource; |
| 23 | +import com.flowingcode.vaadin.addons.demo.SourceCodeViewer; |
| 24 | +import com.github.javafaker.Faker; |
| 25 | +import com.vaadin.flow.component.Html; |
| 26 | +import com.vaadin.flow.component.grid.Grid; |
| 27 | +import com.vaadin.flow.component.grid.Grid.Column; |
| 28 | +import com.vaadin.flow.component.html.Div; |
| 29 | +import com.vaadin.flow.router.PageTitle; |
| 30 | +import com.vaadin.flow.router.Route; |
22 | 31 | import java.io.IOException;
|
23 | 32 | import java.math.BigDecimal;
|
24 | 33 | import java.text.SimpleDateFormat;
|
|
27 | 36 | import java.util.stream.Collectors;
|
28 | 37 | import java.util.stream.IntStream;
|
29 | 38 | import org.apache.poi.EncryptedDocumentException;
|
30 |
| -import com.flowingcode.vaadin.addons.demo.DemoSource; |
31 |
| -import com.github.javafaker.Faker; |
32 |
| -import com.vaadin.flow.component.grid.Grid; |
33 |
| -import com.vaadin.flow.component.grid.Grid.Column; |
34 |
| -import com.vaadin.flow.component.html.Div; |
35 |
| -import com.vaadin.flow.router.PageTitle; |
36 |
| -import com.vaadin.flow.router.Route; |
37 | 39 |
|
38 | 40 | @DemoSource
|
| 41 | +@DemoSource("/src/test/java/com/flowingcode/vaadin/addons/gridexporter/VaadinServiceInitListenerImpl.java") |
39 | 42 | @PageTitle("Grid Exporter Addon Big Dataset Demo")
|
40 | 43 | @Route(value = "gridexporter/bigdataset", layout = GridExporterDemoView.class)
|
41 | 44 | @SuppressWarnings("serial")
|
@@ -68,14 +71,37 @@ public GridExporterBigDatasetDemo() throws EncryptedDocumentException, IOExcepti
|
68 | 71 | }).collect(Collectors.toList());
|
69 | 72 | grid.setItems(query->persons.stream().skip(query.getOffset()).limit(query.getLimit()));
|
70 | 73 | grid.setWidthFull();
|
71 |
| - this.setSizeFull(); |
| 74 | + setSizeFull(); |
72 | 75 | GridExporter<Person> exporter = GridExporter.createFor(grid);
|
73 | 76 | exporter.setAutoSizeColumns(false);
|
74 | 77 | exporter.setExportValue(budgetCol, item -> "" + item.getBudget());
|
75 | 78 | exporter.setColumnPosition(lastNameCol, 1);
|
76 | 79 | exporter.setTitle("People information");
|
77 | 80 | exporter.setFileName(
|
78 | 81 | "GridExport" + new SimpleDateFormat("yyyyddMM").format(Calendar.getInstance().getTime()));
|
| 82 | + |
| 83 | + // begin-block concurrent |
| 84 | + // #if vaadin eq 0 |
| 85 | + Html concurrent = new Html( |
| 86 | + """ |
| 87 | + <div> |
| 88 | + This configuration prepares the exporter for the BigDataset demo, enabling it to manage resource-intensive |
| 89 | + document generation tasks effectively. In this setup, an upper limit of 10 is established for the cost of |
| 90 | + concurrent downloads, and the big dataset exporter is configured with a cost of 9, while other exporters |
| 91 | + handling smaller datasets retain the default cost of 1. This customization allows a combination of one large |
| 92 | + dataset download alongside one small dataset download, or up to 10 concurrent downloads of smaller datasets |
| 93 | + when no big dataset is being exported.<p> |
| 94 | +
|
| 95 | + Additionally, <code>setConcurrentDownloadTimeout</code> enforces a timeout for acquiring the necessary permits |
| 96 | + during a download operation. If the permits are not obtained within the specified timeframe, the download |
| 97 | + request will be aborted, preventing prolonged waiting periods, especially during peak system loads. |
| 98 | + </div>"""); |
| 99 | + add(concurrent); |
| 100 | + // #endif |
| 101 | + SourceCodeViewer.highlightOnHover(concurrent, "concurrent"); |
| 102 | + exporter.setConcurrentDownloadCost(9); |
| 103 | + // end-block |
| 104 | + |
79 | 105 | add(grid);
|
80 | 106 | }
|
81 | 107 | }
|
0 commit comments