From c3c0dbe3777c699c9cac4b6ce7edcf150ad94e0b Mon Sep 17 00:00:00 2001 From: Miki Date: Thu, 21 Dec 2023 16:11:03 +0200 Subject: [PATCH] #508 likely done (#509) --- demo-v24/pom.xml | 6 +++--- .../src/main/java/org/vaadin/miki/InfoPage.java | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/demo-v24/pom.xml b/demo-v24/pom.xml index bc820d5..483ceb0 100644 --- a/demo-v24/pom.xml +++ b/demo-v24/pom.xml @@ -136,11 +136,11 @@ build-frontend compile + + false + - - true - diff --git a/demo-v24/src/main/java/org/vaadin/miki/InfoPage.java b/demo-v24/src/main/java/org/vaadin/miki/InfoPage.java index 4783445..839104a 100644 --- a/demo-v24/src/main/java/org/vaadin/miki/InfoPage.java +++ b/demo-v24/src/main/java/org/vaadin/miki/InfoPage.java @@ -16,7 +16,7 @@ import java.io.IOException; import java.io.InputStream; -import java.util.Locale; +import java.util.Collection; /** * Information about the demo, its organisation and components. @@ -37,12 +37,14 @@ public InfoPage() { new Span("Bottom left corner of the browser window will show major notifications from each component - like value change notifications. Bottom right corner is reserved for secondary notifications, e.g. focus and blur events.") ); + final Collection> types = DemoComponentFactory.get().getDemoableComponentTypes(); final ItemGrid> grid = new ItemGrid>() - .withItems(DemoComponentFactory.get().getDemoableComponentTypes()) + .withItems(types) .withColumnCount(5) .withPaddingCellsClickable(false) .withCellGenerator(this::buildDisplayCell) - .withId("presentation-grid"); + .withId("presentation-grid") + .withLabel("There are %d components with demo pages:".formatted(types.size())); grid.addValueChangeListener(event -> this.getUI() .ifPresent(ui -> ui.navigate( @@ -65,16 +67,14 @@ private Component buildDisplayCell(Class type, int row, int final Div result = new Div(); result.add(new H3(type.getSimpleName())); - try (InputStream resource = this.getClass().getClassLoader().getResourceAsStream(type.getSimpleName().toLowerCase(Locale.ROOT) + ".md")) { + final String resourceName = "/" + type.getSimpleName() + ".md"; + try (InputStream resource = this.getClass().getClassLoader().getResourceAsStream(resourceName)) { if (resource != null) { - try { final Span desc = new Span(new String(resource.readAllBytes())); desc.addClassName("presentation-description"); result.add(desc); - } catch (IOException e) { - LOGGER.error("could not read description for component {}", type.getSimpleName(), e); - } } + else LOGGER.error("did not find resource {}", resourceName); } catch (IOException e) { LOGGER.error("could not open description for component {}", type.getSimpleName(), e); }