diff -r 236501ac78c6 api.knockout/apichanges.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/apichanges.xml Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,98 @@ + + + + + + + + + + + Knockout Integration API + + + + + + + + Introduced + + + + + +

+ Initial version of Knockout Integration API published. +

+
+ +
+
+ + + + Change History for the NetBeans Knockout Integration API + + + + + + +

Introduction

+ +

This document lists changes made to the Knockout Integration API.

+ + +
+ + +

@FOOTER@

+ + +
+ +
diff -r 236501ac78c6 api.knockout/arch.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/arch.xml Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,1115 @@ + + +]> + + + + &api-questions; + + + + +

+ Java model class + to describe JSON-like Knockout bindings and register + a provider + used by the editor infrastructure to query for the model. +

+
+ + + + + +

+ There are some unit tests. The integration with editor is then tested + manually. +

+
+ + + + + +

+ Let's offer this API for 8.1 release. +

+
+ + + + + + +

+This is the code to register a sample provider: +

+
+{@code @}ServiceProvider(service = BindingsProvider.class)
+public class SampleBindingsProvider implements {@link org.netbeans.spi.knockout.BindingsProvider} {
+    {@code @Override}
+    public void findBindings(FileObject htmlFile, Response r) {
+        Bindings tweet = Bindings.create("Tweet").
+                stringProperty("from_user", false).
+                intProperty("from_user_id", false);
+
+        Bindings tweeters = Bindings.create("Tweeters").
+                stringProperty("name", false).
+                stringProperty("userNames", true);
+
+        Bindings twitterClient = Bindings.create("TwitterClient");
+        twitterClient.
+                stringProperty("activeTweetersName", false).
+                stringProperty("activeTweeters", true).
+                stringProperty("userNameToAdd", false).
+                booleanProperty("loading", false).
+                modelProperty("currentTweets", tweet, true).
+                modelProperty("savedLists", tweeters, true);
+
+        r.applyBindings(twitterClient);
+    }
+}
+
+ +

+This sample has been used when testing the module. +

+
+
+ + + + + + + API for registering additional providers + that help the HTML editor to offer better code completion for certain HTML + files based on the produced description of a + JSON-like structure. + + + + + + + + + + + + + + +

+ XXX no answer for compat-deprecation +

+
+ + + + + +

+ XXX no answer for compat-i18n +

+
+ + + + + +

+ XXX no answer for compat-standards +

+
+ + + + + +

+ XXX no answer for compat-version +

+
+ + + + + +

+ XXX no answer for dep-jre +

+
+ + + + + +

+ XXX no answer for dep-jrejdk +

+
+ + + + + + + + + + + + +

+ XXX no answer for dep-non-nb +

+
+ + + + + +

+ XXX no answer for dep-platform +

+
+ + + + + +

+ XXX no answer for deploy-dependencies +

+
+ + + + + +

+ XXX no answer for deploy-jar +

+
+ + + + + +

+ XXX no answer for deploy-nbm +

+
+ + + + + +

+ XXX no answer for deploy-packages +

+
+ + + + + +

+ XXX no answer for deploy-shared +

+
+ + + + + +

+ XXX no answer for exec-ant-tasks +

+
+ + + + + +

+ XXX no answer for exec-classloader +

+
+ + + + + +

+ XXX no answer for exec-component +

+
+ + + + + +

+ XXX no answer for exec-introspection +

+
+ + + + + +

+ XXX no answer for exec-privateaccess +

+
+ + + + + +

+ XXX no answer for exec-process +

+
+ + + + + +

+ XXX no answer for exec-property +

+
+ + + + + +

+ XXX no answer for exec-reflection +

+
+ + + + + +

+ XXX no answer for exec-threading +

+
+ + + + + +

+ XXX no answer for format-clipboard +

+
+ + + + + +

+ XXX no answer for format-dnd +

+
+ + + + + +

+ XXX no answer for format-types +

+
+ + + + + +

+ XXX no answer for lookup-lookup +

+
+ + + + + +

+ XXX no answer for lookup-register +

+
+ + + + + +

+ XXX no answer for lookup-remove +

+
+ + + + + +

+ XXX no answer for perf-exit +

+
+ + + + + +

+ XXX no answer for perf-huge_dialogs +

+
+ + + + + +

+ XXX no answer for perf-limit +

+
+ + + + + +

+ XXX no answer for perf-mem +

+
+ + + + + +

+ XXX no answer for perf-menus +

+
+ + + + + +

+ XXX no answer for perf-progress +

+
+ + + + + +

+ XXX no answer for perf-scale +

+
+ + + + + +

+ XXX no answer for perf-spi +

+
+ + + + + +

+ XXX no answer for perf-startup +

+
+ + + + + +

+ XXX no answer for perf-wakeup +

+
+ + + + + +

+ XXX no answer for resources-file +

+
+ + + + + +

+ XXX no answer for resources-layer +

+
+ + + + + +

+ XXX no answer for resources-mask +

+
+ + + + + +

+ XXX no answer for resources-preferences +

+
+ + + + + +

+ XXX no answer for resources-read +

+
+ + + + + +

+ XXX no answer for security-grant +

+
+ + + + + +

+ XXX no answer for security-policy +

+
+ +
diff -r 236501ac78c6 api.knockout/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/build.xml Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,5 @@ + + + Builds, tests, and runs the project org.netbeans.api.knockout + + diff -r 236501ac78c6 api.knockout/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/manifest.mf Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: org.netbeans.api.knockout +OpenIDE-Module-Localizing-Bundle: org/netbeans/spi/knockout/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r 236501ac78c6 api.knockout/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/nbproject/project.properties Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,4 @@ +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial +javadoc.arch=${basedir}/arch.xml +javadoc.apichanges=${basedir}/apichanges.xml diff -r 236501ac78c6 api.knockout/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/nbproject/project.xml Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,67 @@ + + + org.netbeans.modules.apisupport.project + + + org.netbeans.api.knockout + + + org.netbeans.modules.editor.mimelookup + + + + 1 + 1.32 + + + + org.netbeans.modules.lexer + + + + 2 + 1.52 + + + + org.netbeans.modules.parsing.api + + + + 1 + 9.0 + + + + org.openide.filesystems + + + + 9.0 + + + + org.openide.util.lookup + + + + 8.21 + + + + + + unit + + org.netbeans.libs.testng + + + + + + org.netbeans.modules.knockout.impl + org.netbeans.spi.knockout + + + + diff -r 236501ac78c6 api.knockout/src/org/netbeans/spi/knockout/Bindings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/src/org/netbeans/spi/knockout/Bindings.java Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,218 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.spi.knockout; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.netbeans.spi.knockout.BindingsProvider.Response; +import org.openide.filesystems.FileObject; +import org.openide.util.Lookup; + +/** + * Allows structural description of a ko.applyBindings parameter. + * Register as {@link BindingsProvider}. When called build description of JSON + * types using methods like {@link #stringProperty(java.lang.String, boolean)} + * and then pass the result into + * {@link Response#applyBindings(org.netbeans.spi.knockout.Bindings)} method. + * + * @author Jaroslav Tulach + */ +public final class Bindings { + + private final String name; + private final List subBindings = new ArrayList<>(); + private final List props = new ArrayList<>(); + + private Bindings(String name) { + this.name = name; + } + + /** + * Defines new variable with provided name and assigns a JSON object into + * it. The created instance is a builder - continue calling its various + * builder methods like {@link #intProperty(java.lang.String, boolean)}. + * + * @param name name of variable (must be valid JavaScript identifier) + * @return empty JSON object ready to be filled using + * {@link #doubleProperty(java.lang.String, boolean)}, and other methods + */ + public static Bindings create(String name) { + return new Bindings(name); + } + + /** + * Generates a boolean property (with value true) into the JSON + * class. + * + * @param name name of variable (must be valid JavaScript identifier) + * @param array should this property be an array of just a single value + * @return this object + */ + public final Bindings booleanProperty(String name, boolean array) { + addProp(name, array, "true"); + return this; + } + + /** + * Generates a string property (with value '') into the JSON + * class. + * + * @param name name of variable (must be valid JavaScript identifier) + * @param array should this property be an array of just a single value + * @return this object + */ + public final Bindings stringProperty(String name, boolean array) { + addProp(name, array, "''"); + return this; + } + + /** + * Generates a integer property (with value 0) into the JSON + * class. + * + * @param name name of variable (must be valid JavaScript identifier) + * @param array should this property be an array of just a single value + * @return this object + */ + public final Bindings intProperty(String name, boolean array) { + addProp(name, array, "0"); + return this; + } + + /** + * Generates a floating point property (with value 0.1) into + * the JSON class. + * + * @param name name of variable (must be valid JavaScript identifier) + * @param array should this property be an array of just a single value + * @return this object + */ + public final Bindings doubleProperty(String name, boolean array) { + addProp(name, array, "0.1"); + return this; + } + + /** + * Generates complex subtype based on another {@link Bindings} class. + * + * @param name name of variable (must be valid JavaScript identifier) + * @param binding another description of a JSON like object + * @param array should this property be an array of just a single value + * @return this object + */ + public final Bindings modelProperty(String name, Bindings binding, boolean array) { + subBindings.add(binding); + addProp(name, array, binding.name); + return this; + } + + final String generate() { + StringBuilder sb = new StringBuilder(); + //sb.append("(function() {\n"); + HashSet visited = new HashSet<>(); + LinkedHashSet lhs = new LinkedHashSet<>(); + walkBindings(visited, lhs); + for (Bindings b : lhs) { + b.generate(sb); + } + sb.append(" ko.applyBindings(").append(name).append(");\n"); + //sb.append("}());"); + return sb.toString(); + } + + private void generate(StringBuilder sb) { + sb.append("var ").append(name).append(" = {"); + String sep = "\n"; + for (String s : props) { + sb.append(sep).append(" ").append(s); + sep = ",\n"; + } + sb.append("\n};\n"); + } + + private void addProp(String name, boolean array, String value) { + if (array) { + value = "[ " + value + " ]"; + } + if (name.contains("\"")) { + throw new IllegalStateException("Wrong name " + name); + } + props.add('\"' + name + "\" : " + value); + } + + private void walkBindings(Set visited, Set collect) { + if (!visited.add(this)) { + return; + } + for (Bindings b : subBindings) { + b.walkBindings(visited, collect); + } + collect.add(this); + } + + /** Queries registered providers for additional knockout.js bindings for + * given file. Generates a JavaScript code describing JSON-like structures + * used by knockout.js that can be used to enhance code-completion for + * HTML files using knockout.js bindings. + * + * @param htmlFile the HTML file opened in editor + * @param versionOfFormat the format of the output. Use 1 for now. + * @return either null if no provider or format has been + * found for given file or a JavaScript code formated accordingly + */ + public static String findBindings(FileObject htmlFile, int versionOfFormat) { + if (versionOfFormat != 1) { + return null; + } + Response r = new Response(); + for (BindingsProvider p : Lookup.getDefault().lookupAll(BindingsProvider.class)) { + p.findBindings(htmlFile, r); + if (r.bindings != null) { + return r.bindings.generate(); + } + } + return null; + } +} diff -r 236501ac78c6 api.knockout/src/org/netbeans/spi/knockout/BindingsProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/src/org/netbeans/spi/knockout/BindingsProvider.java Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,103 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.spi.knockout; + +import org.openide.filesystems.FileObject; +import org.openide.util.lookup.ServiceProvider; + +/** A provider that knows more about structure of Knockout bindings + * in an HTML page. + * Providers should be registered by {@link ServiceProvider} annotation + * so they can be found for a particular HTML file. Their {@link #findBindings(org.openide.filesystems.FileObject, org.netbeans.spi.knockout.BindingsProvider.Response) findBindings} + * method is called when a knockout code completion is about to be shown + * in the HTML editor and then can generate a JSON like description of + * the structure of knockout context via {@link Bindings} methods. + * + * @author Jaroslav Tulach + */ +public interface BindingsProvider { + + /** Called when additional completion is requested for a particular file. + * + * @param htmlFile the HTML file opened in editor + * @param r use this object to set a final response before the + * bindings method is finished + */ + public void findBindings(FileObject htmlFile, Response r); + + /** Methods for {@link BindingsProvider}s to provide a response + * when {@link BindingsProvider#findBindings(org.openide.filesystems.FileObject, org.netbeans.spi.knockout.BindingsProvider.Response) queries} + * about a particular HTML file. + */ + public static final class Response { + + Bindings bindings; + String targetId; + + Response() { + } + + /** Used by a {@link BindingsProvider provider} to tell + * the editing infrastructure to expose a JSON like structure + * in code completion. + * + * @param bindings Java model of JSON-like structure + */ + public void applyBindings(Bindings bindings) { + this.bindings = bindings; + this.targetId = null; + } + + /** Used by a {@link BindingsProvider provider} to tell + * the editing infrastructure to expose a JSON like structure + * in code completion. + * + * @param bindings Java model of JSON-like structure + * @param targetId an id of an element on the page to identify + * a subtree where these bindings will be applied to + */ + public void applyBindings(Bindings bindings, String targetId) { + this.bindings = bindings; + this.targetId = targetId; + } + } +} diff -r 236501ac78c6 api.knockout/src/org/netbeans/spi/knockout/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/src/org/netbeans/spi/knockout/Bundle.properties Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=Knockout Model Provider API diff -r 236501ac78c6 api.knockout/src/org/netbeans/spi/knockout/package.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/src/org/netbeans/spi/knockout/package.html Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,50 @@ + + + + +
Java {@link org.netbeans.spi.knockout.Bindings model class} to describe JSON-like Knockout bindings and + register {@link org.netbeans.spi.knockout.BindingsProvider a provider} used by the editor infrastructure + to query for the {@link org.netbeans.spi.knockout.Bindings model}. +
+ + diff -r 236501ac78c6 api.knockout/test/unit/src/org/netbeans/spi/knockout/BindingsNGTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.knockout/test/unit/src/org/netbeans/spi/knockout/BindingsNGTest.java Fri Dec 19 11:53:20 2014 +0100 @@ -0,0 +1,104 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.spi.knockout; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * + * @author Jaroslav Tulach + */ +public class BindingsNGTest { + private ScriptEngine eng; + + public BindingsNGTest() { + } + + @BeforeMethod public void initEngine() { + ScriptEngineManager sem = new ScriptEngineManager(); + eng = sem.getEngineByMimeType("text/javascript"); + } + + @Test public void generateTwitterModel() throws Exception { + Bindings tweet = Bindings.create("Tweet"). + stringProperty("from_user", false). + intProperty("from_user_id", false); + + Bindings tweeters = Bindings.create("Tweeters"). + stringProperty("name", false). + stringProperty("userNames", true); + + Bindings twitterClient = Bindings.create("TwitterClient"); + twitterClient. + stringProperty("activeTweetersName", false). + stringProperty("activeTweeters", true). + stringProperty("userNameToAdd", false). + booleanProperty("loading", false). + modelProperty("currentTweets", tweet, true). + modelProperty("savedLists", tweeters, true); + + String txt = twitterClient.generate(); + + assertValidJS(txt); + + assertNotNull(eng.eval("ko")); + assertNotNull(eng.eval("ko.value")); + assertEquals(eng.eval("ko.value.loading"), true, "Boolean values are set to true"); + assertEquals(eng.eval("ko.value.currentTweets[0].from_user_id"), 0d, "Boolean values are set to true"); + } + + private void assertValidJS(String txt) { + assertNotNull(txt, "We have some script"); + try { + eng.eval("ko = {}; ko.applyBindings = function(val) { ko.value = val; }"); + eng.eval(txt); + } catch (ScriptException ex) { + throw new AssertionError(txt, ex); + } + } + +} \ No newline at end of file diff -r 236501ac78c6 html.editor/manifest.mf --- a/html.editor/manifest.mf Thu Dec 18 13:14:28 2014 +0100 +++ b/html.editor/manifest.mf Fri Dec 19 11:53:20 2014 +0100 @@ -2,5 +2,5 @@ OpenIDE-Module: org.netbeans.modules.html.editor/2 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/html/editor/resources/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/html/editor/resources/layer.xml -OpenIDE-Module-Specification-Version: 2.51 +OpenIDE-Module-Specification-Version: 2.52 AutoUpdate-Show-In-Client: false diff -r 236501ac78c6 html.editor/nbproject/project.xml --- a/html.editor/nbproject/project.xml Thu Dec 18 13:14:28 2014 +0100 +++ b/html.editor/nbproject/project.xml Fri Dec 19 11:53:20 2014 +0100 @@ -541,6 +541,7 @@ com.ext4yii.editor nl.truesoftware.blendsdk + org.netbeans.api.knockout org.netbeans.modules.css.visual org.netbeans.modules.groovy.gsp org.netbeans.modules.html.angular @@ -549,8 +550,8 @@ org.netbeans.modules.html.ojet org.netbeans.modules.javascript.editing org.netbeans.modules.javascript2.editor + org.netbeans.modules.javascript2.nodejs org.netbeans.modules.javascript2.requirejs - org.netbeans.modules.javascript2.nodejs org.netbeans.modules.php.latte org.netbeans.modules.ruby.rhtml org.netbeans.modules.web.clientproject diff -r 236501ac78c6 html.knockout/nbproject/project.xml --- a/html.knockout/nbproject/project.xml Thu Dec 18 13:14:28 2014 +0100 +++ b/html.knockout/nbproject/project.xml Fri Dec 19 11:53:20 2014 +0100 @@ -15,6 +15,14 @@ + org.netbeans.api.knockout + + + + 1.0 + + + org.netbeans.api.progress diff -r 236501ac78c6 html.knockout/src/org/netbeans/modules/html/knockout/KOJsEmbeddingProviderPlugin.java --- a/html.knockout/src/org/netbeans/modules/html/knockout/KOJsEmbeddingProviderPlugin.java Thu Dec 18 13:14:28 2014 +0100 +++ b/html.knockout/src/org/netbeans/modules/html/knockout/KOJsEmbeddingProviderPlugin.java Fri Dec 19 11:53:20 2014 +0100 @@ -67,6 +67,8 @@ import org.netbeans.modules.javascript2.editor.api.lexer.JsTokenId; import org.netbeans.modules.parsing.api.Embedding; import org.netbeans.modules.parsing.api.Snapshot; +import org.netbeans.spi.knockout.Bindings; +import org.openide.filesystems.FileObject; import org.openide.util.Pair; /** @@ -100,6 +102,8 @@ private KODataBindContext currentTemplateContext; + private String generatedSource; + public KOJsEmbeddingProviderPlugin() { JS_LANGUAGE = Language.find(KOUtils.JAVASCRIPT_MIMETYPE); //NOI18N this.stack = new LinkedList(); @@ -114,6 +118,11 @@ if(!KOModel.getModel(parserResult).containsKnockout()) { return false; } + + FileObject fo = snapshot.getSource().getFileObject(); + if (fo != null) { + generatedSource = Bindings.findBindings(fo, 1); + } return true; } @@ -341,6 +350,10 @@ StringBuilder sb = new StringBuilder(); sb.append("(function(){\n"); // NOI18N + if (generatedSource != null) { + sb.append(generatedSource).append("\n"); + } + // for now this is actually just a placeholder sb.append("var $element;\n"); diff -r 236501ac78c6 nbbuild/build.properties --- a/nbbuild/build.properties Thu Dec 18 13:14:28 2014 +0100 +++ b/nbbuild/build.properties Fri Dec 19 11:53:20 2014 +0100 @@ -102,6 +102,7 @@ api.htmlui,\ api.intent,\ api.io,\ + api.knockout,\ api.maven,\ api.templates,\ autoupdate.services,\ diff -r 236501ac78c6 nbbuild/cluster.properties --- a/nbbuild/cluster.properties Thu Dec 18 13:14:28 2014 +0100 +++ b/nbbuild/cluster.properties Fri Dec 19 11:53:20 2014 +0100 @@ -297,6 +297,7 @@ api.debugger,\ api.java.classpath,\ api.java.classpath.nb,\ + api.knockout,\ api.xml,\ api.xml.ui,\ bugtracking,\ diff -r 236501ac78c6 nbbuild/javadoctools/links.xml --- a/nbbuild/javadoctools/links.xml Thu Dec 18 13:14:28 2014 +0100 +++ b/nbbuild/javadoctools/links.xml Fri Dec 19 11:53:20 2014 +0100 @@ -244,3 +244,4 @@ + diff -r 236501ac78c6 nbbuild/javadoctools/properties.xml --- a/nbbuild/javadoctools/properties.xml Thu Dec 18 13:14:28 2014 +0100 +++ b/nbbuild/javadoctools/properties.xml Fri Dec 19 11:53:20 2014 +0100 @@ -243,3 +243,4 @@ + diff -r 236501ac78c6 nbbuild/javadoctools/replaces.xml --- a/nbbuild/javadoctools/replaces.xml Thu Dec 18 13:14:28 2014 +0100 +++ b/nbbuild/javadoctools/replaces.xml Fri Dec 19 11:53:20 2014 +0100 @@ -243,3 +243,4 @@ +