├── .gitignore ├── LICENSE ├── README.md ├── bck2brwsr ├── .gitignore ├── client-web │ ├── nbactions.xml │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── assembly │ │ │ ├── bck2brwsr.xml │ │ │ └── teavm.xml │ │ └── java │ │ │ └── com │ │ │ └── athaydes │ │ │ └── BrowserMain.java │ │ └── test │ │ └── java │ │ └── com │ │ └── athaydes │ │ └── IntegrationTest.java ├── client │ ├── nbactions.xml │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── assembly │ │ │ ├── javafx.xml │ │ │ └── webpages.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── athaydes │ │ │ │ ├── DataModel.java │ │ │ │ └── Main.java │ │ └── webapp │ │ │ └── pages │ │ │ ├── index.css │ │ │ └── index.html │ │ └── test │ │ └── java │ │ └── com │ │ └── athaydes │ │ └── DataModelTest.java ├── js │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── athaydes │ │ │ └── js │ │ │ └── PlatformServices.java │ │ └── test │ │ └── java │ │ └── com │ │ └── athaydes │ │ └── js │ │ └── JsInteractionTest.java └── pom.xml ├── cheerpj ├── .gitignore ├── Makefile ├── cheerpjswing │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── Main.java └── index.html ├── dart-counter ├── .gitignore ├── CHANGELOG.md ├── README.md ├── analysis_options.yaml ├── pubspec.yaml └── web │ ├── favicon.ico │ ├── index.html │ ├── main.dart │ └── styles.css ├── gwt-app ├── .classpath ├── .gitignore ├── .project ├── GwtApp.launch ├── README.txt ├── build.xml ├── src │ └── com │ │ └── athaydes │ │ ├── GwtApp.gwt.xml │ │ └── client │ │ └── GwtApp.java └── war │ ├── GwtApp.css │ ├── GwtApp.html │ ├── WEB-INF │ └── web.xml │ └── favicon.ico ├── jsweet ├── ..gitignore.swp ├── .gitignore ├── LICENSE ├── README.md ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── quickstart │ │ └── QuickStart.java └── webapp │ ├── index.html │ └── logo.png ├── react ├── counter.js ├── index.html ├── index.js ├── react-dom.production.min.js └── react.production.min.js ├── teavm-latest ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── athaydes │ │ └── Client.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── index.html ├── teavm ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── athaydes │ │ └── Client.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── index.html └── vaadin ├── .gitignore ├── LICENSE.md ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── example │ └── test │ └── MainView.java ├── resources └── banner.txt └── webapp ├── frontend ├── src │ └── README └── styles │ └── README └── icons └── icon.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JVM alternatives to JS 2 | 3 | This repo contains different implementations of a simple counter application in the following Java-based 4 | technologies: 5 | 6 | * CheerpJ 7 | * GWT 8 | * JSweet 9 | * TeaVM 10 | * Vaadin Flow 11 | 12 | > bck2brwsr example is broken - I couldn't get it working. 13 | 14 | For comparison, it also contains the following other implementations: 15 | 16 | * React.js 17 | * Dart 18 | 19 | Code for blog post: [Comparing JVM alternatives to JavaScript](https://renato.athaydes.com/posts/comparing-jvm-alternatives-to-js.html). 20 | 21 | -------------------------------------------------------------------------------- /bck2brwsr/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /bck2brwsr/client-web/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | run 5 | 6 | jar 7 | 8 | 9 | package 10 | bck2brwsr:show 11 | 12 | 13 | true 14 | 15 | 16 | 17 | debug 18 | 19 | jar 20 | 21 | 22 | package 23 | bck2brwsr:show 24 | 25 | 26 | true 27 | NONE 28 | maven 29 | 30 | 31 | 32 | CUSTOM-bck2brwsr-show 33 | Run in a Browser 34 | 35 | package 36 | bck2brwsr:show 37 | 38 | 39 | true 40 | NONE 41 | 42 | 43 | 44 | CUSTOM-bck2brwsr-web 45 | Package for website 46 | 47 | clean 48 | package 49 | 50 | 51 | true 52 | 53 | 54 | 55 | CUSTOM-teavm-show 56 | Run in a Browser via TeaVM 57 | 58 | package 59 | bck2brwsr:show 60 | 61 | 62 | teavm 63 | 64 | 65 | true 66 | 67 | 68 | 69 | CUSTOM-teavm-show 70 | Debug in a Browser via TeaVM 71 | 72 | package 73 | bck2brwsr:show 74 | 75 | 76 | teavm 77 | 78 | 79 | true 80 | true 81 | 82 | 83 | 84 | CUSTOM-teavm-web 85 | Package for website via TeaVM 86 | 87 | clean 88 | package 89 | 90 | 91 | true 92 | 93 | 94 | teavm 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /bck2brwsr/client-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.athaydes 8 | bck2brwsr-pom 9 | 1.0-SNAPSHOT 10 | 11 | 12 | com.athaydes 13 | bck2brwsr-web 14 | 1.0-SNAPSHOT 15 | jar 16 | 17 | bck2brwsr Client for Web 18 | 19 | 20 | none 21 | com.athaydes.BrowserMain 22 | initialize bck2brwsr --> 23 | <script type="text/javascript" src="bck2brwsr.js"></script> 24 | <script> 25 | var vm = bck2brwsr('bck2brwsr-web.js'); 26 | var c = vm.loadClass('com.athaydes.BrowserMain'); 27 | c.invoke('main'); 28 | </script> 29 | <!-- end of initialization 30 | 31 | 32 | 33 | 34 | org.netbeans.html 35 | html4j-maven-plugin 36 | ${net.java.html.version} 37 | 38 | 39 | js-classes 40 | 41 | process-js-annotations 42 | 43 | 44 | 45 | 46 | 47 | org.apache.maven.plugins 48 | maven-compiler-plugin 49 | 2.3.2 50 | 51 | 1.7 52 | 1.7 53 | 54 | netbeans.ignore.jdk.bootclasspath 55 | 56 | 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-jar-plugin 61 | 2.4 62 | 63 | 64 | 65 | ${project.mainclass} 66 | true 67 | lib/ 68 | false 69 | 70 | 71 | 72 | 73 | 74 | org.apidesign.bck2brwsr 75 | bck2brwsr-maven-plugin 76 | ${bck2brwsr.version} 77 | 78 | 79 | 80 | brwsr 81 | aot 82 | 83 | 84 | 85 | 86 | ${bck2brwsr.obfuscationlevel} 87 | ${project.build.directory}/${project.build.finalName}-bck2brwsr/public_html/ 88 | index.html 89 | lib 90 | ${project.build.directory}/bck2brwsr-web.js 91 | 92 | ${project.mainclass} 93 | 94 | 95 | 96 | 97 | maven-assembly-plugin 98 | 2.4 99 | 100 | 101 | distro-assembly 102 | package 103 | 104 | single 105 | 106 | 107 | 108 | src/main/assembly/bck2brwsr.xml 109 | 110 | 111 | 112 | 113 | 114 | 115 | org.apache.maven.plugins 116 | maven-dependency-plugin 117 | 2.9 118 | 119 | 120 | unpack 121 | process-resources 122 | 123 | unpack-dependencies 124 | 125 | 126 | 127 | 128 | zip 129 | webpages 130 | true 131 | target/web/pages 132 | */** 133 | ${project.groupId} 134 | 135 | 136 | 137 | org.apache.maven.plugins 138 | maven-surefire-plugin 139 | 2.19.1 140 | 141 | com.dukescript.api:junit-osgi 142 | 143 | false 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | com.athaydes 152 | bck2brwsr 153 | ${project.version} 154 | 155 | 156 | org.netbeans.html 157 | net.java.html.boot.fx 158 | 159 | 160 | 161 | 162 | org.apidesign.bck2brwsr 163 | emul 164 | ${bck2brwsr.version} 165 | rt 166 | 167 | 168 | org.netbeans.html 169 | net.java.html.boot 170 | ${net.java.html.version} 171 | 172 | 173 | asm 174 | org.ow2.asm 175 | 176 | 177 | 178 | 179 | org.apidesign.bck2brwsr 180 | emul 181 | ${bck2brwsr.version} 182 | bck2brwsr 183 | provided 184 | 185 | 186 | org.apidesign.bck2brwsr 187 | ko-bck2brwsr 188 | ${bck2brwsr.version} 189 | bck2brwsr 190 | provided 191 | 192 | 193 | com.athaydes 194 | bck2brwsr-js 195 | ${project.version} 196 | bck2brwsr 197 | provided 198 | jar 199 | 200 | 201 | 202 | 203 | 204 | com.dukescript.api 205 | junit-osgi 206 | test 207 | 208 | 209 | com.dukescript.api 210 | junit-browser-runner 211 | test 212 | 213 | 214 | 215 | 216 | org.netbeans.html 217 | net.java.html.boot.fx 218 | ${net.java.html.version} 219 | test 220 | 221 | 222 | com.oracle 223 | javafx 224 | 225 | 226 | 227 | 228 | org.openjfx 229 | javafx-web 230 | ${openjfx.version} 231 | test 232 | 233 | 234 | 235 | 236 | org.apidesign.bck2brwsr 237 | launcher.http 238 | ${bck2brwsr.version} 239 | test 240 | jar 241 | 242 | 243 | com.dukescript.api 244 | junit-browser-runner 245 | ${junit.browser.version} 246 | test 247 | bck2brwsr 248 | jar 249 | 250 | 251 | org.netbeans.html 252 | net.java.html 253 | 254 | 255 | org.netbeans.html 256 | net.java.html.boot 257 | 258 | 259 | org.apidesign.bck2brwsr 260 | emul 261 | 262 | 263 | 264 | 265 | 266 | 267 | teavm 268 | 269 | 0.4.0 270 | false 271 | initialize TeaVM --> 272 | <script type="text/javascript" src="teavm.js"></script> 273 | <script> 274 | main(); 275 | </script> 276 | <!-- end of initialization 277 | 278 | 279 | 280 | 281 | org.netbeans.html 282 | ko4j 283 | ${net.java.html.version} 284 | 285 | 286 | 287 | 288 | 289 | org.teavm 290 | teavm-maven-plugin 291 | ${teavm.version} 292 | 293 | 294 | org.teavm 295 | teavm-classlib 296 | ${teavm.version} 297 | 298 | 300 | 301 | org.teavm 302 | teavm-html4j 303 | ${teavm.version} 304 | 305 | 306 | 307 | 308 | generate-teavm 309 | 310 | compile 311 | 312 | process-classes 313 | 314 | ${project.mainclass} 315 | ${teavm.debug} 316 | ${teavm.debug} 317 | ${teavm.debug} 318 | 319 | false 320 | 321 | false 322 | 323 | MERGED 324 | 325 | teavm.js 326 | ${project.build.directory}/teavm 327 | 333 | 334 | 335 | 336 | 337 | 338 | maven-assembly-plugin 339 | 2.4 340 | 341 | 342 | distro-assembly 343 | package 344 | 345 | single 346 | 347 | 348 | 349 | src/main/assembly/teavm.xml 350 | 351 | 352 | 353 | 354 | 355 | 356 | org.apidesign.bck2brwsr 357 | bck2brwsr-maven-plugin 358 | ${bck2brwsr.version} 359 | 360 | 361 | 362 | brwsr 363 | 364 | 365 | 366 | 367 | ${project.build.directory}/${project.build.finalName}-teavm/public_html/ 368 | index.html 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | -------------------------------------------------------------------------------- /bck2brwsr/client-web/src/main/assembly/bck2brwsr.xml: -------------------------------------------------------------------------------- 1 | 2 | 27 | 29 | 30 | bck2brwsr 31 | 32 | zip 33 | dir 34 | 35 | public_html 36 | 37 | 38 | target/web/pages 39 | / 40 | 41 | index.html 42 | 43 | 44 | 45 | target/web/pages 46 | / 47 | true 48 | 49 | index.html 50 | 51 | 52 | 53 | ${project.build.directory} 54 | / 55 | 56 | *.js 57 | lib/*.js 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /bck2brwsr/client-web/src/main/assembly/teavm.xml: -------------------------------------------------------------------------------- 1 | 2 | 27 | 29 | 30 | teavm 31 | 32 | zip 33 | dir 34 | 35 | public_html 36 | 37 | 38 | target/web/pages 39 | / 40 | 41 | index.html 42 | 43 | 44 | 45 | target/web/pages 46 | / 47 | true 48 | 49 | index.html 50 | 51 | 52 | 53 | ${project.build.directory}/teavm/ 54 | / 55 | false 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /bck2brwsr/client-web/src/main/java/com/athaydes/BrowserMain.java: -------------------------------------------------------------------------------- 1 | package com.athaydes; 2 | 3 | import com.athaydes.js.PlatformServices; 4 | 5 | public class BrowserMain { 6 | private BrowserMain() { 7 | } 8 | 9 | public static void main(String... args) throws Exception { 10 | Main.onPageLoad(new HTML5Services()); 11 | } 12 | 13 | private static final class HTML5Services extends PlatformServices { 14 | // default behavior is enough for now 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /bck2brwsr/client-web/src/test/java/com/athaydes/IntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.athaydes; 2 | 3 | import net.java.html.junit.BrowserRunner; 4 | import net.java.html.junit.HTMLContent; 5 | import static org.junit.Assert.assertEquals; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | 9 | /** Tests for behavior of your application in real systems. The {@link BrowserRunner} 10 | * selects all possible presenters from your pom.xml and 11 | * runs the tests inside of them. By default there are two: 12 | * 16 | * 17 | * See your pom.xml dependency section for details. 18 | */ 19 | @RunWith(BrowserRunner.class) 20 | @HTMLContent( 21 | "

Test in JavaFX WebView and pluginless Browser

\n" + 22 | "\n" + 23 | "\n" + 28 | "\n" 29 | ) 30 | public class IntegrationTest { 31 | @Test public void testUIModelUI() { 32 | Data model = new Data(); 33 | model.applyBindings(); 34 | model.setMessage("Hello World by JavaFX WebView"); 35 | 36 | java.util.List arr = model.getWords(); 37 | assertEquals("Six words always", arr.size(), 6); 38 | assertEquals("Hello is the first word", "Hello", arr.get(0)); 39 | assertEquals("World is the second word", "World", arr.get(1)); 40 | assertEquals("JavaFX", arr.get(3)); 41 | 42 | model.setMessage("Hello World by Bck2Brwsr Virtual Machine"); 43 | 44 | arr = model.getWords(); 45 | assertEquals("Six words always", arr.size(), 6); 46 | assertEquals("Hello is the first word", "Hello", arr.get(0)); 47 | assertEquals("World is the second word", "World", arr.get(1)); 48 | assertEquals("Bck2Brwsr", arr.get(3)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bck2brwsr/client/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | run 5 | 6 | process-classes 7 | exec:exec 8 | 9 | 10 | desktop 11 | 12 | 13 | 14 | debug 15 | 16 | process-classes 17 | exec:exec 18 | 19 | 20 | true 21 | -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} 22 | 23 | 24 | desktop 25 | 26 | 27 | 28 | CUSTOM-Build Desktop App 29 | Build Desktop App 30 | 31 | clean 32 | package 33 | 34 | 35 | desktop 36 | 37 | 38 | 39 | CUSTOM-Browser-Presenter 40 | Run with Browser Presenter 41 | 42 | process-classes 43 | exec:exec 44 | 45 | 46 | browser-presenter 47 | 48 | 49 | 50 | CUSTOM-WebKit-Presenter 51 | Run with WebKit Presenter 52 | 53 | process-classes 54 | exec:exec 55 | 56 | 57 | webkit-presenter 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /bck2brwsr/client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.athaydes 8 | bck2brwsr-pom 9 | 1.0-SNAPSHOT 10 | 11 | 12 | com.athaydes 13 | bck2brwsr 14 | 1.0-SNAPSHOT 15 | bundle 16 | 17 | bck2brwsr General Client Code 18 | 19 | 20 | all 21 | com.athaydes.Main 22 | ${java.home}/bin/java 23 | -Ddebug=false 24 | -Djavaagent=false 25 | 26 | 27 | 28 | 29 | org.apache.felix 30 | maven-bundle-plugin 31 | 2.4.0 32 | true 33 | 34 | 35 | com.athaydes 36 | com.athaydes 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-compiler-plugin 43 | 2.3.2 44 | 45 | 1.7 46 | 1.7 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-surefire-plugin 52 | 2.19.1 53 | 54 | com.dukescript.api:junit-osgi 55 | 56 | true 57 | 58 | 59 | 60 | 61 | maven-source-plugin 62 | 2.2.1 63 | 64 | 65 | attach-sources 66 | post-integration-test 67 | 68 | jar-no-fork 69 | 70 | 71 | 72 | 73 | 74 | org.codehaus.mojo 75 | exec-maven-plugin 76 | 1.2.1 77 | 78 | ${exec.java.bin} 79 | runtime 80 | 81 | -classpath 82 | 83 | ${springloaded.javaagent} 84 | -Xverify:none 85 | -Dbrowser.rootdir=${basedir}/src/main/webapp/ 86 | -Dnetbeans.inspect.port=${netbeans.inspect.port} 87 | ${exec.debug.arg} 88 | ${project.mainclass} 89 | 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-dependency-plugin 95 | 2.10 96 | 97 | 98 | copy 99 | process-classes 100 | 101 | copy 102 | 103 | 104 | 105 | 106 | org.springframework 107 | springloaded 108 | 1.2.3.RELEASE 109 | jar 110 | false 111 | springloaded.jar 112 | 113 | 114 | ${project.build.directory} 115 | 116 | 117 | 118 | 119 | 120 | maven-assembly-plugin 121 | 2.4 122 | 123 | 124 | web-pages 125 | package 126 | 127 | single 128 | 129 | 130 | 131 | src/main/assembly/webpages.xml 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | org.netbeans.html 142 | net.java.html 143 | ${net.java.html.version} 144 | 145 | 146 | org.netbeans.html 147 | net.java.html.json 148 | ${net.java.html.version} 149 | 150 | 151 | org.netbeans.html 152 | net.java.html.boot 153 | ${net.java.html.version} 154 | 155 | 156 | org.netbeans.html 157 | net.java.html.sound 158 | ${net.java.html.version} 159 | 160 | 161 | org.netbeans.html 162 | ko4j 163 | ${net.java.html.version} 164 | runtime 165 | 166 | 167 | com.athaydes 168 | bck2brwsr-js 169 | ${project.version} 170 | 171 | 172 | org.netbeans.html 173 | net.java.html.boot.fx 174 | ${net.java.html.version} 175 | provided 176 | 177 | 178 | org.openjfx 179 | javafx-web 180 | ${openjfx.version} 181 | test 182 | 183 | 184 | 185 | com.dukescript.api 186 | junit-osgi 187 | test 188 | 189 | 190 | com.dukescript.api 191 | junit-browser-runner 192 | test 193 | 194 | 195 | 204 | 205 | 206 | 207 | org.apidesign.bck2brwsr 208 | launcher.http 209 | ${bck2brwsr.version} 210 | test 211 | jar 212 | 213 | 214 | org.apidesign.bck2brwsr 215 | ko-bck2brwsr 216 | ${bck2brwsr.version} 217 | bck2brwsr 218 | test 219 | jar 220 | 221 | 222 | com.dukescript.api 223 | junit-browser-runner 224 | ${junit.browser.version} 225 | test 226 | bck2brwsr 227 | jar 228 | 229 | 230 | 231 | 232 | 233 | desktop 234 | 235 | 236 | org.netbeans.html 237 | net.java.html.boot.fx 238 | ${net.java.html.version} 239 | runtime 240 | 241 | 242 | org.openjfx 243 | javafx-web 244 | ${openjfx.version} 245 | runtime 246 | 247 | 248 | 249 | 250 | 251 | org.apache.maven.plugins 252 | maven-jar-plugin 253 | 2.4 254 | 255 | 256 | 257 | ${project.mainclass} 258 | true 259 | lib/ 260 | false 261 | 262 | 263 | 264 | 265 | 266 | maven-assembly-plugin 267 | 2.4 268 | 269 | 270 | distro-assembly 271 | package 272 | 273 | single 274 | 275 | 276 | 277 | src/main/assembly/javafx.xml 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | webkit-presenter 288 | 289 | 290 | com.dukescript.presenters 291 | webkit 292 | ${presenters.version} 293 | runtime 294 | 295 | 296 | 297 | 298 | browser-presenter 299 | 300 | 301 | com.dukescript.presenters 302 | browser 303 | ${presenters.version} 304 | runtime 305 | 306 | 307 | 308 | 309 | jdk-8 310 | 311 | 1.8 312 | 313 | 314 | -javaagent:${project.build.directory}/springloaded.jar 315 | 316 | 317 | 318 | 319 | -------------------------------------------------------------------------------- /bck2brwsr/client/src/main/assembly/javafx.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | javafx 6 | 7 | zip 8 | 9 | ${project.build.finalName}-app 10 | 11 | 12 | false 13 | runtime 14 | lib 15 | ${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension} 16 | 17 | 18 | 19 | 20 | ${project.build.directory}/${project.build.finalName}.jar 21 | / 22 | 23 | 24 | 25 | 26 | src/main/webapp/ 27 | / 28 | 29 | pages/** 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /bck2brwsr/client/src/main/assembly/webpages.xml: -------------------------------------------------------------------------------- 1 | 2 | 27 | 29 | 30 | webpages 31 | 32 | zip 33 | 34 | / 35 | 36 | 37 | src/main/webapp/pages 38 | / 39 | false 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /bck2brwsr/client/src/main/java/com/athaydes/DataModel.java: -------------------------------------------------------------------------------- 1 | package com.athaydes; 2 | 3 | import net.java.html.json.ComputedProperty; 4 | import net.java.html.json.Function; 5 | import net.java.html.json.Model; 6 | import net.java.html.json.Property; 7 | import net.java.html.json.ModelOperation; 8 | import net.java.html.json.OnPropertyChange; 9 | import com.athaydes.js.PlatformServices; 10 | /** Model annotation generates class Data with 11 | * one message property, boolean property and read only words property 12 | */ 13 | @Model(className = "Data", targetId = "", instance = true, properties = { 14 | @Property(name = "message", type = String.class), 15 | @Property(name = "rotating", type = boolean.class) 16 | }) 17 | final class DataModel { 18 | private PlatformServices services; 19 | 20 | @ComputedProperty static java.util.List words(String message) { 21 | String[] arr = new String[6]; 22 | String[] words = message == null ? new String[0] : message.split(" ", 6); 23 | for (int i = 0; i < 6; i++) { 24 | arr[i] = words.length > i ? words[i] : "!"; 25 | } 26 | return java.util.Arrays.asList(arr); 27 | } 28 | 29 | @Function static void turnAnimationOn(Data model) { 30 | model.setRotating(true); 31 | } 32 | 33 | @Function 34 | void turnAnimationOff(final Data model) { 35 | services.confirmByUser("Really turn off?", new Runnable() { 36 | @Override 37 | public void run() { 38 | model.setRotating(false); 39 | } 40 | }); 41 | } 42 | 43 | @Function static void rotate5s(final Data model) { 44 | model.setRotating(true); 45 | java.util.Timer timer = new java.util.Timer("Rotates a while"); 46 | timer.schedule(new java.util.TimerTask() { 47 | @Override 48 | public void run() { 49 | model.setRotating(false); 50 | } 51 | }, 5000); 52 | } 53 | 54 | @Function 55 | void showScreenSize(Data model) { 56 | int[] widthHeight = services.getScreenSize(); 57 | model.setMessage("Screen size is " + widthHeight[0] + " x " + widthHeight[1]); 58 | } 59 | 60 | @OnPropertyChange("message") 61 | void storeMessage(Data model) { 62 | final String msg = model.getMessage(); 63 | if (services != null && !msg.contains("Screen size")) { 64 | services.setPreferences("message", msg); 65 | } 66 | } 67 | 68 | @ModelOperation 69 | void initServices(Data model, PlatformServices services) { 70 | this.services = services; 71 | String previousMessage = services.getPreferences("message"); 72 | if (previousMessage != null) { 73 | model.setMessage(previousMessage); 74 | } 75 | } 76 | /** 77 | * Called when the page is ready. 78 | */ 79 | static void onPageLoad(PlatformServices services) { 80 | Data ui = new Data(); 81 | ui.setMessage("Hello World from HTML and Java!"); 82 | ui.initServices(services); 83 | ui.applyBindings(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /bck2brwsr/client/src/main/java/com/athaydes/Main.java: -------------------------------------------------------------------------------- 1 | package com.athaydes; 2 | 3 | import com.athaydes.js.PlatformServices; 4 | import java.util.prefs.Preferences; 5 | import net.java.html.boot.BrowserBuilder; 6 | 7 | public final class Main { 8 | private Main() { 9 | } 10 | 11 | public static void main(String... args) throws Exception { 12 | BrowserBuilder.newBrowser(). 13 | loadPage("pages/index.html"). 14 | loadClass(Main.class). 15 | invoke("onPageLoad", args). 16 | showAndWait(); 17 | System.exit(0); 18 | } 19 | 20 | /** 21 | * Called when the page is ready. 22 | */ 23 | public static void onPageLoad(PlatformServices services) throws Exception { 24 | DataModel.onPageLoad(services); 25 | } 26 | 27 | public static void onPageLoad() throws Exception { 28 | // don't put "common" initialization stuff here, other platforms (iOS, Android, Bck2Brwsr) may not call this method. They rather call DataModel.onPageLoad 29 | DataModel.onPageLoad(new DesktopServices()); 30 | } 31 | 32 | private static final class DesktopServices extends PlatformServices { 33 | @Override 34 | public String getPreferences(String key) { 35 | return Preferences.userNodeForPackage(Main.class).get(key, null); 36 | } 37 | 38 | @Override 39 | public void setPreferences(String key, String value) { 40 | Preferences.userNodeForPackage(Main.class).put(key, value); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bck2brwsr/client/src/main/webapp/pages/index.css: -------------------------------------------------------------------------------- 1 | @-webkit-keyframes spin { 2 | 0% { -webkit-transform: rotate(0deg); } 3 | 100% { -webkit-transform: rotate(360deg); } 4 | } 5 | @keyframes spin { 6 | 0% { transform: rotate(0deg); } 7 | 100% { transform: rotate(360deg); } 8 | } 9 | 10 | input { 11 | width: 100%; 12 | } 13 | 14 | .rotate { 15 | -webkit-animation-name: spin; 16 | -webkit-animation-duration: 3s; 17 | -webkit-animation-iteration-count: infinite; 18 | -webkit-animation-direction: alternate; 19 | animation-name: spin; 20 | animation-duration: 3s; 21 | animation-iteration-count: infinite; 22 | animation-direction: alternate; 23 | } 24 | 25 | #scene { 26 | position: relative; 27 | top: 60px; 28 | text-align: center; 29 | } 30 | 31 | #words span { 32 | border: 1px solid #ccc; 33 | background: rgba(255,255,155,0.8); 34 | text-align: center; 35 | font-size: 30px; 36 | -webkit-box-shadow: inset 0 0 40px rgba(0,0,0,0.4); 37 | box-shadow: inset 0 0 40px rgba(0,0,0,0.4); 38 | position: absolute; 39 | } 40 | 41 | #words span:nth-child(1) { left: 45%; top: 0px; } 42 | #words span:nth-child(2) { left: 25%; top: 100px; } 43 | #words span:nth-child(3) { left: 65%; top: 100px; } 44 | #words span:nth-child(4) { left: 10%; top: 200px; } 45 | #words span:nth-child(5) { left: 45%; top: 200px; } 46 | #words span:nth-child(6) { left: 80%; top: 200px; } 47 | -------------------------------------------------------------------------------- /bck2brwsr/client/src/main/webapp/pages/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Words Demo

10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /bck2brwsr/client/src/test/java/com/athaydes/DataModelTest.java: -------------------------------------------------------------------------------- 1 | package com.athaydes; 2 | 3 | import net.java.html.junit.BrowserRunner; 4 | import static org.junit.Assert.assertEquals; 5 | import org.junit.runner.RunWith; 6 | import org.junit.Test; 7 | 8 | /** Tests for behavior of your application in isolation. Verify 9 | * behavior of your MVVC code in a unit test. 10 | */ 11 | @RunWith(BrowserRunner.class) 12 | public class DataModelTest { 13 | @Test public void testUIModelWithoutUI() { 14 | Data model = new Data(); 15 | model.setMessage("Hello World!"); 16 | 17 | java.util.List arr = model.getWords(); 18 | assertEquals("Six words always", arr.size(), 6); 19 | assertEquals("Hello is the first word", "Hello", arr.get(0)); 20 | assertEquals("World is the second word", "World!", arr.get(1)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bck2brwsr/js/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.athaydes 6 | bck2brwsr-pom 7 | 1.0-SNAPSHOT 8 | 9 | 10 | com.athaydes 11 | bck2brwsr-js 12 | 1.0-SNAPSHOT 13 | bundle 14 | 15 | bck2brwsr JavaScript Libraries 16 | 17 | 18 | none 19 | 20 | 21 | 22 | 23 | org.apache.felix 24 | maven-bundle-plugin 25 | 2.4.0 26 | true 27 | 28 | 29 | com.athaydes.js 30 | com.athaydes.js 31 | 32 | 33 | 34 | 35 | org.netbeans.html 36 | html4j-maven-plugin 37 | ${net.java.html.version} 38 | 39 | 40 | js-classes 41 | 42 | process-js-annotations 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-compiler-plugin 50 | 2.3.2 51 | 52 | 1.7 53 | 1.7 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-surefire-plugin 59 | 2.19.1 60 | 61 | com.dukescript.api:junit-osgi 62 | 63 | true 64 | 65 | 66 | 67 | 68 | org.apidesign.bck2brwsr 69 | bck2brwsr-maven-plugin 70 | ${bck2brwsr.version} 71 | 72 | 73 | 74 | library 75 | 76 | 77 | 78 | 79 | NONE 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.netbeans.html 87 | net.java.html.boot 88 | ${net.java.html.version} 89 | 90 | 91 | com.dukescript.api 92 | junit-osgi 93 | test 94 | 95 | 96 | com.dukescript.api 97 | junit-browser-runner 98 | test 99 | 100 | 101 | 102 | 103 | org.netbeans.html 104 | net.java.html.boot.script 105 | ${net.java.html.version} 106 | test 107 | jar 108 | 109 | 110 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /bck2brwsr/js/src/main/java/com/athaydes/js/PlatformServices.java: -------------------------------------------------------------------------------- 1 | package com.athaydes.js; 2 | 3 | import net.java.html.js.JavaScriptBody; 4 | 5 | /** Use {@link JavaScriptBody} annotation on methods to 6 | * directly interact with JavaScript. See 7 | * http://bits.netbeans.org/html+java/1.3/net/java/html/js/package-summary.html 8 | * to understand how. 9 | */ 10 | public class PlatformServices { 11 | /** 12 | * Reads a value from a persistent storage. 13 | * @param key the identification for the value 14 | * @return the value or null if not found 15 | */ 16 | public String getPreferences(String key) { 17 | return getPreferencesImpl(key); 18 | } 19 | 20 | /** 21 | * Puts a value into the persitent storage. 22 | * @param key the identification for the value 23 | * @param value the value to store 24 | */ 25 | public void setPreferences(String key, String value) { 26 | setPreferencesImpl(key, value); 27 | } 28 | 29 | /** 30 | * Shows confirmation dialog to the user. 31 | * 32 | * @param msg the message 33 | * @param callback called back when the use accepts (can be null) 34 | */ 35 | public void confirmByUser(String msg, Runnable callback) { 36 | confirmImpl(msg, callback); 37 | } 38 | 39 | /** 40 | * Obtains size of the screen. 41 | * @return array with two numbers: width and height 42 | */ 43 | public int[] getScreenSize() { 44 | Object[] size = screenSizeImpl(); 45 | return new int[] { 46 | ((Number)size[0]).intValue(), 47 | ((Number)size[1]).intValue(), 48 | }; 49 | } 50 | 51 | @JavaScriptBody(args = { "key" }, body = 52 | "if (!window.localStorage) return null;\n" + 53 | "return window.localStorage.getItem(key);\n" 54 | ) 55 | private static native String getPreferencesImpl(String key); 56 | 57 | @JavaScriptBody(args = { "key", "value" }, body = 58 | "if (!window.localStorage) return;\n" + 59 | "window.localStorage.setItem(key, value);\n" 60 | ) 61 | private static native void setPreferencesImpl(String key, String value); 62 | 63 | /** 64 | * Shows confirmation dialog to the user. 65 | * 66 | * @param msg the message 67 | * @param callback called back when the use accepts (can be null) 68 | */ 69 | @JavaScriptBody( 70 | args = {"msg", "callback"}, 71 | javacall = true, 72 | body = "if (confirm(msg)) {\n" 73 | + " callback.@java.lang.Runnable::run()();\n" 74 | + "}\n" 75 | ) 76 | static native void confirmImpl(String msg, Runnable callback); 77 | 78 | @JavaScriptBody( 79 | args = {}, body 80 | = "var w = window,\n" 81 | + " d = document,\n" 82 | + " e = d.documentElement,\n" 83 | + " g = d.getElementsByTagName('body')[0],\n" 84 | + " x = w.innerWidth || e.clientWidth || g.clientWidth,\n" 85 | + " y = w.innerHeight|| e.clientHeight|| g.clientHeight;\n" 86 | + "\n" 87 | + "return [x, y];\n" 88 | ) 89 | static native Object[] screenSizeImpl(); 90 | } 91 | -------------------------------------------------------------------------------- /bck2brwsr/js/src/test/java/com/athaydes/js/JsInteractionTest.java: -------------------------------------------------------------------------------- 1 | package com.athaydes.js; 2 | 3 | import net.java.html.junit.BrowserRunner; 4 | import static org.junit.Assert.assertEquals; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | 8 | /** Tests for behavior of @JavaScriptBody methods. The {@link BrowserRunner} 9 | * selects all possible presenters from your pom.xml and 10 | * runs the tests inside of them. 11 | * 12 | * See your pom.xml dependency section for details. 13 | */ 14 | @RunWith(BrowserRunner.class) 15 | public class JsInteractionTest { 16 | @Test 17 | public void emptyTest() { 18 | } 19 | 20 | @Test 21 | public void testCallbackFromJavaScript() throws Exception { 22 | class R implements Runnable { 23 | int called; 24 | 25 | @Override 26 | public void run() { 27 | called++; 28 | } 29 | } 30 | R callback = new R(); 31 | 32 | final PlatformServices services = new PlatformServices(); 33 | services.confirmByUser("Hello", callback); 34 | 35 | assertEquals("One immediate callback", callback.called, 1); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /bck2brwsr/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.athaydes 7 | bck2brwsr-pom 8 | 1.0-SNAPSHOT 9 | pom 10 | 11 | bck2brwsr 12 | 13 | client 14 | client-web 15 | js 16 | 17 | 18 | 1.5.1 19 | 11 20 | 0.30 21 | MINIMAL 22 | 1.0 23 | 2.13 24 | 1.5.2 25 | false 26 | UTF-8 27 | 28 | 29 | 30 | 31 | com.dukescript.api 32 | junit-osgi 33 | test 34 | 4.12 35 | 36 | 37 | com.dukescript.api 38 | junit-browser-runner 39 | ${junit.browser.version} 40 | test 41 | jar 42 | 43 | 44 | org.netbeans.html 45 | net.java.html 46 | 47 | 48 | org.netbeans.html 49 | net.java.html.boot 50 | 51 | 52 | org.apidesign.bck2brwsr 53 | emul 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | org.apache.maven.plugins 63 | maven-compiler-plugin 64 | 3.8.0 65 | 66 | 1.8 67 | 1.8 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /cheerpj/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | *.jar.js 3 | -------------------------------------------------------------------------------- /cheerpj/Makefile: -------------------------------------------------------------------------------- 1 | all: swing.jar.js 2 | 3 | swing.jar: 4 | cd cheerpjswing && mvn package 5 | cp cheerpjswing/target/cheerpj-swing-1.0-SNAPSHOT.jar swing.jar 6 | 7 | swing.jar.js: swing.jar 8 | ~/cheerpj_1.3/cheerpjfy.py swing.jar 9 | 10 | clean: 11 | cd cheerpjswing && mvn clean 12 | rm -rf swing.jar swing.jar.js -------------------------------------------------------------------------------- /cheerpj/cheerpjswing/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /cheerpj/cheerpjswing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.athaydes 8 | cheerpj-swing 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | maven-compiler-plugin 14 | 3.1 15 | 16 | 1.8 17 | 1.8 18 | true 19 | 20 | 21 | 22 | org.apache.maven.plugins 23 | maven-jar-plugin 24 | 2.4 25 | 26 | 27 | 28 | Main 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /cheerpj/cheerpjswing/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | import javax.swing.*; 2 | import java.awt.*; 3 | import java.util.function.Consumer; 4 | 5 | public class Main implements Runnable { 6 | 7 | @Override 8 | public void run() { 9 | JFrame frame = new JFrame( "CheerpJ Demo" ); 10 | 11 | frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 12 | frame.setSize( 400, 80 ); 13 | frame.add( new Counter() ); 14 | frame.setVisible( true ); 15 | } 16 | 17 | public static void main( String[] args ) { 18 | SwingUtilities.invokeLater( new Main() ); 19 | } 20 | } 21 | 22 | class Counter extends JPanel { 23 | private int value; 24 | 25 | public Counter() { 26 | JButton up = new JButton( "Increment" ); 27 | JButton down = new JButton( "Decrement" ); 28 | JLabel out = new JLabel(); 29 | 30 | Runnable update = () -> out.setText( "The current count is " + value ); 31 | update.run(); 32 | 33 | Consumer handler = ( increment ) -> { 34 | if ( increment ) { 35 | value++; 36 | } else { 37 | value--; 38 | } 39 | update.run(); 40 | }; 41 | 42 | up.addActionListener( event -> handler.accept( true ) ); 43 | down.addActionListener( event -> handler.accept( false ) ); 44 | 45 | JPanel buttonsPanel = new JPanel(); 46 | buttonsPanel.add( up ); 47 | buttonsPanel.add( down ); 48 | 49 | JLabel title = new JLabel( "CheerpJ CounterApp (Swing)" ); 50 | 51 | setLayout( new BorderLayout() ); 52 | add( title, BorderLayout.PAGE_START ); 53 | add( buttonsPanel, BorderLayout.PAGE_END ); 54 | add( out, BorderLayout.CENTER ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /cheerpj/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CheerpJ test 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /dart-counter/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | # Remove the following pattern if you wish to check in your lock file 5 | pubspec.lock 6 | 7 | # Conventional directory for build outputs 8 | build/ 9 | 10 | # Directory created by dartdoc 11 | doc/api/ 12 | -------------------------------------------------------------------------------- /dart-counter/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0 2 | 3 | - Initial version, created by Stagehand 4 | -------------------------------------------------------------------------------- /dart-counter/README.md: -------------------------------------------------------------------------------- 1 | An absolute bare-bones web app. 2 | 3 | Created from templates made available by Stagehand under a BSD-style 4 | [license](https://github.com/dart-lang/stagehand/blob/master/LICENSE). 5 | -------------------------------------------------------------------------------- /dart-counter/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # Defines a default set of lint rules enforced for 2 | # projects at Google. For details and rationale, 3 | # see https://github.com/dart-lang/pedantic#enabled-lints. 4 | include: package:pedantic/analysis_options.yaml 5 | 6 | # For lint rules and documentation, see http://dart-lang.github.io/linter/lints. 7 | # Uncomment to specify additional rules. 8 | # linter: 9 | # rules: 10 | # - camel_case_types 11 | 12 | analyzer: 13 | # exclude: 14 | # - path/to/excluded/files/** 15 | -------------------------------------------------------------------------------- /dart-counter/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: dart_counter 2 | description: An absolute bare-bones web app. 3 | # version: 1.0.0 4 | #homepage: https://www.example.com 5 | #author: renato 6 | 7 | environment: 8 | sdk: '>=2.1.0 <3.0.0' 9 | 10 | #dependencies: 11 | # path: ^1.4.1 12 | 13 | dev_dependencies: 14 | build_runner: ^1.1.2 15 | build_web_compilers: ^1.0.0 16 | pedantic: ^1.0.0 17 | -------------------------------------------------------------------------------- /dart-counter/web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renatoathaydes/jvm-alternatives-to-js/40337a4d0b3a79b3b2f0ad529440fc1f22ab6b0b/dart-counter/web/favicon.ico -------------------------------------------------------------------------------- /dart-counter/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Dart CounterApp 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /dart-counter/web/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:html'; 2 | 3 | void main() { 4 | querySelector('#output').append(Counter().build()); 5 | } 6 | 7 | class Counter { 8 | int value = 0; 9 | 10 | Element build() { 11 | final out = DivElement(); 12 | 13 | update() => out.text = "The current count is $value"; 14 | update(); 15 | handler(bool increment) { 16 | if (increment) 17 | value++; 18 | else 19 | value--; 20 | update(); 21 | } 22 | 23 | final up = ButtonElement() 24 | ..text = 'Increment' 25 | ..onClick.listen((e) => handler(true)); 26 | final down = ButtonElement() 27 | ..text = 'Decrement' 28 | ..onClick.listen((e) => handler(false)); 29 | 30 | return DivElement()..append(out)..append(up)..append(down); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /dart-counter/web/styles.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Roboto); 2 | 3 | html, body { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | font-family: 'Roboto', sans-serif; 9 | } 10 | 11 | #output { 12 | padding: 20px; 13 | text-align: center; 14 | } 15 | -------------------------------------------------------------------------------- /gwt-app/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /gwt-app/.gitignore: -------------------------------------------------------------------------------- 1 | gwt-unitCache/ 2 | war/gwtapp/ 3 | war/WEB-INF/lib/ 4 | war/WEB-INF/deploy/ 5 | 6 | -------------------------------------------------------------------------------- /gwt-app/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GwtApp 4 | GwtApp project 5 | 6 | 7 | 8 | org.eclipse.jdt.core.javabuilder 9 | 10 | 11 | 12 | 13 | com.google.gdt.eclipse.core.webAppProjectValidator 14 | 15 | 16 | 17 | 18 | com.google.gwt.eclipse.core.gwtProjectValidator 19 | 20 | 21 | 22 | 23 | 24 | org.eclipse.jdt.core.javanature 25 | com.google.gwt.eclipse.core.gwtNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /gwt-app/GwtApp.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /gwt-app/README.txt: -------------------------------------------------------------------------------- 1 | --- Generated by GWT WebAppCreator --- 2 | 3 | Congratulations, you've successfully generated a starter project! What next? 4 | 5 | -- Option A: Import your project into Eclipse (recommended) -- 6 | 7 | If you use Eclipse, you can simply import the generated project into Eclipse. 8 | We've tested against Eclipse 3.4 and 3.5. Later versions will likely also 9 | work, earlier versions may not. 10 | 11 | If the directory containing this file does not have a .classpath or .project 12 | file, generate them by running 'ant eclipse.generate' 13 | 14 | In Eclipse, go to the File menu and choose: 15 | 16 | File -> Import... -> Existing Projects into Workspace 17 | 18 | Browse to the directory containing this file, 19 | select "GwtApp". 20 | 21 | Be sure to uncheck "Copy projects into workspace" if it is checked. 22 | 23 | Click Finish. 24 | 25 | You can now browse the project in Eclipse. 26 | 27 | To launch your web app in GWT development mode, go to the Run menu and choose: 28 | 29 | Run -> Open Debug Dialog... 30 | 31 | Under Java Application, you should find a launch configuration 32 | named "GwtApp". Select and click "Debug". 33 | 34 | You can now use the built-in debugger to debug your web app in development mode. 35 | 36 | If you supplied the junit path when invoking webAppCreator, you should see 37 | launch configurations for running your tests in development and production 38 | mode. 39 | 40 | -- Option B: Build from the command line with Ant -- 41 | 42 | If you prefer to work from the command line, you can use Ant to build your 43 | project. (http://ant.apache.org/) Ant uses the generated 'build.xml' file 44 | which describes exactly how to build your project. This file has been tested 45 | to work against Ant 1.7.1. The following assumes 'ant' is on your command 46 | line path. 47 | 48 | To run development mode, just type 'ant devmode'. 49 | 50 | To compile your project for deployment, just type 'ant'. 51 | 52 | To compile and also bundle into a .war file, type 'ant war'. 53 | 54 | If you supplied the junit path when invoking webAppCreator, you can type 'ant 55 | test' to run tests in development and production mode. 56 | 57 | For a full listing of other targets, type 'ant -p'. 58 | 59 | -- Option C: Using another IDE -- 60 | 61 | GWT projects can be run in other IDEs as well, but will require some manual 62 | setup. If you go this route, be sure to: 63 | 64 | * Have your IDE build .class files into 'war/WEB-INF/classes'. 65 | * Add gwt-user.jar and gwt-dev.jar to your project build path. 66 | * When creating a launch configuration, add a classpath entry for your 'src' 67 | folder (this is somewhat unusual but GWT needs access to your source files). 68 | 69 | If you get stuck, try to mimic what the Ant 'build.xml' would do. 70 | 71 | -- Option D: Using Maven -- 72 | 73 | If you have generated your project with the option '-maven', you have a 'pom.xml' 74 | file ready to use. Assuming you have Maven installed in your system, 'mvn' is 75 | in your path, and you have access to maven repositories, you should be able to run: 76 | 77 | mvn clean # delete temporary stuff 78 | mvn test # run all the tests (gwt and junit) 79 | mvn gwt:devmode # run development mode (needs "mvn package" to be run before) 80 | mvn package # generate a .war package ready to deploy 81 | 82 | For more information about other available goals, read Maven and gwt-maven-plugin 83 | documentation (http://maven.apache.org, https://tbroyer.github.io/gwt-maven-plugin/) 84 | -------------------------------------------------------------------------------- /gwt-app/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /gwt-app/src/com/athaydes/GwtApp.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /gwt-app/src/com/athaydes/client/GwtApp.java: -------------------------------------------------------------------------------- 1 | package com.athaydes.client; 2 | 3 | import com.google.gwt.core.client.EntryPoint; 4 | import com.google.gwt.user.client.ui.*; 5 | 6 | import java.util.function.Consumer; 7 | 8 | public class GwtApp implements EntryPoint { 9 | public void onModuleLoad() { 10 | RootPanel.get( "content" ).add( new Counter() ); 11 | } 12 | } 13 | 14 | class Counter extends Composite { 15 | 16 | private int value; 17 | 18 | Counter() { 19 | HorizontalPanel buttonsPanel = new HorizontalPanel(); 20 | buttonsPanel.setSpacing( 10 ); 21 | 22 | Button up = new Button( "Increment" ); 23 | Button down = new Button( "Decrement" ); 24 | Label out = new Label(); 25 | 26 | Runnable update = () -> out.setText( "The current count is " + value ); 27 | update.run(); 28 | 29 | Consumer handler = ( increment ) -> { 30 | if ( increment ) { 31 | value++; 32 | } else { 33 | value--; 34 | } 35 | update.run(); 36 | }; 37 | 38 | up.addClickHandler( clickEvent -> handler.accept( true ) ); 39 | down.addClickHandler( clickEvent -> handler.accept( false ) ); 40 | 41 | buttonsPanel.add( up ); 42 | buttonsPanel.add( down ); 43 | 44 | VerticalPanel root = new VerticalPanel(); 45 | root.setSpacing( 20 ); 46 | 47 | root.add( out ); 48 | root.add( buttonsPanel ); 49 | 50 | initWidget( root ); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /gwt-app/war/GwtApp.css: -------------------------------------------------------------------------------- 1 | /** Add css rules here for your application. */ 2 | 3 | 4 | /** Example rules used by the template application (remove for your app) */ 5 | h1 { 6 | font-size: 2em; 7 | font-weight: bold; 8 | color: #777777; 9 | margin: 40px 0px 70px; 10 | text-align: center; 11 | } 12 | 13 | .sendButton { 14 | display: block; 15 | font-size: 16pt; 16 | } 17 | 18 | /** Most GWT widgets already have a style name defined */ 19 | .gwt-DialogBox { 20 | width: 400px; 21 | } 22 | 23 | .dialogVPanel { 24 | margin: 5px; 25 | } 26 | 27 | .serverResponseLabelError { 28 | color: red; 29 | } 30 | 31 | /** Set ids using widget.getElement().setId("idOfElement") */ 32 | #closeButton { 33 | margin: 15px 6px 6px; 34 | } 35 | -------------------------------------------------------------------------------- /gwt-app/war/GwtApp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Web Application Starter Project 7 | 8 | 9 | 10 | 16 |

GWT CounterApp

17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /gwt-app/war/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | GwtApp.html 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /gwt-app/war/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renatoathaydes/jvm-alternatives-to-js/40337a4d0b3a79b3b2f0ad529440fc1f22ab6b0b/gwt-app/war/favicon.ico -------------------------------------------------------------------------------- /jsweet/..gitignore.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renatoathaydes/jvm-alternatives-to-js/40337a4d0b3a79b3b2f0ad529440fc1f22ab6b0b/jsweet/..gitignore.swp -------------------------------------------------------------------------------- /jsweet/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | target/ 3 | .generated 4 | .ts 5 | .jsweet 6 | .project 7 | .settings 8 | .classpath 9 | -------------------------------------------------------------------------------- /jsweet/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /jsweet/README.md: -------------------------------------------------------------------------------- 1 | # JSweet quick start 2 | 3 | A simple project to get started with JSweet. This project just contains a main method that shows 'Hello world' messages in two different ways. The program uses the [J4TS](https://github.com/cincheo/j4ts) candy to access `java.util` API, and the jQuery candy. Programmers can use it to set up a new JSweet project and try out some basic features. 4 | 5 | ## Usage 6 | 7 | ``` 8 | > git clone https://github.com/cincheo/jsweet-quickstart.git 9 | > cd jsweet-quickstart 10 | > mvn generate-sources 11 | > firefox webapp/index.html 12 | ``` 13 | 14 | You can also watch your JSweet (.java) source files for modifications using 15 | ``` 16 | mvn clean jsweet:watch 17 | ``` 18 | It will transpile automatically when you save a source file. 19 | Be sure that there are not transpilation error in your console, though. 20 | 21 | ## Modify 22 | 23 | At any time, you can modify the Java files (or add new files) and run ``mvn generate-sources`` to generate the corresponding JavaScript files. You can then use them in the ``index.html`` file (`` 17 | 18 | 19 | -------------------------------------------------------------------------------- /jsweet/webapp/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renatoathaydes/jvm-alternatives-to-js/40337a4d0b3a79b3b2f0ad529440fc1f22ab6b0b/jsweet/webapp/logo.png -------------------------------------------------------------------------------- /react/counter.js: -------------------------------------------------------------------------------- 1 | class Counter extends React.Component { 2 | constructor(props) { 3 | super(props); 4 | 5 | this.state = { 6 | count: props.count || 0 7 | }; 8 | 9 | this.updateCount = this.updateCount.bind(this); 10 | } 11 | 12 | updateCount(increment) { 13 | const { count } = this.state; 14 | 15 | if (increment) { 16 | this.setState({ 17 | count: count + 1 18 | }); 19 | } else { 20 | this.setState({ 21 | count: count - 1 22 | }); 23 | } 24 | } 25 | 26 | render() { 27 | const { count } = this.state; 28 | 29 | return React.createElement( 30 | "div", 31 | null, 32 | React.createElement("p", null, "The current count is ", count), 33 | React.createElement( 34 | "button", 35 | { 36 | type: "button", 37 | onClick: () => { 38 | return this.updateCount(true); 39 | } 40 | }, 41 | "Increment" 42 | ), 43 | React.createElement( 44 | "button", 45 | { 46 | type: "button", 47 | onClick: () => { 48 | return this.updateCount(false); 49 | } 50 | }, 51 | "Decrement" 52 | ) 53 | ); 54 | } 55 | } 56 | 57 | export default Counter; -------------------------------------------------------------------------------- /react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 15 | You Might Not Need A Build Toolchain 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /react/index.js: -------------------------------------------------------------------------------- 1 | import Counter from "./counter.js"; 2 | 3 | ReactDOM.render( 4 | React.createElement(Counter, null), 5 | document.getElementById("root") 6 | ); -------------------------------------------------------------------------------- /react/react.production.min.js: -------------------------------------------------------------------------------- 1 | /** @license React v16.8.6 2 | * react.production.min.js 3 | * 4 | * Copyright (c) Facebook, Inc. and its affiliates. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | */ 9 | 'use strict';(function(N,q){"object"===typeof exports&&"undefined"!==typeof module?module.exports=q():"function"===typeof define&&define.amd?define(q):N.React=q()})(this,function(){function N(a,b,d,g,p,c,e,h){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var n=[d,g,p,c,e,h],f=0;a=Error(b.replace(/%s/g,function(){return n[f++]}));a.name="Invariant Violation"}a.framesToPop=1; 10 | throw a;}}function q(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,g=0;g=b){d=a;break}a=a.next}while(a!==c);null===d?d=c:d=== 12 | c&&(c=n,u());b=d.previous;b.next=d.previous=n;n.next=d;n.previous=b}}function F(){if(-1===k&&null!==c&&1===c.priorityLevel){x=!0;try{do Q();while(null!==c&&1===c.priorityLevel)}finally{x=!1,null!==c?u():C=!1}}}function ta(a){x=!0;var b=G;G=a;try{if(a)for(;null!==c;){var d=l();if(c.expirationTime<=d){do Q();while(null!==c&&c.expirationTime<=d)}else break}else if(null!==c){do Q();while(null!==c&&!H())}}finally{x=!1,G=b,null!==c?u():C=!1,F()}}function ea(a,b,d){var g=void 0,p={},c=null,e=null;if(null!= 13 | b)for(g in void 0!==b.ref&&(e=b.ref),void 0!==b.key&&(c=""+b.key),b)fa.call(b,g)&&!ha.hasOwnProperty(g)&&(p[g]=b[g]);var h=arguments.length-2;if(1===h)p.children=d;else if(1I.length&&I.push(a)}function T(a,b,d,g){var c=typeof a;if("undefined"===c||"boolean"===c)a=null;var e=!1;if(null=== 15 | a)e=!0;else switch(c){case "string":case "number":e=!0;break;case "object":switch(a.$$typeof){case y:case wa:e=!0}}if(e)return d(g,a,""===b?"."+U(a,0):b),1;e=0;b=""===b?".":b+":";if(Array.isArray(a))for(var f=0;fa;a++)b["_"+String.fromCharCode(a)]=a;if("0123456789"!==Object.getOwnPropertyNames(b).map(function(a){return b[a]}).join(""))return!1;var d={};"abcdefghijklmnopqrst".split("").forEach(function(a){d[a]=a});return"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},d)).join("")?!1:!0}catch(g){return!1}}()?Object.assign:function(a,b){if(null===a||void 0===a)throw new TypeError("Object.assign cannot be called with null or undefined");var d=Object(a);for(var c,e=1;e=L-d)if(-1!==b&&b<=d)c=!0;else{A||(A=!0,Y(aa));w=a;z=b;return}if(null!==a){Z=!0;try{a(c)}finally{Z=!1}}};var aa=function(a){if(null!==w){Y(aa);var b=a-L+B;bb&&(b=8),B=bb?sa.postMessage(void 0):A||(A=!0,Y(aa))};P=function(){w=null;K=!1;z=-1}}var Oa= 25 | 0,ma={current:null},R={current:null};e={ReactCurrentDispatcher:ma,ReactCurrentOwner:R,assign:J};J(e,{Scheduler:{unstable_cancelCallback:function(a){var b=a.next;if(null!==b){if(b===a)c=null;else{a===c&&(c=b);var d=a.previous;d.next=b;b.previous=d}a.next=a.previous=null}},unstable_shouldYield:function(){return!G&&(null!==c&&c.expirationTimeb){d=g;break}g=g.next}while(g!==c);null===d?d=c:d===c&&(c=a,u());b=d.previous;b.next=d.previous=a;a.next=d;a.previous=b}return a},unstable_runWithPriority:function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a= 27 | 3}var d=f,c=k;f=a;k=l();try{return b()}finally{f=d,k=c,F()}},unstable_next:function(a){switch(f){case 1:case 2:case 3:var b=3;break;default:b=f}var d=f,c=k;f=b;k=l();try{return a()}finally{f=d,k=c,F()}},unstable_wrapCallback:function(a){var b=f;return function(){var d=f,c=k;f=b;k=l();try{return a.apply(this,arguments)}finally{f=d,k=c,F()}}},unstable_getFirstCallbackNode:function(){return c},unstable_pauseExecution:function(){},unstable_continueExecution:function(){null!==c&&u()},unstable_getCurrentPriorityLevel:function(){return f}, 28 | unstable_IdlePriority:5,unstable_ImmediatePriority:1,unstable_LowPriority:4,unstable_NormalPriority:3,unstable_UserBlockingPriority:2},SchedulerTracing:{__interactionsRef:null,__subscriberRef:null,unstable_clear:function(a){return a()},unstable_getCurrent:function(){return null},unstable_getThreadID:function(){return++Oa},unstable_subscribe:function(a){},unstable_trace:function(a,b,d){return d()},unstable_unsubscribe:function(a){},unstable_wrap:function(a){return a}}});var fa=Object.prototype.hasOwnProperty, 29 | ha={key:!0,ref:!0,__self:!0,__source:!0},la=/\/+/g,I=[];r={Children:{map:function(a,b,d){if(null==a)return a;var c=[];W(a,c,null,b,d);return c},forEach:function(a,b,d){if(null==a)return a;b=ia(null,null,b,d);V(a,xa,b);ja(b)},count:function(a){return V(a,function(){return null},null)},toArray:function(a){var b=[];W(a,b,null,function(a){return a});return b},only:function(a){S(a)?void 0:q("143");return a}},createRef:function(){return{current:null}},Component:t,PureComponent:O,createContext:function(a, 30 | b){void 0===b&&(b=null);a={$$typeof:Ba,_calculateChangedBits:b,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:Aa,_context:a};return a.Consumer=a},forwardRef:function(a){return{$$typeof:Da,render:a}},lazy:function(a){return{$$typeof:Ga,_ctor:a,_status:-1,_result:null}},memo:function(a,b){return{$$typeof:Fa,type:a,compare:void 0===b?null:b}},useCallback:function(a,b){return m().useCallback(a,b)},useContext:function(a,b){return m().useContext(a,b)}, 31 | useEffect:function(a,b){return m().useEffect(a,b)},useImperativeHandle:function(a,b,d){return m().useImperativeHandle(a,b,d)},useDebugValue:function(a,b){},useLayoutEffect:function(a,b){return m().useLayoutEffect(a,b)},useMemo:function(a,b){return m().useMemo(a,b)},useReducer:function(a,b,d){return m().useReducer(a,b,d)},useRef:function(a){return m().useRef(a)},useState:function(a){return m().useState(a)},Fragment:r,StrictMode:X,Suspense:Ea,createElement:ea,cloneElement:function(a,b,d){null===a|| 32 | void 0===a?q("267",a):void 0;var c=void 0,e=J({},a.props),f=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=R.current);void 0!==b.key&&(f=""+b.key);var l=void 0;a.type&&a.type.defaultProps&&(l=a.type.defaultProps);for(c in b)fa.call(b,c)&&!ha.hasOwnProperty(c)&&(e[c]=void 0===b[c]&&void 0!==l?l[c]:b[c])}c=arguments.length-2;if(1===c)e.children=d;else if(1 3 | 4.0.0 4 | 5 | com.athaydes 6 | mytea 7 | 1.0-SNAPSHOT 8 | war 9 | 10 | 11 | 1.8 12 | 0.6.0-dev-723 13 | UTF-8 14 | 15 | 16 | 17 | 18 | teavm-dev 19 | https://dl.bintray.com/konsoletyper/teavm 20 | 21 | 22 | 23 | 24 | 25 | teavm-dev 26 | https://dl.bintray.com/konsoletyper/teavm 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.teavm 34 | teavm-classlib 35 | ${teavm.version} 36 | provided 37 | 38 | 39 | 40 | 41 | org.teavm 42 | teavm-jso-apis 43 | ${teavm.version} 44 | provided 45 | 46 | 47 | 48 | 49 | javax.servlet 50 | javax.servlet-api 51 | 3.1.0 52 | provided 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | maven-compiler-plugin 61 | 3.1 62 | 63 | ${java.version} 64 | ${java.version} 65 | 66 | 67 | 68 | 69 | 70 | maven-war-plugin 71 | 2.4 72 | 73 | 74 | 75 | ${project.build.directory}/generated/js 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | org.teavm 84 | teavm-maven-plugin 85 | ${teavm.version} 86 | 87 | 88 | web-client 89 | 90 | compile 91 | 92 | 93 | 95 | ${project.build.directory}/generated/js/teavm 96 | 97 | 98 | com.athaydes.Client 99 | 100 | 102 | true 103 | 104 | 105 | true 106 | 107 | 108 | true 109 | 110 | 112 | true 113 | 114 | 115 | ADVANCED 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /teavm-latest/src/main/java/com/athaydes/Client.java: -------------------------------------------------------------------------------- 1 | package com.athaydes; 2 | 3 | import org.teavm.jso.dom.html.HTMLButtonElement; 4 | import org.teavm.jso.dom.html.HTMLDocument; 5 | import org.teavm.jso.dom.html.HTMLElement; 6 | 7 | import java.util.function.Consumer; 8 | 9 | public class Client { 10 | public static void main( String[] args ) { 11 | HTMLDocument document = HTMLDocument.current(); 12 | HTMLElement div = document.createElement( "h2" ); 13 | div.appendChild( document.createTextNode( "TeaVM CounterApp" ) ); 14 | document.getBody().appendChild( div ); 15 | div.appendChild( new Counter().build() ); 16 | } 17 | } 18 | 19 | class Counter { 20 | private int value = 0; 21 | 22 | HTMLElement build() { 23 | HTMLDocument document = HTMLDocument.current(); 24 | HTMLButtonElement up = ( HTMLButtonElement ) document.createElement( "button" ); 25 | up.appendChild( document.createTextNode( "Increment" ) ); 26 | HTMLButtonElement down = ( HTMLButtonElement ) document.createElement( "button" ); 27 | down.appendChild( document.createTextNode( "Decrement" ) ); 28 | HTMLElement out = document.createElement( "p" ); 29 | 30 | Runnable update = () -> out.setInnerHTML( "The current count is " + value ); 31 | 32 | Consumer handler = ( increment ) -> { 33 | if ( increment ) { 34 | value++; 35 | } else { 36 | value--; 37 | } 38 | update.run(); 39 | }; 40 | 41 | up.listenClick( ( event ) -> handler.accept( true ) ); 42 | down.listenClick( ( event ) -> handler.accept( false ) ); 43 | 44 | update.run(); 45 | 46 | HTMLElement div = document.createElement( "div" ); 47 | div.appendChild( out ); 48 | div.appendChild( up ); 49 | div.appendChild( down ); 50 | 51 | return div; 52 | } 53 | } -------------------------------------------------------------------------------- /teavm-latest/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /teavm-latest/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Main page 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /teavm/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /teavm/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.athaydes 6 | mytea 7 | 1.0-SNAPSHOT 8 | war 9 | 10 | 11 | 1.8 12 | 0.5.1 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | org.teavm 20 | teavm-classlib 21 | ${teavm.version} 22 | provided 23 | 24 | 25 | 26 | 27 | org.teavm 28 | teavm-jso-apis 29 | ${teavm.version} 30 | provided 31 | 32 | 33 | 34 | 35 | javax.servlet 36 | javax.servlet-api 37 | 3.1.0 38 | provided 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | maven-compiler-plugin 47 | 3.1 48 | 49 | ${java.version} 50 | ${java.version} 51 | 52 | 53 | 54 | 55 | 56 | maven-war-plugin 57 | 2.4 58 | 59 | 60 | 61 | ${project.build.directory}/generated/js 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | org.teavm 70 | teavm-maven-plugin 71 | ${teavm.version} 72 | 73 | 74 | web-client 75 | 76 | compile 77 | 78 | 79 | 81 | ${project.build.directory}/generated/js/teavm 82 | 83 | 84 | com.athaydes.Client 85 | 86 | 88 | true 89 | 90 | 91 | true 92 | 93 | 94 | true 95 | 96 | 98 | true 99 | 100 | 101 | ADVANCED 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /teavm/src/main/java/com/athaydes/Client.java: -------------------------------------------------------------------------------- 1 | package com.athaydes; 2 | 3 | import org.teavm.jso.dom.html.HTMLButtonElement; 4 | import org.teavm.jso.dom.html.HTMLDocument; 5 | import org.teavm.jso.dom.html.HTMLElement; 6 | 7 | import java.util.function.Consumer; 8 | 9 | public class Client { 10 | public static void main( String[] args ) { 11 | HTMLDocument document = HTMLDocument.current(); 12 | HTMLElement div = document.createElement( "h2" ); 13 | div.appendChild( document.createTextNode( "TeaVM CounterApp" ) ); 14 | document.getBody().appendChild( div ); 15 | div.appendChild( new Counter().build() ); 16 | } 17 | } 18 | 19 | class Counter { 20 | private int value = 0; 21 | 22 | HTMLElement build() { 23 | HTMLDocument document = HTMLDocument.current(); 24 | HTMLButtonElement up = ( HTMLButtonElement ) document.createElement( "button" ); 25 | up.appendChild( document.createTextNode( "Increment" ) ); 26 | HTMLButtonElement down = ( HTMLButtonElement ) document.createElement( "button" ); 27 | down.appendChild( document.createTextNode( "Decrement" ) ); 28 | HTMLElement out = document.createElement( "p" ); 29 | 30 | Runnable update = () -> out.setInnerHTML( "The current count is " + value ); 31 | 32 | Consumer handler = ( increment ) -> { 33 | if ( increment ) { 34 | value++; 35 | } else { 36 | value--; 37 | } 38 | update.run(); 39 | }; 40 | 41 | up.listenClick( ( event ) -> handler.accept( true ) ); 42 | down.listenClick( ( event ) -> handler.accept( false ) ); 43 | 44 | update.run(); 45 | 46 | HTMLElement div = document.createElement( "div" ); 47 | div.appendChild( out ); 48 | div.appendChild( up ); 49 | div.appendChild( down ); 50 | 51 | return div; 52 | } 53 | } -------------------------------------------------------------------------------- /teavm/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /teavm/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Main page 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /vaadin/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /vaadin/LICENSE.md: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /vaadin/README.md: -------------------------------------------------------------------------------- 1 | [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/vaadin-flow/Lobby#?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 2 | 3 | # Skeleton Starter for Vaadin Flow 4 | 5 | This project can be used as a starting point to create your own Vaadin Flow application. 6 | It has the necessary dependencies and files to help you get started. 7 | 8 | The best way to use it by via [vaadin.com/start](https://vaadin.com/start) - you can get only the necessary parts and choose the package naming you want to use. 9 | There is also a [getting started tutorial](https://vaadin.com/docs/v10/flow/introduction/tutorial-get-started.html) based on this project. 10 | 11 | To access it directly from github, clone the repository and import the project to the IDE of your choice as a Maven project. You need to have Java 8 installed. 12 | 13 | Run using `mvn jetty:run` and open [http://localhost:8080](http://localhost:8080) in browser. 14 | 15 | For a full Vaadin Flow application example, there is the Beverage Buddy App Starter for Flow available also from [vaadin.com/start](https://vaadin.com/start) page. 16 | 17 | Branching information: 18 | * `master` the latest version of the starter, using latest platform snapshot 19 | * `v10` the version for Vaadin 10 20 | * `v11` the version for Vaadin 11 21 | * `v12` the version for Vaadin 12 22 | * `v13` the version for Vaadin 13 23 | -------------------------------------------------------------------------------- /vaadin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | com.example.test 4 | vaadin-counter 5 | My Starter Project 6 | 1.0-SNAPSHOT 7 | war 8 | 9 | 10 | 1.8 11 | 1.8 12 | UTF-8 13 | false 14 | 15 | 13.0.3 16 | 17 | 18 | 19 | 20 | 21 | central 22 | https://repo1.maven.org/maven2/ 23 | false 24 | 25 | 26 | 27 | 28 | Vaadin Directory 29 | http://maven.vaadin.com/vaadin-addons 30 | 31 | 32 | 33 | vaadin-prereleases 34 | https://maven.vaadin.com/vaadin-prereleases 35 | 36 | 37 | 38 | 39 | 40 | 41 | central 42 | https://repo1.maven.org/maven2/ 43 | false 44 | 45 | 46 | 47 | vaadin-prereleases 48 | https://maven.vaadin.com/vaadin-prereleases 49 | false 50 | 51 | 52 | 53 | 54 | 55 | 56 | com.vaadin 57 | vaadin-bom 58 | pom 59 | import 60 | ${vaadin.version} 61 | 62 | 63 | 64 | 65 | 66 | 67 | com.vaadin 68 | vaadin-core 69 | 70 | 71 | 72 | 73 | 74 | org.slf4j 75 | slf4j-simple 76 | 77 | 78 | 79 | javax.servlet 80 | javax.servlet-api 81 | 3.1.0 82 | provided 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | org.eclipse.jetty 91 | jetty-maven-plugin 92 | 9.4.11.v20180605 93 | 94 | 1 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | production-mode 104 | 105 | 106 | vaadin.productionMode 107 | 108 | 109 | 110 | true 111 | 112 | 113 | 114 | 115 | com.vaadin 116 | flow-server-production-mode 117 | 118 | 119 | 120 | 121 | 122 | 123 | com.vaadin 124 | vaadin-maven-plugin 125 | ${vaadin.version} 126 | 127 | 128 | 129 | copy-production-files 130 | package-for-production 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /vaadin/src/main/java/com/example/test/MainView.java: -------------------------------------------------------------------------------- 1 | package com.example.test; 2 | 3 | import com.vaadin.flow.component.Composite; 4 | import com.vaadin.flow.component.button.Button; 5 | import com.vaadin.flow.component.html.Div; 6 | import com.vaadin.flow.component.html.H2; 7 | import com.vaadin.flow.component.html.Paragraph; 8 | import com.vaadin.flow.component.orderedlayout.VerticalLayout; 9 | import com.vaadin.flow.router.Route; 10 | 11 | import java.util.function.Consumer; 12 | 13 | @Route( "" ) 14 | public class MainView extends VerticalLayout { 15 | 16 | public MainView() { 17 | H2 header = new H2( "Vaadin Flow CounterApp" ); 18 | add( header, new Counter() ); 19 | } 20 | } 21 | 22 | class Counter extends Composite
{ 23 | private int value; 24 | 25 | Counter() { 26 | Paragraph out = new Paragraph(); 27 | Runnable update = () -> out.setText( "The current count is " + value ); 28 | update.run(); 29 | 30 | Consumer handler = ( increment ) -> { 31 | if ( increment ) { 32 | value++; 33 | } else { 34 | value--; 35 | } 36 | update.run(); 37 | }; 38 | 39 | Button up = new Button( "Increment", event -> handler.accept( true ) ); 40 | Button down = new Button( "Decrement", event -> handler.accept( false ) ); 41 | 42 | getContent().add( out, up, down ); 43 | } 44 | } -------------------------------------------------------------------------------- /vaadin/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | __ __ ____ _ _ ____ _ _ 2 | | \/ | _ _ / ___| | |_ __ _ _ __ | |_ ___ _ __ | _ \ _ __ ___ (_) ___ ___ | |_ 3 | | |\/| || | | | \___ \ | __| / _` || '__|| __| / _ \| '__| | |_) || '__| / _ \ | | / _ \ / __|| __| 4 | | | | || |_| | ___) || |_ | (_| || | | |_ | __/| | | __/ | | | (_) | | || __/| (__ | |_ 5 | |_| |_| \__, | |____/ \__| \__,_||_| \__| \___||_| |_| |_| \___/ _/ | \___| \___| \__| 6 | |___/ |__/ 7 | -------------------------------------------------------------------------------- /vaadin/src/main/webapp/frontend/src/README: -------------------------------------------------------------------------------- 1 | Place your Vaadin Designer or hand written templates in this folder. 2 | -------------------------------------------------------------------------------- /vaadin/src/main/webapp/frontend/styles/README: -------------------------------------------------------------------------------- 1 | Place your optional styles in this folder. 2 | 3 | See https://vaadin.com/docs/v10/flow/theme/theming-overview.html for getting started on theming Vaadin Flow applications. 4 | -------------------------------------------------------------------------------- /vaadin/src/main/webapp/icons/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renatoathaydes/jvm-alternatives-to-js/40337a4d0b3a79b3b2f0ad529440fc1f22ab6b0b/vaadin/src/main/webapp/icons/icon.png --------------------------------------------------------------------------------