Initial version of a demo that can be easily switched between -Pbck2brwsr and -Pfxbrwsr
authorJaroslav Tulach <jtulach@netbeans.org>
Mon, 29 Apr 2013 13:42:23 +0200
changeset 06fe609b8f0fb
child 1 2278c9bafa53
Initial version of a demo that can be easily switched between -Pbck2brwsr and -Pfxbrwsr
.hgignore
COPYING
pom.xml
twitter/nbactions.xml
twitter/pom.xml
twitter/src/main/assembly/bck2brwsr.xml
twitter/src/main/assembly/fxbrwsr.xml
twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java
twitter/src/main/resources/org/apidesign/html/demo/twitter/index.html
twitter/src/main/resources/org/apidesign/html/demo/twitter/twitterExample.css
twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterClientTest.java
twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterProtocolTest.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.hgignore	Mon Apr 29 13:42:23 2013 +0200
     1.3 @@ -0,0 +1,3 @@
     1.4 +.*~
     1.5 +.*\.orig$
     1.6 +.*target/.*
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/COPYING	Mon Apr 29 13:42:23 2013 +0200
     2.3 @@ -0,0 +1,21 @@
     2.4 +The MIT License (MIT)
     2.5 +
     2.6 +Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     2.7 +
     2.8 +Permission is hereby granted, free of charge, to any person obtaining a copy
     2.9 +of this software and associated documentation files (the "Software"), to deal
    2.10 +in the Software without restriction, including without limitation the rights
    2.11 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    2.12 +copies of the Software, and to permit persons to whom the Software is
    2.13 +furnished to do so, subject to the following conditions:
    2.14 +
    2.15 +The above copyright notice and this permission notice shall be included in
    2.16 +all copies or substantial portions of the Software.
    2.17 +
    2.18 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    2.19 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    2.20 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    2.21 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    2.22 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    2.23 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    2.24 +THE SOFTWARE.
    2.25 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pom.xml	Mon Apr 29 13:42:23 2013 +0200
     3.3 @@ -0,0 +1,80 @@
     3.4 +<?xml version="1.0" encoding="UTF-8"?>
     3.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     3.6 +  <modelVersion>4.0.0</modelVersion>
     3.7 +  <groupId>org.apidesign.html</groupId>
     3.8 +  <artifactId>demo</artifactId>
     3.9 +  <version>1.0-SNAPSHOT</version>
    3.10 +  <packaging>pom</packaging>
    3.11 +  <name>Demo of HTML APIs</name>
    3.12 +  <parent>
    3.13 +    <groupId>net.java</groupId>
    3.14 +    <artifactId>jvnet-parent</artifactId>
    3.15 +    <version>3</version>
    3.16 +  </parent>  
    3.17 +  <properties>
    3.18 +      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    3.19 +      <bck2brwsr.version>0.7-SNAPSHOT</bck2brwsr.version>
    3.20 +      <license>COPYING</license>
    3.21 +  </properties>
    3.22 +  <modules>
    3.23 +    <module>twitter</module>
    3.24 +  </modules>
    3.25 +  <licenses>
    3.26 +      <license>
    3.27 +          <name>MIT</name>
    3.28 +          <url>http://opensource.org/licenses/mit-license.php</url>
    3.29 +          <distribution>repo</distribution>
    3.30 +      </license>
    3.31 +  </licenses>
    3.32 +  <organization>
    3.33 +      <name>API Design</name>
    3.34 +      <url>http://apidesign.org</url>
    3.35 +  </organization>
    3.36 +  <scm>
    3.37 +      <connection>scm:hg:https://hg.java.net/hg/html~demo</connection>
    3.38 +      <developerConnection>scm:hg:https://hg.java.net/hg/html~demo</developerConnection>
    3.39 +      <url>https://hg.java.net/hg/html~demo</url>
    3.40 +      <tag>default</tag>
    3.41 +  </scm>
    3.42 +  <pluginRepositories>
    3.43 +      <pluginRepository>
    3.44 +          <id>mc-release</id>
    3.45 +          <name>Local Maven repository of releases</name>
    3.46 +          <url>http://mc-repo.googlecode.com/svn/maven2/releases</url>
    3.47 +          <snapshots>
    3.48 +              <enabled>false</enabled>
    3.49 +          </snapshots>
    3.50 +          <releases>
    3.51 +              <enabled>true</enabled>
    3.52 +          </releases>
    3.53 +      </pluginRepository>
    3.54 +  </pluginRepositories>
    3.55 +  <build>
    3.56 +      <plugins>
    3.57 +         <plugin>
    3.58 +              <inherited>false</inherited>
    3.59 +              <groupId>com.mycila.maven-license-plugin</groupId>
    3.60 +              <artifactId>maven-license-plugin</artifactId>
    3.61 +              <version>1.9.0</version>
    3.62 +              <executions>
    3.63 +                  <execution>
    3.64 +                      <id>blah</id>
    3.65 +                      <goals>
    3.66 +                          <goal>check</goal>
    3.67 +                      </goals>
    3.68 +                  </execution>
    3.69 +              </executions>
    3.70 +              <configuration>
    3.71 +                  <aggregate>true</aggregate>
    3.72 +                  <basedir>${basedir}</basedir>
    3.73 +                  <header>COPYING</header>
    3.74 +                  <strictCheck>true</strictCheck>
    3.75 +                  <excludes>
    3.76 +                       <exclude>*</exclude>
    3.77 +                       <exclude>.*/**</exclude>
    3.78 +                  </excludes>
    3.79 +              </configuration>
    3.80 +          </plugin>
    3.81 +      </plugins>
    3.82 +  </build>
    3.83 +</project>
    3.84 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/twitter/nbactions.xml	Mon Apr 29 13:42:23 2013 +0200
     4.3 @@ -0,0 +1,35 @@
     4.4 +<?xml version="1.0" encoding="UTF-8"?>
     4.5 +<!--
     4.6 +
     4.7 +    The MIT License (MIT)
     4.8 +
     4.9 +    Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    4.10 +
    4.11 +    Permission is hereby granted, free of charge, to any person obtaining a copy
    4.12 +    of this software and associated documentation files (the "Software"), to deal
    4.13 +    in the Software without restriction, including without limitation the rights
    4.14 +    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    4.15 +    copies of the Software, and to permit persons to whom the Software is
    4.16 +    furnished to do so, subject to the following conditions:
    4.17 +
    4.18 +    The above copyright notice and this permission notice shall be included in
    4.19 +    all copies or substantial portions of the Software.
    4.20 +
    4.21 +    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    4.22 +    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    4.23 +    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    4.24 +    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    4.25 +    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    4.26 +    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    4.27 +    THE SOFTWARE.
    4.28 +
    4.29 +-->
    4.30 +<actions>
    4.31 +    <action>
    4.32 +        <actionName>run</actionName>
    4.33 +        <goals>
    4.34 +            <goal>process-classes</goal>
    4.35 +            <goal>bck2brwsr:brwsr</goal>
    4.36 +        </goals>
    4.37 +    </action>
    4.38 +</actions>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/twitter/pom.xml	Mon Apr 29 13:42:23 2013 +0200
     5.3 @@ -0,0 +1,267 @@
     5.4 +<?xml version="1.0" encoding="UTF-8"?>
     5.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     5.6 +  <modelVersion>4.0.0</modelVersion>
     5.7 +
     5.8 +  <groupId>org.apidesign.bck2brwsr</groupId>
     5.9 +  <artifactId>demo-twitter</artifactId>
    5.10 +  <version>1.0-SNAPSHOT</version>
    5.11 +  <packaging>jar</packaging>
    5.12 +  <parent>
    5.13 +      <groupId>org.apidesign.html</groupId>
    5.14 +      <artifactId>demo</artifactId>
    5.15 +      <version>1.0-SNAPSHOT</version>
    5.16 +  </parent>
    5.17 +
    5.18 +  <name>Fx/Bck2Brwsr's Twttr</name>
    5.19 +  <description>
    5.20 +      Rewrite of knockout.js example to use model written in Java and
    5.21 +      execute using FxBrwsr or Bck2Brwsr.
    5.22 +  </description>
    5.23 +
    5.24 +  <properties>
    5.25 +    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    5.26 +    <net.java.html.version>0.1-SNAPSHOT</net.java.html.version>
    5.27 +    <bck2brwsr.version>0.7-SNAPSHOT</bck2brwsr.version>
    5.28 +    <bck2brwsr.obfuscationlevel>MINIMAL</bck2brwsr.obfuscationlevel>
    5.29 +    <brwsr.startpage>org/apidesign/html/demo/twitter/index.html</brwsr.startpage>
    5.30 +  </properties>
    5.31 +
    5.32 +  <repositories>
    5.33 +      <repository>
    5.34 +          <id>java.net</id>
    5.35 +          <name>Java.net</name>
    5.36 +          <url>https://maven.java.net/content/repositories/releases/</url>
    5.37 +          <snapshots>
    5.38 +          </snapshots>
    5.39 +      </repository>
    5.40 +  </repositories>
    5.41 +  <pluginRepositories>
    5.42 +      <pluginRepository>
    5.43 +          <id>java.net</id>
    5.44 +          <name>Java.net</name>
    5.45 +          <url>https://maven.java.net/content/repositories/releases/</url>
    5.46 +          <snapshots>
    5.47 +          </snapshots>
    5.48 +      </pluginRepository>
    5.49 +  </pluginRepositories>
    5.50 +
    5.51 +  <build>
    5.52 +      <plugins>
    5.53 +          <plugin>
    5.54 +              <groupId>org.apidesign.bck2brwsr</groupId>
    5.55 +              <artifactId>bck2brwsr-maven-plugin</artifactId>
    5.56 +              <version>${bck2brwsr.version}</version>
    5.57 +              <executions>
    5.58 +                  <execution>
    5.59 +                      <goals>
    5.60 +                          <goal>brwsr</goal>
    5.61 +                      </goals>
    5.62 +                  </execution>
    5.63 +              </executions>
    5.64 +              <configuration>
    5.65 +                  <startpage>${brwsr.startpage}</startpage>
    5.66 +                  <launcher>${brwsr}</launcher>
    5.67 +              </configuration>
    5.68 +          </plugin>
    5.69 +          <plugin>
    5.70 +              <groupId>org.apache.maven.plugins</groupId>
    5.71 +              <artifactId>maven-compiler-plugin</artifactId>
    5.72 +              <version>2.3.2</version>
    5.73 +              <configuration>
    5.74 +                  <source>1.7</source>
    5.75 +                  <target>1.7</target>
    5.76 +              </configuration>
    5.77 +          </plugin>
    5.78 +          <plugin>
    5.79 +              <groupId>org.apache.maven.plugins</groupId>
    5.80 +              <artifactId>maven-surefire-plugin</artifactId>
    5.81 +              <version>2.14.1</version>
    5.82 +              <configuration>
    5.83 +                  <systemPropertyVariables>
    5.84 +                      <vmtest.brwsrs>${brwsr}</vmtest.brwsrs>
    5.85 +                  </systemPropertyVariables>
    5.86 +              </configuration>
    5.87 +          </plugin>
    5.88 +          <plugin>
    5.89 +              <groupId>org.apache.maven.plugins</groupId>
    5.90 +              <artifactId>maven-jar-plugin</artifactId>
    5.91 +              <version>2.4</version>
    5.92 +              <configuration>
    5.93 +                  <archive>
    5.94 +                      <manifest>
    5.95 +                          <addClasspath>true</addClasspath>
    5.96 +                          <classpathPrefix>lib/</classpathPrefix>
    5.97 +                      </manifest>
    5.98 +                  </archive>
    5.99 +              </configuration>
   5.100 +          </plugin>
   5.101 +          <plugin>
   5.102 +              <groupId>org.apache.maven.plugins</groupId>
   5.103 +              <artifactId>maven-deploy-plugin</artifactId>
   5.104 +              <version>2.7</version>
   5.105 +              <configuration>
   5.106 +                  <skip>true</skip>
   5.107 +              </configuration>
   5.108 +          </plugin>      
   5.109 +      </plugins>
   5.110 +  </build>
   5.111 +
   5.112 +  <dependencies>
   5.113 +    <dependency>
   5.114 +      <groupId>org.testng</groupId>
   5.115 +      <artifactId>testng</artifactId>
   5.116 +      <version>6.5.2</version>
   5.117 +      <scope>test</scope>
   5.118 +    </dependency>
   5.119 +    <dependency>
   5.120 +      <groupId>org.apidesign.bck2brwsr</groupId>
   5.121 +      <artifactId>vmtest</artifactId>
   5.122 +      <version>${bck2brwsr.version}</version>
   5.123 +      <scope>test</scope>
   5.124 +    </dependency>
   5.125 +    <dependency>
   5.126 +      <groupId>org.apidesign.html</groupId>
   5.127 +      <artifactId>net.java.html.json</artifactId>
   5.128 +      <version>${net.java.html.version}</version>
   5.129 +      <type>jar</type>
   5.130 +    </dependency>
   5.131 +  </dependencies>
   5.132 +  <profiles>
   5.133 +      <profile>
   5.134 +          <id>fxbrwsr</id>
   5.135 +          <activation>
   5.136 +              <activeByDefault>true</activeByDefault>
   5.137 +          </activation>
   5.138 +          <properties>
   5.139 +              <brwsr>fxbrwsr</brwsr>
   5.140 +          </properties>
   5.141 +          <build>
   5.142 +            <plugins>
   5.143 +                <plugin>
   5.144 +                    <groupId>org.apache.maven.plugins</groupId>
   5.145 +                    <artifactId>maven-jar-plugin</artifactId>
   5.146 +                    <version>2.4</version>
   5.147 +                    <configuration>
   5.148 +                        <archive>
   5.149 +                            <manifest>
   5.150 +                                <mainClass>org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher</mainClass>
   5.151 +                                <addClasspath>true</addClasspath>
   5.152 +                                <classpathPrefix>lib/</classpathPrefix>
   5.153 +                            </manifest>
   5.154 +                            <manifestEntries>
   5.155 +                                <StartPage>${brwsr.startpage}</StartPage>
   5.156 +                            </manifestEntries>
   5.157 +                        </archive>
   5.158 +                    </configuration>
   5.159 +                </plugin>
   5.160 +                <plugin>
   5.161 +                    <artifactId>maven-assembly-plugin</artifactId>
   5.162 +                    <version>2.4</version>
   5.163 +                    <executions>
   5.164 +                        <execution>
   5.165 +                            <id>distro-assembly</id>
   5.166 +                            <phase>package</phase>
   5.167 +                            <goals>
   5.168 +                                <goal>single</goal>
   5.169 +                            </goals>
   5.170 +                            <configuration>
   5.171 +                                <descriptors>
   5.172 +                                    <descriptor>src/main/assembly/fxbrwsr.xml</descriptor>
   5.173 +                                </descriptors>
   5.174 +                            </configuration>
   5.175 +                        </execution>
   5.176 +                    </executions>                
   5.177 +                </plugin>      
   5.178 +            </plugins>
   5.179 +          </build>
   5.180 +          <dependencies>
   5.181 +              <dependency>
   5.182 +                  <groupId>org.apidesign.html</groupId>
   5.183 +                  <artifactId>ko-fx</artifactId>
   5.184 +                  <version>${net.java.html.version}</version>
   5.185 +              </dependency>
   5.186 +              <dependency>
   5.187 +                  <groupId>org.apidesign.bck2brwsr</groupId>
   5.188 +                  <artifactId>launcher.fx</artifactId>
   5.189 +                  <version>${bck2brwsr.version}</version>
   5.190 +                  <scope>runtime</scope>
   5.191 +              </dependency>
   5.192 +          </dependencies>
   5.193 +      </profile>
   5.194 +      <profile>
   5.195 +          <id>bck2brwsr</id>
   5.196 +          <activation>
   5.197 +              <property>
   5.198 +                  <name>brwsr</name>
   5.199 +                  <value>bck2brwsr</value>
   5.200 +              </property>
   5.201 +          </activation>
   5.202 +          <build>
   5.203 +              <plugins>
   5.204 +                  <plugin>
   5.205 +                      <groupId>org.apidesign.bck2brwsr</groupId>
   5.206 +                      <artifactId>bck2brwsr-maven-plugin</artifactId>
   5.207 +                      <executions>
   5.208 +                          <execution>
   5.209 +                              <goals>
   5.210 +                                  <goal>j2js</goal>
   5.211 +                              </goals>
   5.212 +                          </execution>
   5.213 +                      </executions>
   5.214 +                      <configuration>
   5.215 +                          <javascript>${project.build.directory}/bck2brwsr.js</javascript>
   5.216 +                          <obfuscation>${bck2brwsr.obfuscationlevel}</obfuscation>
   5.217 +                      </configuration>
   5.218 +                  </plugin>
   5.219 +                  <plugin>
   5.220 +                      <groupId>org.apache.maven.plugins</groupId>
   5.221 +                      <artifactId>maven-compiler-plugin</artifactId>
   5.222 +                      <configuration>
   5.223 +                          <compilerArguments>
   5.224 +                              <bootclasspath>netbeans.ignore.jdk.bootclasspath</bootclasspath>
   5.225 +                          </compilerArguments>
   5.226 +                      </configuration>
   5.227 +                  </plugin>
   5.228 +                  <plugin>
   5.229 +                      <artifactId>maven-assembly-plugin</artifactId>
   5.230 +                      <version>2.4</version>
   5.231 +                      <executions>
   5.232 +                          <execution>
   5.233 +                              <id>distro-assembly</id>
   5.234 +                              <phase>package</phase>
   5.235 +                              <goals>
   5.236 +                                  <goal>single</goal>
   5.237 +                              </goals>
   5.238 +                              <configuration>
   5.239 +                                  <descriptors>
   5.240 +                                      <descriptor>src/main/assembly/bck2brwsr.xml</descriptor>
   5.241 +                                  </descriptors>
   5.242 +                              </configuration>
   5.243 +                          </execution>
   5.244 +                      </executions>                
   5.245 +                  </plugin>      
   5.246 +              </plugins>
   5.247 +          </build>
   5.248 +          <dependencies>
   5.249 +              <dependency>
   5.250 +                  <groupId>org.apidesign.bck2brwsr</groupId>
   5.251 +                  <artifactId>emul</artifactId>
   5.252 +                  <version>${bck2brwsr.version}</version>
   5.253 +                  <classifier>rt</classifier>
   5.254 +              </dependency>
   5.255 +              <dependency>
   5.256 +                  <groupId>org.apidesign.html</groupId>
   5.257 +                  <artifactId>ko-bck2brwsr</artifactId>
   5.258 +                  <version>${net.java.html.version}</version>
   5.259 +                  <scope>runtime</scope>
   5.260 +              </dependency>
   5.261 +              <dependency>
   5.262 +                  <groupId>org.apidesign.bck2brwsr</groupId>
   5.263 +                  <artifactId>launcher.http</artifactId>
   5.264 +                  <version>${bck2brwsr.version}</version>
   5.265 +                  <scope>test</scope>
   5.266 +              </dependency>
   5.267 +          </dependencies>
   5.268 +      </profile>
   5.269 +  </profiles>
   5.270 +</project>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/twitter/src/main/assembly/bck2brwsr.xml	Mon Apr 29 13:42:23 2013 +0200
     6.3 @@ -0,0 +1,68 @@
     6.4 +<?xml version="1.0"?>
     6.5 +<!--
     6.6 +
     6.7 +    The MIT License (MIT)
     6.8 +
     6.9 +    Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    6.10 +
    6.11 +    Permission is hereby granted, free of charge, to any person obtaining a copy
    6.12 +    of this software and associated documentation files (the "Software"), to deal
    6.13 +    in the Software without restriction, including without limitation the rights
    6.14 +    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    6.15 +    copies of the Software, and to permit persons to whom the Software is
    6.16 +    furnished to do so, subject to the following conditions:
    6.17 +
    6.18 +    The above copyright notice and this permission notice shall be included in
    6.19 +    all copies or substantial portions of the Software.
    6.20 +
    6.21 +    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    6.22 +    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    6.23 +    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    6.24 +    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    6.25 +    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    6.26 +    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    6.27 +    THE SOFTWARE.
    6.28 +
    6.29 +-->
    6.30 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    6.31 +  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    6.32 +  
    6.33 +  <id>bck2brwsr</id>
    6.34 +  <formats>
    6.35 +      <format>zip</format>
    6.36 +  </formats>
    6.37 +  <baseDirectory>public_html</baseDirectory>
    6.38 +  <dependencySets>
    6.39 +    <dependencySet>
    6.40 +        <useProjectArtifact>false</useProjectArtifact>
    6.41 +        <scope>runtime</scope>
    6.42 +        <outputDirectory>lib</outputDirectory>
    6.43 +        <includes>
    6.44 +            <include>*:jar</include>
    6.45 +            <include>*:rt</include>
    6.46 +        </includes>
    6.47 +    </dependencySet>
    6.48 +  </dependencySets> 
    6.49 +  <fileSets>
    6.50 +      <fileSet>
    6.51 +          <directory>${project.build.directory}/classes/org/apidesign/html/demo/twitter/</directory>
    6.52 +          <includes>
    6.53 +              <include>**/*</include>
    6.54 +          </includes>
    6.55 +          <excludes>
    6.56 +              <exclude>**/*.class</exclude>
    6.57 +          </excludes>
    6.58 +          <outputDirectory>/</outputDirectory>
    6.59 +      </fileSet>
    6.60 +  </fileSets>
    6.61 +  <files>
    6.62 +    <file>
    6.63 +      <source>${project.build.directory}/${project.build.finalName}.jar</source>
    6.64 +      <outputDirectory>/</outputDirectory>
    6.65 +    </file>
    6.66 +    <file>
    6.67 +      <source>${project.build.directory}/bck2brwsr.js</source>
    6.68 +      <outputDirectory>/</outputDirectory>
    6.69 +    </file>
    6.70 +  </files>
    6.71 +</assembly>
    6.72 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/twitter/src/main/assembly/fxbrwsr.xml	Mon Apr 29 13:42:23 2013 +0200
     7.3 @@ -0,0 +1,48 @@
     7.4 +<?xml version="1.0"?>
     7.5 +<!--
     7.6 +
     7.7 +    The MIT License (MIT)
     7.8 +
     7.9 +    Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    7.10 +
    7.11 +    Permission is hereby granted, free of charge, to any person obtaining a copy
    7.12 +    of this software and associated documentation files (the "Software"), to deal
    7.13 +    in the Software without restriction, including without limitation the rights
    7.14 +    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    7.15 +    copies of the Software, and to permit persons to whom the Software is
    7.16 +    furnished to do so, subject to the following conditions:
    7.17 +
    7.18 +    The above copyright notice and this permission notice shall be included in
    7.19 +    all copies or substantial portions of the Software.
    7.20 +
    7.21 +    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    7.22 +    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    7.23 +    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    7.24 +    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    7.25 +    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    7.26 +    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    7.27 +    THE SOFTWARE.
    7.28 +
    7.29 +-->
    7.30 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    7.31 +  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    7.32 +  
    7.33 +  <id>fxbrwsr</id>
    7.34 +  <formats>
    7.35 +      <format>zip</format>
    7.36 +  </formats>
    7.37 +  <baseDirectory>${project.build.finalName}-fxbrwsr</baseDirectory>
    7.38 +  <dependencySets>
    7.39 +    <dependencySet>
    7.40 +        <useProjectArtifact>false</useProjectArtifact>
    7.41 +        <scope>runtime</scope>
    7.42 +        <outputDirectory>lib</outputDirectory>
    7.43 +    </dependencySet>
    7.44 +  </dependencySets> 
    7.45 +  <files>
    7.46 +    <file>
    7.47 +      <source>${project.build.directory}/${project.build.finalName}.jar</source>
    7.48 +      <outputDirectory>/</outputDirectory>
    7.49 +    </file>
    7.50 +  </files>
    7.51 +</assembly>
    7.52 \ No newline at end of file
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java	Mon Apr 29 13:42:23 2013 +0200
     8.3 @@ -0,0 +1,204 @@
     8.4 +/**
     8.5 + * The MIT License (MIT)
     8.6 + *
     8.7 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     8.8 + *
     8.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    8.10 + * of this software and associated documentation files (the "Software"), to deal
    8.11 + * in the Software without restriction, including without limitation the rights
    8.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    8.13 + * copies of the Software, and to permit persons to whom the Software is
    8.14 + * furnished to do so, subject to the following conditions:
    8.15 + *
    8.16 + * The above copyright notice and this permission notice shall be included in
    8.17 + * all copies or substantial portions of the Software.
    8.18 + *
    8.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    8.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    8.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    8.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    8.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    8.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    8.25 + * THE SOFTWARE.
    8.26 + */
    8.27 +package org.apidesign.html.demo.twitter;
    8.28 +
    8.29 +import java.util.Arrays;
    8.30 +import java.util.List;
    8.31 +import net.java.html.json.ComputedProperty;
    8.32 +import net.java.html.json.Context;
    8.33 +import net.java.html.json.Function;
    8.34 +import net.java.html.json.Model;
    8.35 +import net.java.html.json.OnPropertyChange;
    8.36 +import net.java.html.json.OnReceive;
    8.37 +import net.java.html.json.Property;
    8.38 +
    8.39 +/** Controller class for access to Twitter.
    8.40 + * 
    8.41 + * @author Jaroslav Tulach
    8.42 + */
    8.43 +@Model(className="TwitterModel", properties={
    8.44 +    @Property(name="savedLists", type=Tweeters.class, array = true),
    8.45 +    @Property(name="activeTweetersName", type=String.class),
    8.46 +    @Property(name="activeTweeters", type=String.class, array = true),
    8.47 +    @Property(name="userNameToAdd", type=String.class),
    8.48 +    @Property(name="currentTweets", type=Tweet.class, array = true)
    8.49 +})
    8.50 +public class TwitterClient {
    8.51 +    @Model(className = "Tweeters", properties = {
    8.52 +        @Property(name="name", type = String.class),
    8.53 +        @Property(name="userNames", type = String.class, array = true)
    8.54 +    })
    8.55 +    static class Twttrs {
    8.56 +    }
    8.57 +    @Model(className = "Tweet", properties = {
    8.58 +        @Property(name = "from_user", type = String.class),
    8.59 +        @Property(name = "from_user_id", type = int.class),
    8.60 +        @Property(name = "profile_image_url", type = String.class),
    8.61 +        @Property(name = "text", type = String.class),
    8.62 +        @Property(name = "created_at", type = String.class),
    8.63 +    })
    8.64 +    static final class Twt {
    8.65 +        @ComputedProperty static String html(String text) {
    8.66 +            StringBuilder sb = new StringBuilder(320);
    8.67 +            for (int pos = 0;;) {
    8.68 +                int http = text.indexOf("http", pos);
    8.69 +                if (http == -1) {
    8.70 +                    sb.append(text.substring(pos));
    8.71 +                    return sb.toString();
    8.72 +                }
    8.73 +                int spc = text.indexOf(' ', http);
    8.74 +                if (spc == -1) {
    8.75 +                    spc = text.length();
    8.76 +                }
    8.77 +                sb.append(text.substring(pos, http));
    8.78 +                String url = text.substring(http, spc);
    8.79 +                sb.append("<a href='").append(url).append("'>").append(url).append("</a>");
    8.80 +                pos = spc;
    8.81 +            }
    8.82 +        }
    8.83 +        
    8.84 +        @ComputedProperty static String userUrl(String from_user) {
    8.85 +            return "http://twitter.com/" + from_user;
    8.86 +        }
    8.87 +    }
    8.88 +    @Model(className = "TwitterQuery", properties = {
    8.89 +        @Property(array = true, name = "results", type = Twt.class)
    8.90 +    })
    8.91 +    public static final class TwttrQr {
    8.92 +    }
    8.93 +    
    8.94 +    @OnReceive(url="{root}/search.json?{query}&callback={me}", jsonp="me")
    8.95 +    static void queryTweets(TwitterModel page, TwitterQuery q) {
    8.96 +        page.getCurrentTweets().clear();
    8.97 +        page.getCurrentTweets().addAll(q.getResults());
    8.98 +    }
    8.99 +    
   8.100 +    @OnPropertyChange("activeTweetersName")
   8.101 +    static void changeTweetersList(TwitterModel model) {
   8.102 +        Tweeters people = findByName(model.getSavedLists(), model.getActiveTweetersName());        
   8.103 +        model.getActiveTweeters().clear();
   8.104 +        model.getActiveTweeters().addAll(people.getUserNames());
   8.105 +    }
   8.106 +    
   8.107 +    @OnPropertyChange({ "activeTweeters", "activeTweetersCount" })
   8.108 +    static void refreshTweets(TwitterModel model) {
   8.109 +        StringBuilder sb = new StringBuilder();
   8.110 +        sb.append("rpp=25&q=");
   8.111 +        String sep = "";
   8.112 +        for (String p : model.getActiveTweeters()) {
   8.113 +            sb.append(sep);
   8.114 +            sb.append("from:");
   8.115 +            sb.append(p);
   8.116 +            sep = " OR ";
   8.117 +        }
   8.118 +        model.queryTweets("http://search.twitter.com", sb.toString());
   8.119 +    }
   8.120 +    
   8.121 +    private static final Context DEFAULT = Context.findDefault(TwitterClient.class);
   8.122 +    static {
   8.123 +        final TwitterModel model = new TwitterModel(DEFAULT);
   8.124 +        final List<Tweeters> svdLst = model.getSavedLists();
   8.125 +        svdLst.add(newTweeters("API Design", "JaroslavTulach"));
   8.126 +        svdLst.add(newTweeters("Celebrities", "JohnCleese", "MCHammer", "StephenFry", "algore", "StevenSanderson"));
   8.127 +        svdLst.add(newTweeters("Microsoft people", "BillGates", "shanselman", "ScottGu"));
   8.128 +        svdLst.add(newTweeters("NetBeans", "GeertjanW","monacotoni", "NetBeans", "petrjiricka"));
   8.129 +        svdLst.add(newTweeters("Tech pundits", "Scobleizer", "LeoLaporte", "techcrunch", "BoingBoing", "timoreilly", "codinghorror"));
   8.130 +
   8.131 +        model.setActiveTweetersName("NetBeans");
   8.132 +
   8.133 +        model.applyBindings();
   8.134 +    }
   8.135 +    
   8.136 +    @ComputedProperty
   8.137 +    static boolean hasUnsavedChanges(List<String> activeTweeters, List<Tweeters> savedLists, String activeTweetersName) {
   8.138 +        Tweeters tw = findByName(savedLists, activeTweetersName);
   8.139 +        if (activeTweeters == null) {
   8.140 +            return false;
   8.141 +        }
   8.142 +        return !tw.getUserNames().equals(activeTweeters);
   8.143 +    }
   8.144 +    
   8.145 +    @ComputedProperty
   8.146 +    static int activeTweetersCount(List<String> activeTweeters) {
   8.147 +        return activeTweeters.size();
   8.148 +    }
   8.149 +    
   8.150 +    @ComputedProperty
   8.151 +    static boolean userNameToAddIsValid(
   8.152 +        String userNameToAdd, String activeTweetersName, List<Tweeters> savedLists, List<String> activeTweeters
   8.153 +    ) {
   8.154 +        return userNameToAdd != null && 
   8.155 +            userNameToAdd.matches("[a-zA-Z0-9_]{1,15}") &&
   8.156 +            !activeTweeters.contains(userNameToAdd);
   8.157 +    }
   8.158 +    
   8.159 +    @Function
   8.160 +    static void deleteList(TwitterModel model) {
   8.161 +        final List<Tweeters> sl = model.getSavedLists();
   8.162 +        sl.remove(findByName(sl, model.getActiveTweetersName()));
   8.163 +        if (sl.isEmpty()) {
   8.164 +            final Tweeters t = new Tweeters(DEFAULT);
   8.165 +            t.setName("New");
   8.166 +            sl.add(t);
   8.167 +        }
   8.168 +        model.setActiveTweetersName(sl.get(0).getName());
   8.169 +    }
   8.170 +    
   8.171 +    @Function
   8.172 +    static void saveChanges(TwitterModel model) {
   8.173 +        Tweeters t = findByName(model.getSavedLists(), model.getActiveTweetersName());
   8.174 +        int indx = model.getSavedLists().indexOf(t);
   8.175 +        if (indx != -1) {
   8.176 +            t.setName(model.getActiveTweetersName());
   8.177 +            t.getUserNames().clear();
   8.178 +            t.getUserNames().addAll(model.getActiveTweeters());
   8.179 +        }
   8.180 +    }
   8.181 +    
   8.182 +    @Function
   8.183 +    static void addUser(TwitterModel model) {
   8.184 +        String n = model.getUserNameToAdd();
   8.185 +        model.getActiveTweeters().add(n);
   8.186 +    }
   8.187 +    @Function
   8.188 +    static void removeUser(String data, TwitterModel model) {
   8.189 +        model.getActiveTweeters().remove(data);
   8.190 +    }
   8.191 +    
   8.192 +    private static Tweeters findByName(List<Tweeters> list, String name) {
   8.193 +        for (Tweeters l : list) {
   8.194 +            if (l.getName() != null && l.getName().equals(name)) {
   8.195 +                return l;
   8.196 +            }
   8.197 +        }
   8.198 +        return list.isEmpty() ? new Tweeters(DEFAULT) : list.get(0);
   8.199 +    }
   8.200 +    
   8.201 +    private static Tweeters newTweeters(String listName, String... userNames) {
   8.202 +        Tweeters t = new Tweeters(DEFAULT);
   8.203 +        t.setName(listName);
   8.204 +        t.getUserNames().addAll(Arrays.asList(userNames));
   8.205 +        return t;
   8.206 +    }
   8.207 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/twitter/src/main/resources/org/apidesign/html/demo/twitter/index.html	Mon Apr 29 13:42:23 2013 +0200
     9.3 @@ -0,0 +1,105 @@
     9.4 +<?xml version="1.0" encoding="UTF-8"?>
     9.5 +<!--
     9.6 +
     9.7 +    The MIT License (MIT)
     9.8 +
     9.9 +    Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    9.10 +
    9.11 +    Permission is hereby granted, free of charge, to any person obtaining a copy
    9.12 +    of this software and associated documentation files (the "Software"), to deal
    9.13 +    in the Software without restriction, including without limitation the rights
    9.14 +    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    9.15 +    copies of the Software, and to permit persons to whom the Software is
    9.16 +    furnished to do so, subject to the following conditions:
    9.17 +
    9.18 +    The above copyright notice and this permission notice shall be included in
    9.19 +    all copies or substantial portions of the Software.
    9.20 +
    9.21 +    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    9.22 +    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    9.23 +    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    9.24 +    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    9.25 +    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    9.26 +    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    9.27 +    THE SOFTWARE.
    9.28 +
    9.29 +-->
    9.30 +
    9.31 +<!--
    9.32 +    Copied from knockout.js Twitter example:
    9.33 +    http://knockoutjs.com/examples/twitter.html
    9.34 +-->
    9.35 +
    9.36 +<!DOCTYPE html>
    9.37 +<html xmlns="http://www.w3.org/1999/xhtml">
    9.38 +    <head>
    9.39 +        <title>Bck2Brwsr's Twitter</title>
    9.40 +    </head>
    9.41 +    <body>
    9.42 +        <link href='twitterExample.css' rel='Stylesheet' ></link>
    9.43 +        
    9.44 +        <style type='text/css'>
    9.45 +           .liveExample select { height: 1.7em; }
    9.46 +           .liveExample button { height: 2em; }
    9.47 +        </style>
    9.48 +        
    9.49 +        
    9.50 +        <h2>Bck2Brwsr's Twitter</h2>
    9.51 +        
    9.52 +        <p>
    9.53 +        This code based on original <a href="http://knockoutjs.com/examples/twitter.html">knockout.js Twitter example</a> and
    9.54 +        uses almost unmodified HTML code. It just changes the model. It 
    9.55 +        is written in Java language and it is executed using <a href="http://bck2brwsr.apidesign.org">Bck2Brwsr</a>
    9.56 +        virtual machine. The Java source code has about 190 lines and is available 
    9.57 +        <a href="http://source.apidesign.org/hg/bck2brwsr/file/7fc6b7e9c982/javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClient.java">here</a>
    9.58 +        - in fact it may even be more dense than the original JavaScript model.
    9.59 +        </p>
    9.60 +        
    9.61 +        <div class='liveExample'>
    9.62 +            <div class='configuration'>
    9.63 +                <div class='listChooser'>
    9.64 +                    <button data-bind='click: deleteList, enable: activeTweetersName'>Delete</button>
    9.65 +                    <button data-bind='click: saveChanges, enable: hasUnsavedChanges'>Save</button> 
    9.66 +                    <select data-bind='options: savedLists, optionsValue: "name", value: activeTweetersName'> </select>
    9.67 +                </div>
    9.68 +
    9.69 +                <p>Currently viewing <span data-bind='text: activeTweetersCount'> </span> user(s):</p>
    9.70 +                <div class='currentUsers' >
    9.71 +                    <ul data-bind='foreach: activeTweeters'>
    9.72 +                        <li>
    9.73 +                            <button data-bind='click: $root.removeUser'>Remove</button>
    9.74 +                            <div data-bind='text: $data'> </div>
    9.75 +                        </li>
    9.76 +                    </ul>
    9.77 +                </div>
    9.78 +
    9.79 +                <form data-bind='submit: addUser'>
    9.80 +                    <label>Add user:</label>
    9.81 +                    <input data-bind='value: userNameToAdd, valueUpdate: "keyup", css: { invalid: !userNameToAddIsValid() }' />
    9.82 +                    <button data-bind='enable: userNameToAddIsValid' type='submit'>Add</button>
    9.83 +                </form>
    9.84 +            </div>
    9.85 +            <div class='tweets'>
    9.86 +                <div class='loadingIndicator'>Loading...</div>
    9.87 +                <table data-bind='foreach: currentTweets' width='100%'>
    9.88 +                    <tr>
    9.89 +                        <td><img data-bind='attr: { src: profile_image_url }' /></td>
    9.90 +                        <td>
    9.91 +                            <a class='twitterUser' data-bind='attr: { href: userUrl }, text: from_user'> </a>
    9.92 +                            <span data-bind='html: html'> </span>
    9.93 +                            <div class='tweetInfo' data-bind='text: created_at'> </div>
    9.94 +                        </td>
    9.95 +                    </tr>
    9.96 +                </table>
    9.97 +            </div>
    9.98 +        </div>
    9.99 +        
   9.100 +        <script src="bck2brwsr.js"></script>
   9.101 +        <script type="text/javascript">
   9.102 +            var vm = bck2brwsr('demo-twitter-1.0-SNAPSHOT.jar');
   9.103 +            vm.loadClass('org.apidesign.html.demo.twitter.TwitterClient');
   9.104 +        </script>
   9.105 +
   9.106 +
   9.107 +    </body>
   9.108 +</html>
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/twitter/src/main/resources/org/apidesign/html/demo/twitter/twitterExample.css	Mon Apr 29 13:42:23 2013 +0200
    10.3 @@ -0,0 +1,58 @@
    10.4 +/**
    10.5 + * The MIT License (MIT)
    10.6 + *
    10.7 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    10.8 + *
    10.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   10.10 + * of this software and associated documentation files (the "Software"), to deal
   10.11 + * in the Software without restriction, including without limitation the rights
   10.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   10.13 + * copies of the Software, and to permit persons to whom the Software is
   10.14 + * furnished to do so, subject to the following conditions:
   10.15 + *
   10.16 + * The above copyright notice and this permission notice shall be included in
   10.17 + * all copies or substantial portions of the Software.
   10.18 + *
   10.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   10.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   10.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   10.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   10.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   10.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   10.25 + * THE SOFTWARE.
   10.26 + */
   10.27 +
   10.28 +
   10.29 +
   10.30 +/*
   10.31 +    Copied from knockout.js Twitter example:
   10.32 +    http://knockoutjs.com/examples/twitter.html
   10.33 +*/
   10.34 +
   10.35 +.configuration, .tweets, .tweets td { font-family: Verdana; font-size: 13px; }
   10.36 +.configuration { background-color: #DEDEDE; border: 2px solid gray; float:left; height: 40em; width: 40%; padding: 0.5em; border-right-width:0; }
   10.37 +.tweets { width: 55%; border: 2px solid gray; height: 40em; overflow: scroll; overflow-x: hidden; background-color: Black; color: White; padding: 0.5em; position: relative; }
   10.38 +.tweets table { border-width: 0;}
   10.39 +.tweets tr { vertical-align: top; }
   10.40 +.tweets td { padding: 0.4em 0.3em 1em 0.4em; border-width: 0; }
   10.41 +.tweets img { width: 4em; }
   10.42 +.tweetInfo { color: Gray; font-size: 0.9em; }
   10.43 +.twitterUser { color: #77AAFF; text-decoration: none; font-size: 1.1em; font-weight: bold; }
   10.44 +input.invalid { border: 1px solid red !important; background-color: #FFAAAA !important; }
   10.45 +
   10.46 +.listChooser select, .listChooser button { vertical-align:top; }
   10.47 +.listChooser select { width: 60%; font-size:1.2em; height:1.4em; }
   10.48 +.listChooser button { width: 19%; height:1.68em; float:right; }
   10.49 +
   10.50 +.currentUsers { height: 28em; overflow-y: auto; overflow-x: hidden; }
   10.51 +.currentUsers button { float: right; height: 2.5em; margin: 0.1em; padding-left: 1em; padding-right: 1em; }
   10.52 +.currentUsers ul, .configuration li { list-style: none; margin: 0; padding: 0 }
   10.53 +.currentUsers li { height: 2.4em; font-size: 1.2em; background-color: #A7D0E3; border: 1px solid gray; margin-bottom: 0.3em; -webkit-border-radius: 5px; -moz-border-radius: 5px; -webkit-box-shadow: 0 0.2em 0.5em gray; -moz-box-shadow: 0 0.2em 0.5em gray; }
   10.54 +.currentUsers li div { padding: 0.6em; }
   10.55 +.currentUsers li:hover { background-color: #EEC; }
   10.56 +
   10.57 +.configuration form label { width: 25%; display: inline-block; text-align:right; overflow: hidden; }
   10.58 +.configuration form input { width:40%; font-size: 1.3em; border:1px solid silver; background-color: White; padding: 0.1em; }
   10.59 +.configuration form button { width: 20%; margin-left: 0.3em; height: 2em; }
   10.60 +
   10.61 +.loadingIndicator { position: absolute; top: 0.1em; left: 0.1em; font: 0.8em Arial; background-color: #229; color: White; padding: 0.2em 0.5em 0.2em 0.5em; display: none; }
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterClientTest.java	Mon Apr 29 13:42:23 2013 +0200
    11.3 @@ -0,0 +1,75 @@
    11.4 +/**
    11.5 + * The MIT License (MIT)
    11.6 + *
    11.7 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    11.8 + *
    11.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   11.10 + * of this software and associated documentation files (the "Software"), to deal
   11.11 + * in the Software without restriction, including without limitation the rights
   11.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   11.13 + * copies of the Software, and to permit persons to whom the Software is
   11.14 + * furnished to do so, subject to the following conditions:
   11.15 + *
   11.16 + * The above copyright notice and this permission notice shall be included in
   11.17 + * all copies or substantial portions of the Software.
   11.18 + *
   11.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   11.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   11.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   11.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   11.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   11.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   11.25 + * THE SOFTWARE.
   11.26 + */
   11.27 +package org.apidesign.html.demo.twitter;
   11.28 +
   11.29 +import org.apidesign.html.demo.twitter.TwitterClient;
   11.30 +import java.util.List;
   11.31 +import net.java.html.json.Context;
   11.32 +import static org.testng.Assert.*;
   11.33 +import org.testng.annotations.BeforeMethod;
   11.34 +import org.testng.annotations.Test;
   11.35 +
   11.36 +/** We can unit test the TwitterModel smoothly.
   11.37 + *
   11.38 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   11.39 + */
   11.40 +public class TwitterClientTest {
   11.41 +    private TwitterModel model;
   11.42 +    
   11.43 +
   11.44 +    @BeforeMethod
   11.45 +    public void initModel() {
   11.46 +        model = new TwitterModel(Context.EMPTY);
   11.47 +    }
   11.48 +
   11.49 +    @Test public void testIsValidToAdd() {
   11.50 +        model.setUserNameToAdd("Joe");
   11.51 +        Tweeters t = new Tweeters(Context.EMPTY);
   11.52 +        t.setName("test");
   11.53 +        model.getSavedLists().add(t);
   11.54 +        model.setActiveTweetersName("test");
   11.55 +        
   11.56 +        assertTrue(model.isUserNameToAddIsValid(), "Joe is OK");
   11.57 +        TwitterClient.addUser(model);
   11.58 +        assertFalse(model.isUserNameToAddIsValid(), "Can't add Joe for the 2nd time");
   11.59 +        assertEquals(t.getUserNames().size(), 0, "Original tweeters list remains empty");
   11.60 +        
   11.61 +        List<String> mod = model.getActiveTweeters();
   11.62 +        assertTrue(model.isHasUnsavedChanges(), "We have modifications");
   11.63 +        assertEquals(mod.size(), 1, "One element in the list");
   11.64 +        assertEquals(mod.get(0), "Joe", "Its name is Joe");
   11.65 +        
   11.66 +        assertSame(model.getActiveTweeters(), mod, "Editing list is the modified one");
   11.67 +        
   11.68 +        TwitterClient.saveChanges(model);
   11.69 +        assertFalse(model.isHasUnsavedChanges(), "Does not have anything to save");
   11.70 +        
   11.71 +        assertSame(model.getActiveTweeters(), mod, "Still editing the old modified one");
   11.72 +    }
   11.73 +    
   11.74 +    @Test public void httpAtTheEnd() {
   11.75 +        String res = TwitterClient.Twt.html("Ahoj http://kuk");
   11.76 +        assertEquals(res, "Ahoj <a href='http://kuk'>http://kuk</a>");
   11.77 +    }
   11.78 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterProtocolTest.java	Mon Apr 29 13:42:23 2013 +0200
    12.3 @@ -0,0 +1,101 @@
    12.4 +/**
    12.5 + * The MIT License (MIT)
    12.6 + *
    12.7 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    12.8 + *
    12.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   12.10 + * of this software and associated documentation files (the "Software"), to deal
   12.11 + * in the Software without restriction, including without limitation the rights
   12.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   12.13 + * copies of the Software, and to permit persons to whom the Software is
   12.14 + * furnished to do so, subject to the following conditions:
   12.15 + *
   12.16 + * The above copyright notice and this permission notice shall be included in
   12.17 + * all copies or substantial portions of the Software.
   12.18 + *
   12.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   12.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   12.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   12.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   12.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   12.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   12.25 + * THE SOFTWARE.
   12.26 + */
   12.27 +package org.apidesign.html.demo.twitter;
   12.28 +
   12.29 +import net.java.html.json.Context;
   12.30 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   12.31 +import org.apidesign.bck2brwsr.vmtest.Http;
   12.32 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   12.33 +import org.testng.annotations.Factory;
   12.34 +
   12.35 +/**
   12.36 + *
   12.37 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   12.38 + */
   12.39 +public class TwitterProtocolTest {
   12.40 +    private TwitterModel page;
   12.41 +    @Http(@Http.Resource(
   12.42 +        path = "/search.json",
   12.43 +        mimeType = "application/json",
   12.44 +        parameters = {"callback"},
   12.45 +        content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\""
   12.46 +        + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":"
   12.47 +        + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\","
   12.48 +        + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\","
   12.49 +        + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
   12.50 +        + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344,"
   12.51 +        + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
   12.52 +        + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
   12.53 +        + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
   12.54 +        + "\"source\":\"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;\",\"text\":"
   12.55 +        + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + "
   12.56 +        + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747,"
   12.57 +        + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872,"
   12.58 +        + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\","
   12.59 +        + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
   12.60 +        + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913,"
   12.61 +        + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
   12.62 +        + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
   12.63 +        + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
   12.64 +        + "\"source\":\"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;\",\"text\":"
   12.65 +        + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"},"
   12.66 +        + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\","
   12.67 +        + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\","
   12.68 +        + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\","
   12.69 +        + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":"
   12.70 +        + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
   12.71 +        + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
   12.72 +        + "\"source\":\"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;\",\"text\":"
   12.73 +        + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"},"
   12.74 +        + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,"
   12.75 +        + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,"
   12.76 +        + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":"
   12.77 +        + "{\"result_type\":\"recent\"},\"profile_image_url\":"
   12.78 +        + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
   12.79 +        + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
   12.80 +        + "\"source\":\"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;\",\"text\":"
   12.81 +        + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100,"
   12.82 +        + "\"since_id\":0,\"since_id_str\":\"0\"})"
   12.83 +    ))
   12.84 +    @BrwsrTest public void readFromTwttr() throws InterruptedException {
   12.85 +        if (page == null) {
   12.86 +            page = new TwitterModel(Context.findDefault(TwitterProtocolTest.class));
   12.87 +            page.applyBindings();
   12.88 +            page.queryTweets("", "q=xyz");
   12.89 +        }
   12.90 +
   12.91 +        if (page.getCurrentTweets().isEmpty()) {
   12.92 +            throw new InterruptedException();
   12.93 +        }
   12.94 +
   12.95 +        assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets();
   12.96 +        
   12.97 +        String firstDate = page.getCurrentTweets().get(0).getCreated_at();
   12.98 +        assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate;
   12.99 +    }
  12.100 +    
  12.101 +    @Factory public static Object[] create() {
  12.102 +        return VMTest.create(TwitterProtocolTest.class);
  12.103 +    }
  12.104 +}