File tree Expand file tree Collapse file tree 4 files changed +61
-2
lines changed
main/java/com/flowingcode/vaadin/addons/demo
test/java/com/flowingcode/vaadin/addons/demo Expand file tree Collapse file tree 4 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -183,11 +183,21 @@ public void showRouterLayoutContent(HasElement content) {
183183 String sourceCodeUrl = null ;
184184 if (demoSource != null ) {
185185 sourceCodeUrl = demoSource .value ();
186+
187+ String demoFile ;
186188 if (sourceCodeUrl .equals (DemoSource .GITHUB_SOURCE )) {
189+ String className = demo .getClass ().getName ().replace ('.' , '/' );
190+ demoFile = "src/test/java/" + className + ".java" ;
191+ } else if (sourceCodeUrl .startsWith ("/src/test/" )) {
192+ demoFile = sourceCodeUrl .substring (1 );
193+ } else {
194+ demoFile = null ;
195+ }
196+
197+ if (demoFile != null ) {
187198 String branch = lookupGithubBranch (this .getClass ());
188- String demoFile = demo .getClass ().getName ().replace ('.' , '/' );
189199 sourceCodeUrl = Optional .ofNullable (this .getClass ().getAnnotation (GithubLink .class ))
190- .map (githubLink -> String .format ("%s/blob/%s/src/test/java/%s.java " , githubLink .value (),
200+ .map (githubLink -> String .format ("%s/blob/%s/%s " , githubLink .value (),
191201 branch , demoFile ))
192202 .orElse (null );
193203 }
Original file line number Diff line number Diff line change 1+ /*-
2+ * #%L
3+ * Commons Demo
4+ * %%
5+ * Copyright (C) 2020 - 2023 Flowing Code
6+ * %%
7+ * Licensed under the Apache License, Version 2.0 (the "License");
8+ * you may not use this file except in compliance with the License.
9+ * You may obtain a copy of the License at
10+ *
11+ * http://www.apache.org/licenses/LICENSE-2.0
12+ *
13+ * Unless required by applicable law or agreed to in writing, software
14+ * distributed under the License is distributed on an "AS IS" BASIS,
15+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+ * See the License for the specific language governing permissions and
17+ * limitations under the License.
18+ * #L%
19+ */
20+ package com .flowingcode .vaadin .addons .demo ;
21+
22+ import com .vaadin .flow .component .html .Div ;
23+ import com .vaadin .flow .component .html .Span ;
24+ import com .vaadin .flow .router .PageTitle ;
25+ import com .vaadin .flow .router .Route ;
26+
27+ @ Route (value = "demo/demo-with-adhoc-source" , layout = Demo .class )
28+ @ PageTitle ("Demo with source in a different file" )
29+ @ DemoSource ("/src/test/java/com/flowingcode/vaadin/addons/demo/AdHocSource.java" )
30+ public class AdHocDemo extends Div {
31+
32+ public AdHocDemo () {
33+ add (new Span ("This span is added to the demo view" ));
34+ }
35+
36+ }
Original file line number Diff line number Diff line change 1+ package com .flowingcode .vaadin .addons .demo ;
2+
3+ import com .vaadin .flow .component .html .Div ;
4+ import com .vaadin .flow .component .html .Span ;
5+
6+ public class AdHocSource extends Div {
7+
8+ public AdHocSource () {
9+ add (new Span ("... but sources have this other span instead" ));
10+ }
11+
12+ }
Original file line number Diff line number Diff line change @@ -32,5 +32,6 @@ public Demo() {
3232 addDemo (new LegacyDemo ());
3333 addDemo (SampleDemo .class , "Demo" );
3434 addDemo (SampleDemoDefault .class );
35+ addDemo (AdHocDemo .class );
3536 }
3637}
You can’t perform that action at this time.
0 commit comments