Skip to content

Commit

Permalink
#508 likely done (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaadin-miki authored Dec 21, 2023
1 parent 3ae2934 commit c3c0dbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions demo-v24/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@
<goal>build-frontend</goal>
</goals>
<phase>compile</phase>
<configuration>
<optimizeBundle>false</optimizeBundle>
</configuration>
</execution>
</executions>
<configuration>
<productionMode>true</productionMode>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
16 changes: 8 additions & 8 deletions demo-v24/src/main/java/org/vaadin/miki/InfoPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<Class<? extends Component>> types = DemoComponentFactory.get().getDemoableComponentTypes();
final ItemGrid<Class<? extends Component>> grid = new ItemGrid<Class<? extends Component>>()
.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(
Expand All @@ -65,16 +67,14 @@ private Component buildDisplayCell(Class<? extends Component> 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);
}
Expand Down

0 comments on commit c3c0dbe

Please sign in to comment.