Skip to content

Commit a1b99fc

Browse files
committed
chore(demo): highlight block in VaadinServiceInitListener
1 parent f8a59c4 commit a1b99fc

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterBigDatasetDemo.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import com.flowingcode.vaadin.addons.demo.DemoSource;
2323
import com.flowingcode.vaadin.addons.demo.SourceCodeViewer;
24+
import com.flowingcode.vaadin.addons.gridhelpers.GridHelper;
25+
import com.flowingcode.vaadin.addons.gridhelpers.HeightMode;
2426
import com.github.javafaker.Faker;
2527
import com.vaadin.flow.component.Html;
2628
import com.vaadin.flow.component.grid.Grid;
@@ -38,7 +40,7 @@
3840
import org.apache.poi.EncryptedDocumentException;
3941

4042
@DemoSource
41-
@DemoSource("/src/test/java/com/flowingcode/vaadin/addons/gridexporter/VaadinServiceInitListenerImpl.java")
43+
@DemoSource(clazz = VaadinServiceInitListenerImpl.class)
4244
@PageTitle("Big Dataset")
4345
@Route(value = "gridexporter/bigdataset", layout = GridExporterDemoView.class)
4446
@SuppressWarnings("serial")
@@ -80,29 +82,38 @@ public GridExporterBigDatasetDemo() throws EncryptedDocumentException, IOExcepti
8082
exporter.setFileName(
8183
"GridExport" + new SimpleDateFormat("yyyyddMM").format(Calendar.getInstance().getTime()));
8284

83-
// begin-block concurrent
85+
// show-source add(grid);
86+
8487
// #if vaadin eq 0
85-
Html concurrent = new Html(
88+
GridHelper.setHeightByRows(grid, 6);
89+
GridHelper.setHeightMode(grid, HeightMode.ROW);
90+
Html block1 = new Html(
8691
"""
8792
<div>
8893
This configuration prepares the exporter for the BigDataset demo, enabling it to manage resource-intensive
8994
document generation tasks effectively. In this setup, an upper limit of 10 is established for the cost of
9095
concurrent downloads, and the big dataset exporter is configured with a cost of 9, while other exporters
9196
handling smaller datasets retain the default cost of 1. This customization allows a combination of one large
9297
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-
98+
when no big dataset is being exported.
99+
</div>""");
100+
Html block2 = new Html(
101+
"""
102+
<div>
95103
Additionally, <code>setConcurrentDownloadTimeout</code> enforces a timeout for acquiring the necessary permits
96104
during a download operation. If the permits are not obtained within the specified timeframe, the download
97105
request will be aborted and the <code>DownloadTimeoutEvent</code> listener will execute, preventing prolonged
98106
waiting periods, especially during peak system loads.
99107
</div>""");
100-
add(concurrent);
108+
109+
add(block1, grid, block2);
110+
SourceCodeViewer.highlightOnHover(block1, "concurrent");
111+
SourceCodeViewer.highlightOnHover(block2,
112+
"VaadinServiceInitListenerImpl.java#setConcurrentDownloadTimeout");
101113
// #endif
102-
SourceCodeViewer.highlightOnHover(concurrent, "concurrent");
114+
// begin-block concurrent
103115
exporter.setConcurrentDownloadCost(9);
104116
// end-block
105117

106-
add(grid);
107118
}
108119
}

src/test/java/com/flowingcode/vaadin/addons/gridexporter/VaadinServiceInitListenerImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ public class VaadinServiceInitListenerImpl implements VaadinServiceInitListener
1111
@Override
1212
public void serviceInit(ServiceInitEvent event) {
1313
GridExporter.setConcurrentDownloadLimit(10);
14+
15+
// begin-block setConcurrentDownloadTimeout
1416
GridExporter.setConcurrentDownloadTimeout(5, TimeUnit.SECONDS);
1517
GridExporter.addGlobalConcurrentDownloadTimeoutEvent(ev -> {
1618
Notification.show("System is busy. Please try again later.")
1719
.addThemeVariants(NotificationVariant.LUMO_ERROR);
1820
});
21+
// end-block
22+
1923
}
2024

2125
}

0 commit comments

Comments
 (0)