From b37ff72db077963cbd744fc75eb10a8108d7f177 Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:00:42 -0300 Subject: [PATCH] feat: add clazz attribute to DemoSource annotation --- .../vaadin/addons/demo/DemoSource.java | 27 +++++++++++++------ .../vaadin/addons/demo/TabbedDemo.java | 7 ++++- .../vaadin/addons/demo/MultiSourceDemo.java | 6 ++++- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/flowingcode/vaadin/addons/demo/DemoSource.java b/src/main/java/com/flowingcode/vaadin/addons/demo/DemoSource.java index 356efc4..32fa014 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/demo/DemoSource.java +++ b/src/main/java/com/flowingcode/vaadin/addons/demo/DemoSource.java @@ -2,7 +2,7 @@ * #%L * Commons Demo * %% - * Copyright (C) 2020 - 2023 Flowing Code + * Copyright (C) 2020 - 2024 Flowing Code * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,12 +29,12 @@ /** * This annotation is used for configuring the source code URL in a {@link TabbedDemo}. If no {@code - * value} is specified, and the demo view is annotated with {@link GithubLink}, then the source URL - * defaults to the location of the annotated class under {@code src/test/java} and the branch is - * determined from the value of {@link GithubBranch} in the demo view class (if the annotation is - * present) or the containing package of the demo view class. If the source URL is defaulted and no - * {@code GithubBranch} annotation is present either in the demo view class or its containing - * package, then the branch defaults to {@code master}. + * value} or {@code clazz} is specified, and the demo view is annotated with {@link GithubLink}, + * then the source URL defaults to the location of the annotated class under {@code src/test/java} + * and the branch is determined from the value of {@link GithubBranch} in the demo view class (if + * the annotation is present) or the containing package of the demo view class. If the source URL is + * defaulted and no {@code GithubBranch} annotation is present either in the demo view class or its + * containing package, then the branch defaults to {@code master}. * * @author Javier Godoy / Flowing Code */ @@ -47,9 +47,20 @@ static final String DEFAULT_VALUE = "__DEFAULT__"; - /** A link to the source code, if different from the annotated class. */ + /** + * A link to the source code, if different from the annotated class. + *
+ * It is an error if both {@code value} and {@link #clazz()} are specified. + */ String value() default GITHUB_SOURCE; + /** + * The class to display, if different from the annotated class. + *
+ * It is an error if both {@link #value()} and {@code clazz} are specified.
+ */
+ Class> clazz() default DemoSource.class;
+
/**
* The caption of the source tab (displayed if several sources are provided). Default to the file
* name.
diff --git a/src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java b/src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java
index c6317e8..f091e2b 100644
--- a/src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java
+++ b/src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java
@@ -214,7 +214,12 @@ private Optional