# HG changeset patch # User Jaroslav Tulach # Date 1367385606 -7200 # Node ID 0930803c77d2e821ff8d93ea14d643d863e0aa02 # Parent 93e8fc67b2b5e4aa13a61e52a525c5b4fcb9a8fa# Parent 3213724a49968149d9d89519c16f850e946b84ac Merging in recent updates needed to produce release-0.1 diff -r 93e8fc67b2b5 -r 0930803c77d2 ko-bck2brwsr/pom.xml --- a/ko-bck2brwsr/pom.xml Tue Apr 30 17:28:02 2013 +0200 +++ b/ko-bck2brwsr/pom.xml Wed May 01 07:20:06 2013 +0200 @@ -22,6 +22,13 @@ 1.7 + + org.apache.maven.plugins + maven-javadoc-plugin + + false + + diff -r 93e8fc67b2b5 -r 0930803c77d2 ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/BrwsrCntxt.java --- a/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/BrwsrCntxt.java Tue Apr 30 17:28:02 2013 +0200 +++ b/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/BrwsrCntxt.java Wed May 01 07:20:06 2013 +0200 @@ -32,7 +32,7 @@ * * @author Jaroslav Tulach */ -public final class BrwsrCntxt implements Technology, Transfer { +final class BrwsrCntxt implements Technology, Transfer { private BrwsrCntxt() {} public static final Context DEFAULT; diff -r 93e8fc67b2b5 -r 0930803c77d2 ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/BrwsrCntxtPrvdr.java --- a/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/BrwsrCntxtPrvdr.java Tue Apr 30 17:28:02 2013 +0200 +++ b/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/BrwsrCntxtPrvdr.java Wed May 01 07:20:06 2013 +0200 @@ -25,9 +25,15 @@ import org.apidesign.html.json.spi.ContextProvider; import org.openide.util.lookup.ServiceProvider; -/** +/** This is an implementation package - just + * include its JAR on classpath and use official {@link Context} API + * to access the functionality. + *

+ * Provides binding between models and + * Bck2Brwsr VM. + * Registers {@link ContextProvider}, so {@link ServiceLoader} can find it. * - * @author Jaroslav Tulach + * @author Jaroslav Tulach */ @ServiceProvider(service = ContextProvider.class) public final class BrwsrCntxtPrvdr implements ContextProvider { diff -r 93e8fc67b2b5 -r 0930803c77d2 ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/ConvertTypes.java --- a/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/ConvertTypes.java Tue Apr 30 17:28:02 2013 +0200 +++ b/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/ConvertTypes.java Wed May 01 07:20:06 2013 +0200 @@ -26,7 +26,7 @@ * * @author Jaroslav Tulach */ -public final class ConvertTypes { +final class ConvertTypes { ConvertTypes() { } diff -r 93e8fc67b2b5 -r 0930803c77d2 ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/KOList.java --- a/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/KOList.java Tue Apr 30 17:28:02 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -/** - * HTML via Java(tm) Language Bindings - * Copyright (C) 2013 Jaroslav Tulach - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. apidesign.org - * designates this particular file as subject to the - * "Classpath" exception as provided by apidesign.org - * in the License file that accompanied this code. - * - * You should have received a copy of the GNU General Public License - * along with this program. Look for COPYING file in the top folder. - * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException - */ -package org.apidesign.html.ko2brwsr; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import org.apidesign.bck2brwsr.core.JavaScriptOnly; - -/** - * - * @author Jaroslav Tulach - */ -public final class KOList extends ArrayList { - private final String name; - private final String[] deps; - private Knockout model; - private Runnable onchange; - - public KOList(String name, String... deps) { - this.name = name; - this.deps = deps; - } - - public void assign(Knockout model) { - if (this.model != model) { - this.model = model; - notifyChange(); - } - } - - public KOList onChange(Runnable r) { - if (this.onchange != null) { - throw new IllegalStateException(); - } - this.onchange = r; - return this; - } - - @Override - public boolean add(T e) { - boolean ret = super.add(e); - notifyChange(); - return ret; - } - - @Override - public boolean addAll(Collection c) { - boolean ret = super.addAll(c); - notifyChange(); - return ret; - } - - @Override - public boolean addAll(int index, Collection c) { - boolean ret = super.addAll(index, c); - notifyChange(); - return ret; - } - - @Override - public boolean remove(Object o) { - boolean ret = super.remove(o); - notifyChange(); - return ret; - } - - @Override - public void clear() { - super.clear(); - notifyChange(); - } - - @Override - public boolean removeAll(Collection c) { - boolean ret = super.removeAll(c); - notifyChange(); - return ret; - } - - @Override - public boolean retainAll(Collection c) { - boolean ret = super.retainAll(c); - notifyChange(); - return ret; - } - - @Override - public T set(int index, T element) { - T ret = super.set(index, element); - notifyChange(); - return ret; - } - - @Override - public void add(int index, T element) { - super.add(index, element); - notifyChange(); - } - - @Override - public T remove(int index) { - T ret = super.remove(index); - notifyChange(); - return ret; - } - - @Override - public String toString() { - Iterator it = iterator(); - if (!it.hasNext()) { - return "[]"; - } - String sep = ""; - StringBuilder sb = new StringBuilder(); - sb.append('['); - while (it.hasNext()) { - T t = it.next(); - sb.append(sep); - sb.append(ConvertTypes.toJSON(t)); - sep = ","; - } - sb.append(']'); - return sb.toString(); - } - - - @JavaScriptOnly(name = "koArray", value = "function() { return this.toArray___3Ljava_lang_Object_2(); }") - private static native int koArray(); - - private void notifyChange() { - Knockout m = model; - if (m != null) { - m.valueHasMutated(name); - for (String dependant : deps) { - m.valueHasMutated(dependant); - } - } - Runnable r = onchange; - if (r != null) { - r.run(); - } - } - - @Override - public KOList clone() { - KOList ko = (KOList)super.clone(); - ko.model = null; - return ko; - } - -} diff -r 93e8fc67b2b5 -r 0930803c77d2 ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/Knockout.java --- a/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/Knockout.java Tue Apr 30 17:28:02 2013 +0200 +++ b/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/Knockout.java Wed May 01 07:20:06 2013 +0200 @@ -25,12 +25,12 @@ import org.apidesign.bck2brwsr.core.ExtraJavaScript; import org.apidesign.bck2brwsr.core.JavaScriptBody; -/** Provides binding between models and +/** Provides binding between models and bck2brwsr VM. * * @author Jaroslav Tulach */ @ExtraJavaScript(resource = "/org/apidesign/bck2brwsr/htmlpage/knockout-2.2.1.js") -public class Knockout { +final class Knockout { /** used by tests */ static Knockout next; private final Object model;