1.1 --- a/boot/pom.xml Thu Aug 01 17:36:01 2013 +0200
1.2 +++ b/boot/pom.xml Thu Aug 08 13:30:23 2013 +0200
1.3 @@ -42,7 +42,7 @@
1.4 <dependency>
1.5 <groupId>org.netbeans.api</groupId>
1.6 <artifactId>org-openide-util-lookup</artifactId>
1.7 - <scope>compile</scope>
1.8 + <scope>provided</scope>
1.9 </dependency>
1.10 </dependencies>
1.11 </project>
2.1 --- a/boot/src/main/java/net/java/html/boot/BrowserBuilder.java Thu Aug 01 17:36:01 2013 +0200
2.2 +++ b/boot/src/main/java/net/java/html/boot/BrowserBuilder.java Thu Aug 08 13:30:23 2013 +0200
2.3 @@ -189,6 +189,7 @@
2.4 @Override
2.5 public void run() {
2.6 try {
2.7 + Thread.currentThread().setContextClassLoader(loader);
2.8 Class<?> newClazz = Class.forName(clazz.getName(), true, loader);
2.9 if (browserClass != null) {
2.10 browserClass[0] = newClazz;
3.1 --- a/json/src/main/java/org/apidesign/html/json/impl/ModelProcessor.java Thu Aug 01 17:36:01 2013 +0200
3.2 +++ b/json/src/main/java/org/apidesign/html/json/impl/ModelProcessor.java Thu Aug 08 13:30:23 2013 +0200
3.3 @@ -455,6 +455,11 @@
3.4 if (e.getAnnotation(ComputedProperty.class) == null) {
3.5 continue;
3.6 }
3.7 + if (!e.getModifiers().contains(Modifier.STATIC)) {
3.8 + error("Method " + e.getSimpleName() + " has to be static when annotated by @ComputedProperty", e);
3.9 + ok = false;
3.10 + continue;
3.11 + }
3.12 ExecutableElement ee = (ExecutableElement)e;
3.13 final TypeMirror rt = ee.getReturnType();
3.14 final Types tu = processingEnv.getTypeUtils();
4.1 --- a/json/src/test/java/net/java/html/json/ModelProcessorTest.java Thu Aug 01 17:36:01 2013 +0200
4.2 +++ b/json/src/test/java/net/java/html/json/ModelProcessorTest.java Thu Aug 08 13:30:23 2013 +0200
4.3 @@ -60,6 +60,38 @@
4.4 }
4.5 }
4.6
4.7 + @Test public void warnOnNonStatic() throws IOException {
4.8 + String html = "<html><body>"
4.9 + + "</body></html>";
4.10 + String code = "package x.y.z;\n"
4.11 + + "import net.java.html.json.Model;\n"
4.12 + + "import net.java.html.json.Property;\n"
4.13 + + "import net.java.html.json.ComputedProperty;\n"
4.14 + + "@Model(className=\"XModel\", properties={\n"
4.15 + + " @Property(name=\"prop\", type=int.class)\n"
4.16 + + "})\n"
4.17 + + "class X {\n"
4.18 + + " @ComputedProperty int y(int prop) {\n"
4.19 + + " return prop;\n"
4.20 + + " }\n"
4.21 + + "}\n";
4.22 +
4.23 + Compile c = Compile.create(html, code);
4.24 + assertFalse(c.getErrors().isEmpty(), "One error: " + c.getErrors());
4.25 + boolean ok = false;
4.26 + StringBuilder msgs = new StringBuilder();
4.27 + for (Diagnostic<? extends JavaFileObject> e : c.getErrors()) {
4.28 + String msg = e.getMessage(Locale.ENGLISH);
4.29 + if (msg.contains("y has to be static")) {
4.30 + ok = true;
4.31 + }
4.32 + msgs.append("\n").append(msg);
4.33 + }
4.34 + if (!ok) {
4.35 + fail("Should contain warning about non-static method:" + msgs);
4.36 + }
4.37 + }
4.38 +
4.39 @Test public void canWeCompileWithJDK1_5SourceLevel() throws IOException {
4.40 String html = "<html><body>"
4.41 + "</body></html>";
5.1 --- a/pom.xml Thu Aug 01 17:36:01 2013 +0200
5.2 +++ b/pom.xml Thu Aug 08 13:30:23 2013 +0200
5.3 @@ -22,6 +22,7 @@
5.4 <module>ko-archetype</module>
5.5 <module>ko-archetype-test</module>
5.6 <module>ko-fx</module>
5.7 + <module>sound</module>
5.8 <module>context</module>
5.9 <module>boot</module>
5.10 <module>boot-fx</module>
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/sound/pom.xml Thu Aug 08 13:30:23 2013 +0200
6.3 @@ -0,0 +1,48 @@
6.4 +<?xml version="1.0"?>
6.5 +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
6.6 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6.7 + <modelVersion>4.0.0</modelVersion>
6.8 + <parent>
6.9 + <groupId>org.apidesign</groupId>
6.10 + <artifactId>html</artifactId>
6.11 + <version>0.5-SNAPSHOT</version>
6.12 + </parent>
6.13 + <groupId>org.apidesign.html</groupId>
6.14 + <artifactId>net.java.html.sound</artifactId>
6.15 + <version>0.5-SNAPSHOT</version>
6.16 + <name>Sound API via HTML</name>
6.17 + <url>http://maven.apache.org</url>
6.18 + <properties>
6.19 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6.20 + </properties>
6.21 + <build>
6.22 + <plugins>
6.23 + <plugin>
6.24 + <groupId>org.apache.maven.plugins</groupId>
6.25 + <artifactId>maven-javadoc-plugin</artifactId>
6.26 + <configuration>
6.27 + <skip>false</skip>
6.28 + <subpackages>net.java.html.sound</subpackages>
6.29 + </configuration>
6.30 + </plugin>
6.31 + </plugins>
6.32 + </build>
6.33 + <dependencies>
6.34 + <dependency>
6.35 + <groupId>org.testng</groupId>
6.36 + <artifactId>testng</artifactId>
6.37 + <scope>test</scope>
6.38 + </dependency>
6.39 + <dependency>
6.40 + <groupId>org.apidesign.html</groupId>
6.41 + <artifactId>net.java.html.boot</artifactId>
6.42 + <version>0.5-SNAPSHOT</version>
6.43 + <type>jar</type>
6.44 + </dependency>
6.45 + <dependency>
6.46 + <groupId>org.netbeans.api</groupId>
6.47 + <artifactId>org-openide-util-lookup</artifactId>
6.48 + <scope>provided</scope>
6.49 + </dependency>
6.50 + </dependencies>
6.51 +</project>
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/sound/src/main/java/net/java/html/sound/AudioClip.java Thu Aug 08 13:30:23 2013 +0200
7.3 @@ -0,0 +1,127 @@
7.4 +/**
7.5 + * HTML via Java(tm) Language Bindings
7.6 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
7.7 + *
7.8 + * This program is free software: you can redistribute it and/or modify
7.9 + * it under the terms of the GNU General Public License as published by
7.10 + * the Free Software Foundation, version 2 of the License.
7.11 + *
7.12 + * This program is distributed in the hope that it will be useful,
7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.15 + * GNU General Public License for more details. apidesign.org
7.16 + * designates this particular file as subject to the
7.17 + * "Classpath" exception as provided by apidesign.org
7.18 + * in the License file that accompanied this code.
7.19 + *
7.20 + * You should have received a copy of the GNU General Public License
7.21 + * along with this program. Look for COPYING file in the top folder.
7.22 + * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
7.23 + */
7.24 +package net.java.html.sound;
7.25 +
7.26 +import java.util.ServiceLoader;
7.27 +import org.apidesign.html.sound.spi.AudioEnvironment;
7.28 +
7.29 +/** Handle to an audio clip which can be {@link #play() played}, {@link #pause() paused}
7.30 + * and etc. Obtain new instance via {@link #create(java.lang.String) create} factory
7.31 + * method and then use it when necessary.
7.32 + *
7.33 + * @author antonepple
7.34 + */
7.35 +public abstract class AudioClip {
7.36 + private AudioClip() {
7.37 + }
7.38 +
7.39 + /** Creates new instance of an audio clip based on the provided URL.
7.40 + *
7.41 + * @param src the URL where to find the audio clip
7.42 + * @return the audio clip handle
7.43 + * @throws NullPointerException if src is <code>null</code>
7.44 + */
7.45 + public static AudioClip create(String src) {
7.46 + src.getClass();
7.47 + for (AudioEnvironment<?> ae : ServiceLoader.load(AudioEnvironment.class)) {
7.48 + Impl handle = create(ae, src);
7.49 + if (handle != null) {
7.50 + return handle;
7.51 + }
7.52 + }
7.53 + throw new IllegalStateException();
7.54 + }
7.55 +
7.56 + /** Plays the clip from begining to the end.
7.57 + */
7.58 + public abstract void play();
7.59 +
7.60 + /** Pauses playback of the clip
7.61 + */
7.62 + public abstract void pause();
7.63 +
7.64 + /**
7.65 + * Specifies the volume of the audio. Must be a number between 0.0 and 1.0:
7.66 + * <ul>
7.67 + * <li>1.0 - highest volume</li>
7.68 + * <li>0.5 - 50% volume</li>
7.69 + * <li>0.0 - silent</li>
7.70 + * </ul>
7.71 + *
7.72 + * @param volume for the playback
7.73 + */
7.74 + public abstract void setVolume(double volume);
7.75 +
7.76 +// public abstract void playFrom(int seconds);
7.77 +
7.78 + //
7.79 + // Implementation
7.80 + //
7.81 +
7.82 + private static <Audio> Impl<Audio> create(AudioEnvironment<Audio> env, String src) {
7.83 + Audio a = env.create(src);
7.84 + if (a != null) {
7.85 + return new Impl<Audio>(env, src, a);
7.86 + } else {
7.87 + return null;
7.88 + }
7.89 + }
7.90 +
7.91 + private static final class Impl<Audio> extends AudioClip {
7.92 + private final String src;
7.93 + private final Audio clip;
7.94 + private final AudioEnvironment<Audio> env;
7.95 +
7.96 + public Impl(AudioEnvironment<Audio> env, String src, Audio clip) {
7.97 + this.clip = clip;
7.98 + this.env = env;
7.99 + this.src = src;
7.100 + }
7.101 +
7.102 + @Override
7.103 + public void play() {
7.104 + env.play(clip);
7.105 + }
7.106 +
7.107 + @Override
7.108 + public void pause() {
7.109 + env.pause(clip);
7.110 + }
7.111 +
7.112 + @Override
7.113 + public void setVolume(double volume) {
7.114 + env.setVolume(clip, volume);
7.115 + }
7.116 +
7.117 + @Override
7.118 + public int hashCode() {
7.119 + return 59 * src.hashCode();
7.120 + }
7.121 +
7.122 + @Override
7.123 + public boolean equals(Object obj) {
7.124 + if (obj instanceof Impl) {
7.125 + return src.equals(((Impl)obj).src);
7.126 + }
7.127 + return false;
7.128 + }
7.129 + } // end of Impl
7.130 +}
7.131 \ No newline at end of file
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/sound/src/main/java/org/apidesign/html/sound/impl/BrowserAudioEnv.java Thu Aug 08 13:30:23 2013 +0200
8.3 @@ -0,0 +1,53 @@
8.4 +/**
8.5 + * HTML via Java(tm) Language Bindings
8.6 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
8.7 + *
8.8 + * This program is free software: you can redistribute it and/or modify
8.9 + * it under the terms of the GNU General Public License as published by
8.10 + * the Free Software Foundation, version 2 of the License.
8.11 + *
8.12 + * This program is distributed in the hope that it will be useful,
8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.15 + * GNU General Public License for more details. apidesign.org
8.16 + * designates this particular file as subject to the
8.17 + * "Classpath" exception as provided by apidesign.org
8.18 + * in the License file that accompanied this code.
8.19 + *
8.20 + * You should have received a copy of the GNU General Public License
8.21 + * along with this program. Look for COPYING file in the top folder.
8.22 + * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
8.23 + */
8.24 +package org.apidesign.html.sound.impl;
8.25 +
8.26 +import net.java.html.js.JavaScriptBody;
8.27 +import org.apidesign.html.sound.spi.AudioEnvironment;
8.28 +import org.openide.util.lookup.ServiceProvider;
8.29 +
8.30 +/** Registers an audio provider that delegates to HTML5 Audio tag.
8.31 + *
8.32 + * @author Jaroslav Tulach <jtulach@netbeans.org>
8.33 + */
8.34 +@ServiceProvider(service = AudioEnvironment.class, position = 100)
8.35 +public final class BrowserAudioEnv implements AudioEnvironment<Object> {
8.36 + @Override
8.37 + @JavaScriptBody(args = { "src" }, body = ""
8.38 + + "if (!Audio) return null;"
8.39 + + "return new Audio(src);")
8.40 + public Object create(String src) {
8.41 + // null if not running in browser
8.42 + return null;
8.43 + }
8.44 +
8.45 + @Override @JavaScriptBody(args = { "a" }, body = "a.play();")
8.46 + public void play(Object a) {
8.47 + }
8.48 +
8.49 + @Override @JavaScriptBody(args = { "a" }, body = "a.pause();")
8.50 + public void pause(Object a) {
8.51 + }
8.52 +
8.53 + @Override @JavaScriptBody(args = { "a", "volume" }, body = "a.setVolume(volume);")
8.54 + public void setVolume(Object a, double volume) {
8.55 + }
8.56 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/sound/src/main/java/org/apidesign/html/sound/spi/AudioEnvironment.java Thu Aug 08 13:30:23 2013 +0200
9.3 @@ -0,0 +1,36 @@
9.4 +/**
9.5 + * HTML via Java(tm) Language Bindings
9.6 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
9.7 + *
9.8 + * This program is free software: you can redistribute it and/or modify
9.9 + * it under the terms of the GNU General Public License as published by
9.10 + * the Free Software Foundation, version 2 of the License.
9.11 + *
9.12 + * This program is distributed in the hope that it will be useful,
9.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
9.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9.15 + * GNU General Public License for more details. apidesign.org
9.16 + * designates this particular file as subject to the
9.17 + * "Classpath" exception as provided by apidesign.org
9.18 + * in the License file that accompanied this code.
9.19 + *
9.20 + * You should have received a copy of the GNU General Public License
9.21 + * along with this program. Look for COPYING file in the top folder.
9.22 + * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
9.23 + */
9.24 +package org.apidesign.html.sound.spi;
9.25 +
9.26 +/** Basic interface for sound playback providers.
9.27 + *
9.28 + * @author antonepple
9.29 + * @param <Audio> the type representing an audio
9.30 + */
9.31 +public interface AudioEnvironment<Audio> {
9.32 + public Audio create(String src);
9.33 +
9.34 + public void play(Audio a);
9.35 +
9.36 + public void pause(Audio a);
9.37 +
9.38 + public void setVolume(Audio a, double volume);
9.39 +}