# HG changeset patch # User Jaroslav Tulach # Date 1376565474 -7200 # Node ID 009537e6ce80ec79b81f33c211423aa9bc80d7af # Parent 3f85884ca049d890c941b123f5f3f80f7cd160ce Simpler animation demo that works on JDK7 diff -r 3f85884ca049 -r 009537e6ce80 pom.xml --- a/pom.xml Tue Aug 13 21:19:31 2013 +0200 +++ b/pom.xml Thu Aug 15 13:17:54 2013 +0200 @@ -20,6 +20,7 @@ twitter chat spinningcube + words diff -r 3f85884ca049 -r 009537e6ce80 words/nbactions-iOS.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/nbactions-iOS.xml Thu Aug 15 13:17:54 2013 +0200 @@ -0,0 +1,51 @@ + + + + + run + + package + org.netbeans.ios:ios-maven-plugin:0.2:deploy + + + true + + + + debug + + package + org.netbeans.ios:ios-maven-plugin:0.2:deploy + + + true + true + ${jpda.address} + Debug + + + \ No newline at end of file diff -r 3f85884ca049 -r 009537e6ce80 words/nbactions.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/nbactions.xml Thu Aug 15 13:17:54 2013 +0200 @@ -0,0 +1,45 @@ + + + + + run + + process-classes + exec:java + + + + debug + + process-classes + exec:java + + + maven + + + diff -r 3f85884ca049 -r 009537e6ce80 words/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/pom.xml Thu Aug 15 13:17:54 2013 +0200 @@ -0,0 +1,148 @@ + + + 4.0.0 + + demo + org.apidesign.html + 1.0-SNAPSHOT + + + org.apidesign.demo + words + 1.0-SNAPSHOT + jar + + Words + + + + ios + NetBeans iOS Maven Plugin + http://beetle.cz.oracle.com/~jtulach/maven/ + + + + + + + UTF-8 + 0.4 + org.apidesign.demo.words.Main + none + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + ${project.mainclass} + true + lib/ + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + browser.rootdir + ${basedir}/src/main/webapp/ + + + ${project.mainclass} + + + + maven-assembly-plugin + 2.4 + + + distro-assembly + package + + single + + + + src/main/assembly/html.java.net.xml + + + + + + + + + + org.apidesign.html + net.java.html.json + ${net.java.html.version} + + + org.apidesign.html + net.java.html.boot + ${net.java.html.version} + + + org.apidesign.html + ko-fx + ${net.java.html.version} + runtime + + + org.apidesign.html + boot-fx + ${net.java.html.version} + runtime + + + org.testng + testng + 6.7 + test + + + + + iOS + + + mac + Mac OS X + + + + + + org.netbeans.ios + ios-maven-plugin + 0.2 + + ${project.build.directory}/${project.build.finalName}.jar + ${project.name} + ${project.mainclass} + src/main/webapp/ + + + + + + + diff -r 3f85884ca049 -r 009537e6ce80 words/src/main/assembly/html.java.net.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/main/assembly/html.java.net.xml Thu Aug 15 13:17:54 2013 +0200 @@ -0,0 +1,57 @@ + + + + + html.java.net + + zip + + ${project.build.finalName}-app + + + false + runtime + lib + + + + + ${project.build.directory}/${project.build.finalName}.jar + / + + + + + src/main/webapp/ + / + + pages/** + + + + \ No newline at end of file diff -r 3f85884ca049 -r 009537e6ce80 words/src/main/java/org/apidesign/demo/words/DataModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/main/java/org/apidesign/demo/words/DataModel.java Thu Aug 15 13:17:54 2013 +0200 @@ -0,0 +1,55 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.words; + +import net.java.html.json.ComputedProperty; +import net.java.html.json.Function; +import net.java.html.json.Model; +import net.java.html.json.Property; + +/** Model with one message and cube with six sides. + * + * @author Jaroslav Tulach + */ +@Model(className = "Data", properties = { + @Property(name = "message", type = String.class), + @Property(name = "on", type = boolean.class) +}) +final class DataModel { + @ComputedProperty static String[] sides(String message) { + String[] arr = new String[6]; + String[] words = message == null ? new String[0] : message.split(" ", 6); + for (int i = 0; i < 6; i++) { + arr[i] = words.length > i ? words[i] : "!"; + } + return arr; + } + + @Function static void turnOn(Data model) { + model.setOn(true); + } + @Function static void turnOff(Data model) { + model.setOn(false); + } +} diff -r 3f85884ca049 -r 009537e6ce80 words/src/main/java/org/apidesign/demo/words/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/main/java/org/apidesign/demo/words/Main.java Thu Aug 15 13:17:54 2013 +0200 @@ -0,0 +1,53 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.words; + +import net.java.html.boot.BrowserBuilder; + + +/** Bootstrap and initialization. + * + * @author Jaroslav Tulach + */ +public final class Main { + private Main() { + } + + /** Launches the browser */ + public static void main(String... args) throws Exception { + BrowserBuilder.newBrowser(). + loadPage("pages/index.html"). + loadClass(Main.class). + invoke("onPageLoad", args). + showAndWait(); + System.exit(0); + } + + /** Called when page is ready */ + public static void onPageLoad(String... args) throws Exception { + Data d = new Data(); + d.setMessage("Hello World from HTML and Java!"); + d.applyBindings(); + } +} diff -r 3f85884ca049 -r 009537e6ce80 words/src/main/webapp/pages/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/main/webapp/pages/index.html Thu Aug 15 13:17:54 2013 +0200 @@ -0,0 +1,83 @@ + + + + + + + + + + + +

Words Demo

+ +
+ + + +
+ + + +
+ + diff -r 3f85884ca049 -r 009537e6ce80 words/src/test/java/org/apidesign/demo/words/DataModelTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/test/java/org/apidesign/demo/words/DataModelTest.java Thu Aug 15 13:17:54 2013 +0200 @@ -0,0 +1,39 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.words; + +import static org.testng.Assert.*; +import org.testng.annotations.Test; + +public class DataModelTest { + @Test public void areHelloWorldTwoWords() { + Data model = new Data(); + model.setMessage("Hello World!"); + + String[] arr = model.getSides(); + assertEquals(arr.length, 6, "Cube has six sides"); + assertEquals("Hello", arr[0], "Hello is the first word"); + assertEquals("World!", arr[1], "World is the second word"); + } +}