You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jt...@apache.org on 2017/09/03 12:48:57 UTC
[24/24] incubator-netbeans-html4j git commit: [INFRA-15006] Initial
donation of HTML/Java NetBeans API. Equivalent to the content of
html4j-donation-review.zip donated as part of ApacheNetBeansDonation1.zip
with SHA256 being 7f2ca0f61953a190613c9a0fbcc1b
[INFRA-15006] Initial donation of HTML/Java NetBeans API.
Equivalent to the content of html4j-donation-review.zip donated as part of ApacheNetBeansDonation1.zip with SHA256 being 7f2ca0f61953a190613c9a0fbcc1b034084b04a4d55d23c02cefffc354e7c24a.
Equivalent to changeset 929563230c07 of the original http://hg.netbeans.org/html4j/ NetBeans Hg repository.
Equivalent to commit d029b8e in the Emilian Bold Git conversion https://github.com/emilianbold/netbeans-html4j/ of the above Hg repository.
Project: http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/commit/226089a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/tree/226089a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/diff/226089a5
Branch: refs/heads/master
Commit: 226089a5a86d173bcc8acec247bd9def277e1459
Parents:
Author: Jaroslav Tulach <ja...@apidesign.org>
Authored: Sun Sep 3 14:47:24 2017 +0200
Committer: Jaroslav Tulach <ja...@apidesign.org>
Committed: Sun Sep 3 14:47:24 2017 +0200
----------------------------------------------------------------------
COPYING | 40 +
boot-agent-test/pom.xml | 105 +
.../html/bootagent/DynamicClassLoaderTest.java | 126 +
.../html/bootagent/JavaScriptBodyTst.java | 63 +
.../java/org/netbeans/html/bootagent/KOFx.java | 125 +
.../org/netbeans/html/bootagent/empty.html | 55 +
boot-fx/pom.xml | 115 +
.../java/net/java/html/boot/fx/FXBrowsers.java | 293 +++
.../java/net/java/html/boot/fx/package.html | 51 +
.../html/boot/fx/AbstractFXPresenter.java | 433 ++++
.../java/org/netbeans/html/boot/fx/Dbgr.java | 87 +
.../java/org/netbeans/html/boot/fx/FXBrwsr.java | 427 ++++
.../org/netbeans/html/boot/fx/FXConsole.java | 84 +
.../org/netbeans/html/boot/fx/FXInspect.java | 134 +
.../org/netbeans/html/boot/fx/FXPresenter.java | 88 +
.../org/netbeans/html/boot/fx/FXToolbar.java | 437 ++++
.../org/netbeans/html/boot/fx/WatchDir.java | 117 +
.../org/netbeans/html/boot/fx/Bundle.properties | 54 +
.../org/netbeans/html/boot/fx/desktop.png | Bin 0 -> 1093 bytes
.../netbeans/html/boot/fx/handheldLandscape.png | Bin 0 -> 1100 bytes
.../netbeans/html/boot/fx/handheldPortrait.png | Bin 0 -> 1111 bytes
.../org/netbeans/html/boot/fx/netbook.png | Bin 0 -> 1101 bytes
.../org/netbeans/html/boot/fx/selectionMode.png | Bin 0 -> 1078 bytes
.../org/netbeans/html/boot/fx/sizeToFit.png | Bin 0 -> 1093 bytes
.../netbeans/html/boot/fx/tabletLandscape.png | Bin 0 -> 1076 bytes
.../netbeans/html/boot/fx/tabletPortrait.png | Bin 0 -> 1067 bytes
.../org/netbeans/html/boot/fx/widescreen.png | Bin 0 -> 1114 bytes
.../html/boot/fx/FXBrowsersOnResourceTest.java | 209 ++
.../net/java/html/boot/fx/FXBrowsersTest.java | 253 ++
.../org/netbeans/html/boot/fx/FXBrwsrTest.java | 84 +
.../netbeans/html/boot/fx/FXJavaScriptTest.java | 124 +
.../netbeans/html/boot/fx/FXPresenterTst.java | 103 +
.../netbeans/html/boot/fx/FxJavaScriptTst.java | 55 +
.../java/org/netbeans/html/boot/fx/KOFx.java | 125 +
.../org/netbeans/html/boot/fx/ReloadTest.java | 157 ++
.../netbeans/html/boot/fx/TestingProvider.java | 65 +
.../org/netbeans/html/boot/fx/TitleTest.java | 146 ++
.../test/java/org/sample/app/pkg/SampleApp.java | 62 +
.../test/resources/net/java/html/boot/fx/wnd.js | 49 +
.../org/netbeans/html/boot/fx/empty.html | 55 +
boot-script/pom.xml | 152 ++
.../java/html/boot/script/ScriptPresenter.java | 443 ++++
.../java/net/java/html/boot/script/Scripts.java | 119 +
.../java/net/java/html/boot/script/package.html | 51 +
.../html/boot/script/Jsr223JavaScriptTest.java | 117 +
.../html/boot/script/Jsr223JavaScriptTst.java | 55 +
.../net/java/html/boot/script/SingleCase.java | 127 +
.../java/html/boot/script/ko4j/DynamicHTTP.java | 261 ++
.../net/java/html/boot/script/ko4j/KOCase.java | 140 ++
.../boot/script/ko4j/KnockoutEnvJSTest.java | 266 ++
.../net/java/html/boot/script/ko4j/test.html | 56 +
boot-truffle/empty.sigtest | 21 +
boot-truffle/pom.xml | 209 ++
.../net/java/html/boot/truffle/IsArrayNode.java | 68 +
.../net/java/html/boot/truffle/IsNullNode.java | 68 +
.../net/java/html/boot/truffle/JavaArray.java | 102 +
.../net/java/html/boot/truffle/JavaObject.java | 82 +
.../net/java/html/boot/truffle/JavaValue.java | 91 +
.../html/boot/truffle/TrufflePresenter.java | 293 +++
.../html/boot/truffle/TrufflePresenters.java | 66 +
.../net/java/html/boot/truffle/package.html | 51 +
.../html/boot/truffle/JsArrayTruffleTest.java | 140 ++
.../net/java/html/boot/truffle/SingleCase.java | 127 +
.../boot/truffle/TruffleJavaScriptTest.java | 164 ++
boot/pom.xml | 106 +
.../java/net/java/html/boot/BrowserBuilder.java | 519 ++++
.../main/java/net/java/html/boot/package.html | 54 +
.../java/net/java/html/js/JavaScriptBody.java | 152 ++
.../net/java/html/js/JavaScriptResource.java | 70 +
.../src/main/java/net/java/html/js/package.html | 483 ++++
.../netbeans/html/boot/impl/FindResources.java | 56 +
.../org/netbeans/html/boot/impl/FnContext.java | 165 ++
.../org/netbeans/html/boot/impl/FnUtils.java | 717 ++++++
.../html/boot/impl/JavaScriptProcesor.java | 528 ++++
.../org/netbeans/html/boot/impl/JsAgent.java | 75 +
.../org/netbeans/html/boot/impl/JsCallback.java | 160 ++
.../netbeans/html/boot/impl/JsClassLoader.java | 57 +
.../org/netbeans/html/boot/impl/JsPkgCache.java | 132 +
.../java/org/netbeans/html/boot/spi/Fn.java | 388 +++
.../org/netbeans/html/boot/spi/package.html | 54 +
.../resources/net/java/html/boot/html4j.txt | 43 +
.../net/java/html/boot/BrowserBuilderTest.java | 134 +
.../org/netbeans/html/boot/impl/Arithm.java | 53 +
.../org/netbeans/html/boot/impl/Compile.java | 307 +++
.../html/boot/impl/CountFnCreationTest.java | 123 +
.../org/netbeans/html/boot/impl/FnTest.java | 186 ++
.../html/boot/impl/JavaScriptProcesorTest.java | 167 ++
.../netbeans/html/boot/impl/JsCallbackTest.java | 86 +
.../html/boot/impl/JsClassLoaderBase.java | 285 +++
.../html/boot/impl/JsClassLoaderTest.java | 161 ++
.../org/netbeans/html/boot/impl/JsMethods.java | 157 ++
.../netbeans/html/boot/impl/KeepAliveTest.java | 113 +
.../org/netbeans/html/boot/impl/Object.java | 49 +
.../org/netbeans/html/boot/impl/empty.js | 42 +
.../org/netbeans/html/boot/impl/jsmethods.js | 43 +
context/pom.xml | 91 +
.../src/main/java/net/java/html/BrwsrCtx.java | 192 ++
.../src/main/java/net/java/html/package.html | 49 +
.../netbeans/html/context/impl/CtxAccssr.java | 71 +
.../org/netbeans/html/context/impl/CtxImpl.java | 139 ++
.../org/netbeans/html/context/spi/Contexts.java | 244 ++
.../org/netbeans/html/context/spi/package.html | 50 +
.../test/java/net/java/html/BrwsrCtxTest.java | 120 +
.../netbeans/html/context/spi/ContextsTest.java | 115 +
equinox-agentclass-hook/pom.xml | 86 +
.../html/equinox/agentclass/AgentHook.java | 164 ++
.../equinox/agentclass/NbInstrumentation.java | 213 ++
.../main/resources/hookconfigurators.properties | 44 +
geo/pom.xml | 94 +
.../main/java/net/java/html/geo/OnLocation.java | 96 +
.../main/java/net/java/html/geo/Position.java | 383 +++
.../net/java/html/geo/doc-files/GeoDuke.png | Bin 0 -> 242819 bytes
.../main/java/net/java/html/geo/package.html | 74 +
.../org/netbeans/html/geo/impl/Accessor.java | 76 +
.../netbeans/html/geo/impl/GeoProcessor.java | 290 +++
.../netbeans/html/geo/impl/JsGLProvider.java | 154 ++
.../org/netbeans/html/geo/spi/CoordImpl.java | 87 +
.../org/netbeans/html/geo/spi/GLProvider.java | 306 +++
.../java/org/netbeans/html/geo/spi/package.html | 59 +
.../java/net/java/html/geo/OnLocationTest.java | 137 ++
.../org/netbeans/html/geo/impl/Compile.java | 286 +++
.../html/geo/impl/GeoProcessorTest.java | 114 +
.../html/geo/impl/JsGLProviderTest.java | 76 +
.../netbeans/html/geo/spi/CoordImplTest.java | 106 +
html4j-maven-plugin/pom.xml | 119 +
.../html/mojo/ProcessJsAnnotationsMojo.java | 223 ++
json-tck/pom.xml | 116 +
.../java/net/java/html/js/tests/Bodies.java | 254 ++
.../java/net/java/html/js/tests/Factorial.java | 62 +
.../java/net/java/html/js/tests/GCBodyTest.java | 178 ++
.../net/java/html/js/tests/Global2String.java | 52 +
.../net/java/html/js/tests/GlobalString.java | 52 +
.../java/html/js/tests/JavaScriptBodyTest.java | 548 +++++
.../main/java/net/java/html/js/tests/Later.java | 65 +
.../java/net/java/html/js/tests/Receiver.java | 80 +
.../main/java/net/java/html/js/tests/Sum.java | 81 +
.../java/html/json/tests/ConvertTypesTest.java | 322 +++
.../java/html/json/tests/GCKnockoutTest.java | 139 ++
.../java/net/java/html/json/tests/JSONTest.java | 637 +++++
.../net/java/html/json/tests/KnockoutTest.java | 1001 ++++++++
.../net/java/html/json/tests/MinesTest.java | 356 +++
.../java/html/json/tests/OperationsTest.java | 96 +
.../net/java/html/json/tests/PairModel.java | 80 +
.../net/java/html/json/tests/PersonImpl.java | 100 +
.../main/java/net/java/html/json/tests/Sex.java | 51 +
.../java/net/java/html/json/tests/Utils.java | 225 ++
.../net/java/html/json/tests/WebSocketTest.java | 179 ++
.../netbeans/html/json/tck/JavaScriptTCK.java | 73 +
.../java/org/netbeans/html/json/tck/KOTest.java | 60 +
.../org/netbeans/html/json/tck/KnockoutTCK.java | 144 ++
.../resources/net/java/html/js/tests/global.js | 44 +
.../resources/net/java/html/js/tests/global2.js | 44 +
.../org/netbeans/html/json/tck/package.html | 56 +
.../java/net/java/html/js/tests/BodiesTest.java | 83 +
json/pom.xml | 115 +
.../net/java/html/json/ComputedProperty.java | 105 +
.../main/java/net/java/html/json/FakeModel.java | 122 +
.../main/java/net/java/html/json/Function.java | 122 +
.../src/main/java/net/java/html/json/Model.java | 356 +++
.../java/net/java/html/json/ModelOperation.java | 100 +
.../main/java/net/java/html/json/Models.java | 191 ++
.../net/java/html/json/OnPropertyChange.java | 100 +
.../main/java/net/java/html/json/OnReceive.java | 204 ++
.../main/java/net/java/html/json/Property.java | 98 +
.../net/java/html/json/doc-files/DukeHTML.png | Bin 0 -> 70129 bytes
.../net/java/html/json/doc-files/html4j.png | Bin 0 -> 558910 bytes
.../java/html/json/doc-files/websockets.html | 185 ++
.../main/java/net/java/html/json/package.html | 118 +
.../org/netbeans/html/json/impl/Bindings.java | 133 +
.../java/org/netbeans/html/json/impl/JSON.java | 533 ++++
.../org/netbeans/html/json/impl/JSONList.java | 257 ++
.../netbeans/html/json/impl/ModelProcessor.java | 2286 ++++++++++++++++++
.../html/json/impl/PropertyBindingAccessor.java | 109 +
.../org/netbeans/html/json/impl/RcvrJSON.java | 136 ++
.../org/netbeans/html/json/impl/Transitive.java | 60 +
.../netbeans/html/json/spi/FunctionBinding.java | 162 ++
.../org/netbeans/html/json/spi/JSONCall.java | 152 ++
.../org/netbeans/html/json/spi/Observers.java | 233 ++
.../netbeans/html/json/spi/PropertyBinding.java | 236 ++
.../java/org/netbeans/html/json/spi/Proto.java | 953 ++++++++
.../org/netbeans/html/json/spi/Technology.java | 216 ++
.../org/netbeans/html/json/spi/Transfer.java | 96 +
.../org/netbeans/html/json/spi/WSTransfer.java | 92 +
.../org/netbeans/html/json/spi/package.html | 51 +
.../netbeans/html/json/impl/Bundle.properties | 97 +
.../org/netbeans/html/json/spi/package.html | 59 +
.../java/net/java/html/json/AdressTest.java | 59 +
.../test/java/net/java/html/json/BoardTest.java | 83 +
.../net/java/html/json/BooleanArrayTest.java | 80 +
.../test/java/net/java/html/json/Compile.java | 311 +++
.../java/net/java/html/json/KeywordsTest.java | 99 +
.../java/html/json/MapModelNotMutableTest.java | 227 ++
.../java/net/java/html/json/MapModelTest.java | 521 ++++
.../net/java/html/json/ModelProcessorTest.java | 823 +++++++
.../test/java/net/java/html/json/ModelTest.java | 506 ++++
.../java/net/java/html/json/ModelsTest.java | 72 +
.../java/net/java/html/json/OperationTest.java | 125 +
.../java/net/java/html/json/PersonImpl.java | 135 ++
.../net/java/html/json/PrimitiveArrayTest.java | 80 +
json/src/test/java/net/java/html/json/Sex.java | 51 +
.../test/java/net/java/html/json/TypesTest.java | 145 ++
.../java/net/java/html/json/UnderscoreTest.java | 67 +
.../net/java/html/json/WebSocketCallTest.java | 56 +
.../net/java/html/json/sub/StreetCntrl.java | 53 +
.../netbeans/html/json/impl/BuilderTest.java | 117 +
.../html/json/impl/ConstructorTest.java | 80 +
.../netbeans/html/json/impl/DeepChangeTest.java | 617 +++++
.../netbeans/html/json/impl/EmployeeImpl.java | 119 +
.../netbeans/html/json/impl/EmployerTest.java | 65 +
.../netbeans/html/json/impl/InfinityTest.java | 151 ++
.../netbeans/html/json/impl/JSONListTest.java | 236 ++
.../org/netbeans/html/json/impl/JSONTest.java | 84 +
.../html/json/impl/NoPropertiesTest.java | 55 +
.../netbeans/html/json/impl/OnReceiveTest.java | 180 ++
.../html/json/impl/ParallelChangeTest.java | 199 ++
.../org/netbeans/html/json/impl/ToDoTest.java | 132 +
ko-felix-test/pom.xml | 184 ++
.../ko/felix/test/KnockoutFelixTCKImpl.java | 283 +++
.../html/ko/felix/test/DynamicHTTP.java | 261 ++
.../org/netbeans/html/ko/felix/test/KOFx.java | 132 +
.../ko/felix/test/KnockoutFelixAriesIT.java | 258 ++
.../html/ko/felix/test/KnockoutFelixIT.java | 253 ++
.../org/netbeans/html/ko/felix/test/test.html | 56 +
ko-osgi-test/pom.xml | 181 ++
.../ko/osgi/test/KnockoutEquinoxTCKImpl.java | 222 ++
.../netbeans/html/ko/osgi/test/DynamicHTTP.java | 261 ++
.../org/netbeans/html/ko/osgi/test/KOFx.java | 130 +
.../html/ko/osgi/test/KnockoutEquinoxIT.java | 245 ++
.../org/netbeans/html/ko/osgi/test/test.html | 56 +
ko-ws-tyrus/pom.xml | 194 ++
.../org/netbeans/html/wstyrus/LoadJSON.java | 301 +++
.../org/netbeans/html/wstyrus/TyrusContext.java | 209 ++
.../netbeans/html/wstyrus/TyrusDynamicHTTP.java | 262 ++
.../java/org/netbeans/html/wstyrus/TyrusFX.java | 125 +
.../html/wstyrus/TyrusKnockoutTest.java | 219 ++
.../org/netbeans/html/wstyrus/test.html | 56 +
ko4j/pom.xml | 179 ++
.../main/java/org/netbeans/html/ko4j/KO4J.java | 149 ++
.../java/org/netbeans/html/ko4j/KOSockets.java | 81 +
.../java/org/netbeans/html/ko4j/KOTech.java | 176 ++
.../java/org/netbeans/html/ko4j/KOTransfer.java | 164 ++
.../java/org/netbeans/html/ko4j/Knockout.java | 277 +++
.../java/org/netbeans/html/ko4j/LoadJSON.java | 138 ++
.../java/org/netbeans/html/ko4j/LoadWS.java | 141 ++
.../org/netbeans/html/ko4j/DynamicHTTP.java | 261 ++
.../html/ko4j/InitializeKnockoutTest.java | 156 ++
.../test/java/org/netbeans/html/ko4j/KOFx.java | 132 +
.../org/netbeans/html/ko4j/KnockoutFXTest.java | 235 ++
.../netbeans/html/ko4j/LessCallbacksCheck.java | 97 +
.../html/ko4j/OffThreadInitializationTest.java | 166 ++
.../html/ko4j/ReferenceKnockoutTest.java | 63 +
.../resources/org/netbeans/html/ko4j/test.html | 56 +
pom.xml | 475 ++++
sound/pom.xml | 93 +
.../java/net/java/html/sound/AudioClip.java | 200 ++
.../main/java/net/java/html/sound/package.html | 50 +
.../html/sound/impl/BrowserAudioEnv.java | 85 +
.../html/sound/spi/AudioEnvironment.java | 94 +
.../org/netbeans/html/sound/spi/package.html | 49 +
src/main/javadoc/overview.html | 623 +++++
xhr4j/pom.xml | 166 ++
.../java/org/netbeans/html/xhr4j/LoadJSON.java | 274 +++
.../html/xhr4j/XmlHttpResourceContext.java | 88 +
.../netbeans/html/xhr4j/JsonDynamicHTTP.java | 262 ++
.../java/org/netbeans/html/xhr4j/JsonFX.java | 125 +
.../netbeans/html/xhr4j/JsonKnockoutTest.java | 217 ++
.../resources/org/netbeans/html/xhr4j/test.html | 56 +
267 files changed, 45112 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/COPYING
----------------------------------------------------------------------
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..83fe966
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,40 @@
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+Copyright 2013-2014 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]"
+
+Contributor(s):
+
+The Original Software is NetBeans. The Initial Developer of the Original
+Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+
+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.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-agent-test/pom.xml
----------------------------------------------------------------------
diff --git a/boot-agent-test/pom.xml b/boot-agent-test/pom.xml
new file mode 100644
index 0000000..8159679
--- /dev/null
+++ b/boot-agent-test/pom.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+ Copyright 2013-2016 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]"
+
+ Contributor(s):
+
+ The Original Software is NetBeans. The Initial Developer of the Original
+ Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+
+ 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.
+
+-->
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.netbeans.html</groupId>
+ <artifactId>pom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>boot-agent-test</artifactId>
+ <packaging>jar</packaging>
+ <name>Dynamic Boot Test</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.netbeans.html</groupId>
+ <artifactId>net.java.html</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.netbeans.html</groupId>
+ <artifactId>net.java.html.boot</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.netbeans.api</groupId>
+ <artifactId>org-openide-util-lookup</artifactId>
+ <scope>test</scope>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>net.java.html.boot.fx</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-agent-test/src/test/java/org/netbeans/html/bootagent/DynamicClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/boot-agent-test/src/test/java/org/netbeans/html/bootagent/DynamicClassLoaderTest.java b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/DynamicClassLoaderTest.java
new file mode 100644
index 0000000..610834d
--- /dev/null
+++ b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/DynamicClassLoaderTest.java
@@ -0,0 +1,126 @@
+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013-2014 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]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+ *
+ * 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.
+ */
+package org.netbeans.html.bootagent;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executors;
+import net.java.html.BrwsrCtx;
+import net.java.html.boot.BrowserBuilder;
+import org.netbeans.html.boot.spi.Fn;
+import org.testng.Assert;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
+import org.testng.annotations.Factory;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+public class DynamicClassLoaderTest {
+ private static Class<?> browserClass;
+ private static Fn.Presenter browserPresenter;
+
+ public DynamicClassLoaderTest() {
+ }
+
+ @Factory public static Object[] compatibilityTests() throws Exception {
+ final BrowserBuilder bb = BrowserBuilder.newBrowser().loadClass(DynamicClassLoaderTest.class).
+ loadPage("empty.html").
+ invoke("initialized");
+
+ Executors.newSingleThreadExecutor().submit(new Runnable() {
+ @Override
+ public void run() {
+ bb.showAndWait();
+ }
+ });
+
+ List<Object> res = new ArrayList<Object>();
+
+ Class[] arr = new Class[] { loadClass() };
+ for (Class c : arr) {
+ for (Method m : c.getDeclaredMethods()) {
+ if ((m.getModifiers() & Modifier.PUBLIC) != 0) {
+ res.add(new KOFx(browserPresenter, m));
+ }
+ }
+ }
+ return res.toArray();
+ }
+
+ static synchronized Class<?> loadClass() throws InterruptedException {
+ while (browserClass == null) {
+ DynamicClassLoaderTest.class.wait();
+ }
+ return browserClass;
+ }
+
+ public static void ready(Class<?> browserCls) throws Exception {
+ Class<?> origClazz = ClassLoader.getSystemClassLoader().loadClass(DynamicClassLoaderTest.class.getName());
+ final Field f1 = origClazz.getDeclaredField("browserClass");
+ f1.setAccessible(true);
+ f1.set(null, browserCls);
+ final Field f2 = origClazz.getDeclaredField("browserPresenter");
+ f2.setAccessible(true);
+ f2.set(null, Fn.activePresenter());
+ synchronized (origClazz) {
+ origClazz.notifyAll();
+ }
+ }
+
+ public static void initialized() throws Exception {
+ BrwsrCtx b1 = BrwsrCtx.findDefault(DynamicClassLoaderTest.class);
+ assertNotSame(b1, BrwsrCtx.EMPTY, "Browser context is not empty");
+ BrwsrCtx b2 = BrwsrCtx.findDefault(DynamicClassLoaderTest.class);
+ assertSame(b1, b2, "Browser context remains stable");
+ Assert.assertNotSame(DynamicClassLoaderTest.class.getClassLoader(),
+ ClassLoader.getSystemClassLoader(),
+ "Should use special classloader, not system one"
+ );
+ DynamicClassLoaderTest.ready(JavaScriptBodyTst.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-agent-test/src/test/java/org/netbeans/html/bootagent/JavaScriptBodyTst.java
----------------------------------------------------------------------
diff --git a/boot-agent-test/src/test/java/org/netbeans/html/bootagent/JavaScriptBodyTst.java b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/JavaScriptBodyTst.java
new file mode 100644
index 0000000..33c2d22
--- /dev/null
+++ b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/JavaScriptBodyTst.java
@@ -0,0 +1,63 @@
+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013-2014 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]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+ *
+ * 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.
+ */
+package org.netbeans.html.bootagent;
+
+import net.java.html.js.JavaScriptBody;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+public class JavaScriptBodyTst {
+
+ public JavaScriptBodyTst() {
+ }
+
+ public void assert42() {
+ int v = mul(7, 6);
+ assert v == 42 : "Really 42: " + v;
+ }
+
+ @JavaScriptBody(args = { "x", "y" }, body = "return x * y;")
+ private static native int mul(int x, int y);
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-agent-test/src/test/java/org/netbeans/html/bootagent/KOFx.java
----------------------------------------------------------------------
diff --git a/boot-agent-test/src/test/java/org/netbeans/html/bootagent/KOFx.java b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/KOFx.java
new file mode 100644
index 0000000..19f5c5a
--- /dev/null
+++ b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/KOFx.java
@@ -0,0 +1,125 @@
+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013-2014 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]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+ *
+ * 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.
+ */
+package org.netbeans.html.bootagent;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import javafx.application.Platform;
+import org.netbeans.html.boot.impl.FnContext;
+import org.netbeans.html.boot.spi.Fn;
+import org.testng.IHookCallBack;
+import org.testng.IHookable;
+import org.testng.ITest;
+import org.testng.ITestResult;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+public final class KOFx implements ITest, IHookable, Runnable {
+ private final Fn.Presenter p;
+ private final Method m;
+ private Object result;
+ private Object inst;
+
+ KOFx(Fn.Presenter p, Method m) {
+ this.p = p;
+ this.m = m;
+ }
+
+ @Override
+ public String getTestName() {
+ return m.getName();
+ }
+
+ @Test
+ public synchronized void executeTest() throws Exception {
+ if (result == null) {
+ Platform.runLater(this);
+ wait();
+ }
+ if (result instanceof Exception) {
+ throw (Exception)result;
+ }
+ if (result instanceof Error) {
+ throw (Error)result;
+ }
+ }
+
+ @Override
+ public synchronized void run() {
+ boolean notify = true;
+ try {
+ FnContext.currentPresenter(p);
+ if (inst == null) {
+ inst = m.getDeclaringClass().newInstance();
+ }
+ result = m.invoke(inst);
+ if (result == null) {
+ result = this;
+ }
+ } catch (InvocationTargetException ex) {
+ Throwable r = ex.getTargetException();
+ if (r instanceof InterruptedException) {
+ notify = false;
+ Platform.runLater(this);
+ return;
+ }
+ result = r;
+ } catch (Exception ex) {
+ result = ex;
+ } finally {
+ if (notify) {
+ notifyAll();
+ }
+ FnContext.currentPresenter(null);
+ }
+ }
+
+ @Override
+ public void run(IHookCallBack ihcb, ITestResult itr) {
+ ihcb.runTestMethod(itr);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty.html
----------------------------------------------------------------------
diff --git a/boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty.html b/boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty.html
new file mode 100644
index 0000000..bf2114b
--- /dev/null
+++ b/boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty.html
@@ -0,0 +1,55 @@
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+ Copyright 2013-2014 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]"
+
+ Contributor(s):
+
+ The Original Software is NetBeans. The Initial Developer of the Original
+ Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+
+ 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.
+
+-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Bootstrap Dynamically</title>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ </head>
+ <body>
+ <div>Bootstrap Dynamically</div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-fx/pom.xml
----------------------------------------------------------------------
diff --git a/boot-fx/pom.xml b/boot-fx/pom.xml
new file mode 100644
index 0000000..26dd2ce
--- /dev/null
+++ b/boot-fx/pom.xml
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+ Copyright 2013-2016 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]"
+
+ Contributor(s):
+
+ The Original Software is NetBeans. The Initial Developer of the Original
+ Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+
+ 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.
+
+-->
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.netbeans.html</groupId>
+ <artifactId>pom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.netbeans.html</groupId>
+ <artifactId>net.java.html.boot.fx</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <name>FX WebView Bootstrap</name>
+ <packaging>bundle</packaging>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <publicPackages>net.java.html.boot.fx</publicPackages>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Require-Capability>osgi.extender;resolution:=optional;filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
+ <Provide-Capability>osgi.serviceloader;osgi.serviceloader=org.netbeans.html.boot.spi.Fn$Presenter</Provide-Capability>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.netbeans.html</groupId>
+ <artifactId>html4j-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>javafx</artifactId>
+ <version>2.2</version>
+ <scope>system</scope>
+ <systemPath>${jfxrt.jar}</systemPath>
+ </dependency>
+ <dependency>
+ <groupId>org.netbeans.api</groupId>
+ <artifactId>org-openide-util-lookup</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.netbeans.html</groupId>
+ <artifactId>net.java.html.boot</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>net.java.html.json.tck</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <description>A presentation provider to show JavaFX WebView
+when a Java/HTML based application is about to boot.</description>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-fx/src/main/java/net/java/html/boot/fx/FXBrowsers.java
----------------------------------------------------------------------
diff --git a/boot-fx/src/main/java/net/java/html/boot/fx/FXBrowsers.java b/boot-fx/src/main/java/net/java/html/boot/fx/FXBrowsers.java
new file mode 100644
index 0000000..eca28e1
--- /dev/null
+++ b/boot-fx/src/main/java/net/java/html/boot/fx/FXBrowsers.java
@@ -0,0 +1,293 @@
+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013-2014 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]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+ *
+ * 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.
+ */
+package net.java.html.boot.fx;
+
+import java.net.URL;
+import javafx.application.Platform;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.concurrent.Worker;
+import javafx.scene.web.WebView;
+import net.java.html.BrwsrCtx;
+import net.java.html.boot.BrowserBuilder;
+import net.java.html.js.JavaScriptBody;
+import org.netbeans.html.boot.fx.AbstractFXPresenter;
+import org.netbeans.html.context.spi.Contexts;
+import org.netbeans.html.context.spi.Contexts.Id;
+
+/** Utility methods to use {@link WebView} and {@link JavaScriptBody} code
+ * in existing <em>JavaFX</em> applications.
+ * This class is for those who want to instantiate their own {@link WebView},
+ * configure it manually, embed it into own <em>JavaFX</em>
+ * application and based on other events in the application
+ * {@link #runInBrowser(javafx.scene.web.WebView, java.lang.Runnable) re-execute code}
+ * inside of such {@link WebView}s.
+ * <p>
+ * In case such detailed control is not necessary,
+ * consider using {@link BrowserBuilder}. Btw. when using the {@link BrowserBuilder}
+ * one can execute presenter in headless mode. Just specify: <code>
+ * {@link System}.{@link System#setProperty(java.lang.String, java.lang.String) setProperty}("fxpresenter.headless", "true");
+ * </code>
+ *
+ *
+ * @author Jaroslav Tulach
+ * @since 0.6
+ */
+public final class FXBrowsers {
+ private FXBrowsers() {
+ }
+
+ /** Enables the Java/JavaScript bridge (that supports {@link JavaScriptBody} and co.)
+ * in the provided <code>webView</code>. This method returns
+ * immediately. Once the support is active, it calls back specified
+ * method in <code>onPageLoad</code> class - the class can possibly be
+ * loaded by a different classloader (to enable replacement of
+ * methods with {@link JavaScriptBody} annotations with executable
+ * versions). The method <code>methodName</code> needs to be <code>public</code>
+ * (in a public class), <code>static</code> and take either no parameters
+ * or an array of {@link String}s.
+ * <p>
+ * This method sets {@link WebView#getUserData()} and {@link #runInBrowser(javafx.scene.web.WebView, java.lang.Runnable)}
+ * relies on the value. Please don't alter it.
+ * <p>
+ * Since introduction of {@link Id technology identifiers} the
+ * provided <code>args</code> strings are also passed to the
+ * {@link BrwsrCtx context} when it is being
+ * {@link Contexts#newBuilder(java.lang.Object...) created}
+ * and can influence the selection
+ * of available technologies
+ * (like {@link org.netbeans.html.json.spi.Technology},
+ * {@link org.netbeans.html.json.spi.Transfer} or
+ * {@link org.netbeans.html.json.spi.WSTransfer}).
+ *
+ * @param webView the instance of Web View to tweak
+ * @param url the URL of the HTML page to load into the view
+ * @param onPageLoad callback class with method <code>methodName</code>
+ * @param methodName the method to call when the page is loaded
+ * @param args arguments to pass to the <code>methodName</code> method
+ */
+ public static void load(
+ final WebView webView, final URL url,
+ Class<?> onPageLoad, String methodName,
+ String... args
+ ) {
+ Object[] context = new Object[args.length + 1];
+ System.arraycopy(args, 0, context, 1, args.length);
+ final Load load = new Load(webView, null);
+ context[0] = load;
+ BrowserBuilder.newBrowser(context).
+ loadPage(url.toExternalForm()).
+ loadFinished(load).
+ loadClass(onPageLoad).
+ invoke(methodName, args).
+ showAndWait();
+ }
+
+ /** Enables the Java/JavaScript bridge (that supports {@link JavaScriptBody} and co.)
+ * in the provided <code>webView</code>. This method returns
+ * immediately. Once the support is active, it calls back specified
+ * method in <code>onPageLoad</code>'s run method.
+ * This is more convenient way to initialize the webview,
+ * but it requires one to make sure
+ * all {@link JavaScriptBody} methods has been post-processed during
+ * compilation and there will be no need to instantiate new classloader.
+ * <p>
+ * This method sets {@link WebView#getUserData()} and {@link #runInBrowser(javafx.scene.web.WebView, java.lang.Runnable)}
+ * relies on the value. Please don't alter it.
+ *
+ * @param webView the instance of Web View to tweak
+ * @param url the URL of the HTML page to load into the view
+ * @param onPageLoad callback to call when the page is ready
+ * @since 0.8.1
+ */
+ public static void load(
+ WebView webView, final URL url, Runnable onPageLoad
+ ) {
+ load(webView, url, onPageLoad, null);
+ }
+
+ /** Enables the Java/JavaScript bridge (that supports {@link JavaScriptBody} and co.)
+ * in the provided <code>webView</code>. This method returns
+ * immediately. Once the support is active, it calls back {@link Runnable#run() run}
+ * method in <code>onPageLoad</code>.
+ * This is more convenient way to initialize the webview,
+ * but it requires one to make sure
+ * all {@link JavaScriptBody} methods has been post-processed during
+ * compilation and there will be no need to instantiate new classloader.
+ * <p>
+ * This method sets {@link WebView#getUserData()} and {@link #runInBrowser(javafx.scene.web.WebView, java.lang.Runnable)}
+ * relies on the value. Please don't alter it.
+ *
+ * @param webView the instance of Web View to tweak
+ * @param url the URL of the HTML page to load into the view
+ * @param onPageLoad callback to call when the page is ready
+ * @param loader the loader to use when constructing initial {@link BrwsrCtx} or <code>null</code>
+ * @since 0.9
+ */
+ public static void load(
+ WebView webView, final URL url, Runnable onPageLoad, ClassLoader loader
+ ) {
+ load(webView, url, onPageLoad, loader, new Object[0]);
+ }
+
+ /** Enables the Java/JavaScript bridge (that supports {@link JavaScriptBody} and co.)
+ * in the provided <code>webView</code>. This method returns
+ * immediately. Once the support is active, it calls back {@link Runnable#run() run}
+ * method in <code>onPageLoad</code>.
+ * This is more convenient way to initialize the webview,
+ * but it requires one to make sure
+ * all {@link JavaScriptBody} methods has been post-processed during
+ * compilation and there will be no need to instantiate new classloader.
+ * <p>
+ * This method sets {@link WebView#getUserData()} and {@link #runInBrowser(javafx.scene.web.WebView, java.lang.Runnable)}
+ * relies on the value. Please don't alter it.
+ *
+ * @param webView the instance of Web View to tweak
+ * @param url the URL of the HTML page to load into the view
+ * @param onPageLoad callback to call when the page is ready
+ * @param loader the loader to use when constructing initial {@link BrwsrCtx} or <code>null</code>
+ * @param context additonal configuration to pass to {@link BrowserBuilder#newBrowser(java.lang.Object...)}
+ * and {@link Contexts#newBuilder(java.lang.Object...)} factory methods
+ * @since 1.1
+ */
+ public static void load(
+ WebView webView, final URL url, Runnable onPageLoad, ClassLoader loader,
+ Object... context
+ ) {
+ Object[] newCtx = new Object[context.length + 1];
+ System.arraycopy(context, 0, newCtx, 1, context.length);
+ final Load load = new Load(webView, onPageLoad);
+ newCtx[0] = load;
+ BrowserBuilder.newBrowser(newCtx).
+ loadPage(url.toExternalForm()).
+ loadFinished(load).
+ classloader(loader).
+ showAndWait();
+ }
+
+ /** Executes a code inside of provided {@link WebView}. This method
+ * associates the {@link BrwsrCtx execution context} with provided browser,
+ * so the {@link JavaScriptBody} annotations know where to execute
+ * their JavaScript bodies.
+ * The code is going to be executed synchronously
+ * in case {@link Platform#isFxApplicationThread()} returns <code>true</code>.
+ * Otherwise this method returns immediately and the code is executed
+ * later via {@link Platform#runLater(java.lang.Runnable)}.
+ * <p>
+ * This method relies on {@link WebView#getUserData()} being properly
+ * provided by the <code>load</code> methods in this class.
+ *
+ * @param webView the web view previously prepared by one of the <code>load</code>
+ * methods in this class
+ * @param code the code to execute
+ * @throws IllegalArgumentException if the web view was not properly
+ * initialized
+ * @see BrwsrCtx#execute(java.lang.Runnable)
+ * @since 0.8.1
+ */
+ public static void runInBrowser(WebView webView, Runnable code) {
+ Object ud = webView.getUserData();
+ if (!(ud instanceof Load)) {
+ throw new IllegalArgumentException();
+ }
+ ((Load)ud).ctx.execute(code);
+ }
+
+ private static class Load extends AbstractFXPresenter implements Runnable {
+ private final WebView webView;
+ private final Runnable myLoad;
+ private BrwsrCtx ctx;
+
+ public Load(WebView webView, Runnable onLoad) {
+ this.webView = webView;
+ this.myLoad = onLoad;
+ webView.setUserData(this);
+ }
+
+ public void run() {
+ ctx = BrwsrCtx.findDefault(Load.class);
+ if (myLoad != null) {
+ myLoad.run();
+ }
+ }
+
+ @Override
+ protected void waitFinished() {
+ // don't wait
+ }
+
+ @Override
+ protected WebView findView(final URL resource) {
+ final Worker<Void> w = webView.getEngine().getLoadWorker();
+ w.stateProperty().addListener(new ChangeListener<Worker.State>() {
+ private String previous;
+
+ @Override
+ public void changed(ObservableValue<? extends Worker.State> ov, Worker.State t, Worker.State newState) {
+ if (newState.equals(Worker.State.SUCCEEDED)) {
+ if (checkValid()) {
+ onPageLoad();
+ }
+ }
+ if (newState.equals(Worker.State.FAILED)) {
+ checkValid();
+ throw new IllegalStateException("Failed to load " + resource);
+ }
+ }
+
+ private boolean checkValid() {
+ final String crnt = webView.getEngine().getLocation();
+ if (previous != null && !previous.equals(crnt)) {
+ w.stateProperty().removeListener(this);
+ return false;
+ }
+ previous = crnt;
+ return true;
+ }
+ });
+
+ return webView;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-fx/src/main/java/net/java/html/boot/fx/package.html
----------------------------------------------------------------------
diff --git a/boot-fx/src/main/java/net/java/html/boot/fx/package.html b/boot-fx/src/main/java/net/java/html/boot/fx/package.html
new file mode 100644
index 0000000..d2ed2c4
--- /dev/null
+++ b/boot-fx/src/main/java/net/java/html/boot/fx/package.html
@@ -0,0 +1,51 @@
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+ Copyright 2013-2014 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]"
+
+ Contributor(s):
+
+ The Original Software is NetBeans. The Initial Developer of the Original
+ Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+
+ 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.
+
+-->
+<body>
+ <p>
+ Implementation of {@link net.java.html.boot.BrowserBuilder} that renders
+ using JavaFX WebView and additional {@link net.java.html.boot.fx.FXBrowsers utilities}
+ to configure individual WebViews.
+ </p>
+</body>
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-fx/src/main/java/org/netbeans/html/boot/fx/AbstractFXPresenter.java
----------------------------------------------------------------------
diff --git a/boot-fx/src/main/java/org/netbeans/html/boot/fx/AbstractFXPresenter.java b/boot-fx/src/main/java/org/netbeans/html/boot/fx/AbstractFXPresenter.java
new file mode 100644
index 0000000..9164140
--- /dev/null
+++ b/boot-fx/src/main/java/org/netbeans/html/boot/fx/AbstractFXPresenter.java
@@ -0,0 +1,433 @@
+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013-2014 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]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+ *
+ * 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.
+ */
+package org.netbeans.html.boot.fx;
+
+import java.io.BufferedReader;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.Reader;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javafx.application.Platform;
+import javafx.scene.Parent;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.web.WebEngine;
+import javafx.scene.web.WebView;
+import netscape.javascript.JSObject;
+import org.netbeans.html.boot.spi.Fn;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+public abstract class AbstractFXPresenter implements Fn.Presenter,
+Fn.KeepAlive, Fn.ToJavaScript, Fn.FromJavaScript, Executor, Cloneable {
+ static final Logger LOG = Logger.getLogger(FXPresenter.class.getName());
+ protected static int cnt;
+ protected Runnable onLoad;
+ protected WebEngine engine;
+
+ // transient - e.g. not cloneable
+ private JSObject arraySize;
+ private JSObject wrapArrImpl;
+ private Object undefined;
+
+ @Override
+ protected AbstractFXPresenter clone() {
+ try {
+ AbstractFXPresenter p = (AbstractFXPresenter) super.clone();
+ p.arraySize = null;
+ p.wrapArrImpl = null;
+ p.undefined = null;
+ return p;
+ } catch (CloneNotSupportedException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ @Override
+ public Fn defineFn(String code, String... names) {
+ return defineJSFn(code, names, null);
+ }
+
+ @Override
+ public Fn defineFn(String code, String[] names, boolean[] keepAlive) {
+ return defineJSFn(code, names, keepAlive);
+ }
+
+
+
+ final JSFn defineJSFn(String code, String[] names, boolean[] keepAlive) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("(function() {\n");
+ sb.append(" return function(\n ");
+ String sep = "";
+ if (names != null) for (String n : names) {
+ sb.append(sep).append(n);
+ sep = ",";
+ }
+ sb.append(" \n) {\n");
+ sb.append(code);
+ sb.append("};\n");
+ sb.append("})();\n");
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.log(Level.FINE,
+ "defining function #{0}:\n{1}\n",
+ new Object[] { ++cnt, code }
+ );
+ }
+ JSObject x = (JSObject) engine.executeScript(sb.toString());
+ return new JSFn(this, x, cnt, keepAlive);
+ }
+
+ @Override
+ public void loadScript(Reader code) throws Exception {
+ BufferedReader r = new BufferedReader(code);
+ StringBuilder sb = new StringBuilder();
+ for (;;) {
+ String l = r.readLine();
+ if (l == null) {
+ break;
+ }
+ sb.append(l).append('\n');
+ }
+ final String script = sb.toString();
+ engine.executeScript(script);
+ }
+
+ protected final void onPageLoad() {
+ Closeable c = Fn.activate(this.clone());
+ try {
+ onLoad.run();
+ } finally {
+ try {
+ c.close();
+ } catch (IOException ex) {
+ LOG.log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+ @Override
+ public void displayPage(final URL resource, final Runnable onLoad) {
+ this.onLoad = onLoad;
+ final WebView view = findView(resource);
+ this.engine = view.getEngine();
+ boolean inspectOn = false;
+ try {
+ if (FXInspect.initialize(engine)) {
+ inspectOn = true;
+ }
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ }
+ final boolean isFirebugOn = Boolean.getBoolean("firebug.lite"); // NOI18N
+ final boolean isInspectOn = inspectOn;
+ class Run implements Runnable {
+
+ @Override
+ public void run() {
+ if (isInspectOn || isFirebugOn) {
+ view.setContextMenuEnabled(true);
+ final Parent p = view.getParent();
+ if (p instanceof BorderPane) {
+ BorderPane bp = (BorderPane) p;
+ if (bp.getTop() == null) {
+ bp.setTop(new FXToolbar(view, bp, isFirebugOn));
+ }
+ }
+ }
+ engine.load(resource.toExternalForm());
+ }
+ }
+ Run run = new Run();
+ if (Platform.isFxApplicationThread()) {
+ run.run();
+ } else {
+ Platform.runLater(run);
+ }
+ waitFinished();
+ }
+
+ protected abstract void waitFinished();
+
+ protected abstract WebView findView(final URL resource);
+
+ final JSObject convertArrays(Object[] arr) {
+ for (int i = 0; i < arr.length; i++) {
+ if (arr[i] instanceof Object[]) {
+ arr[i] = convertArrays((Object[]) arr[i]);
+ }
+ }
+ final JSObject wrapArr = (JSObject)wrapArrFn().call("array", arr); // NOI18N
+ return wrapArr;
+ }
+
+ private final JSObject wrapArrFn() {
+ if (wrapArrImpl == null) {
+ try {
+ wrapArrImpl = (JSObject)defineJSFn(" var k = {};"
+ + " k.array= function() {"
+ + " return Array.prototype.slice.call(arguments);"
+ + " };"
+ + " return k;", null, null
+ ).invokeImpl(null, false);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+ return wrapArrImpl;
+ }
+
+ final Object undefined() {
+ if (undefined == null) {
+ undefined = engine.executeScript("undefined");
+ }
+ return undefined;
+ }
+
+ final Object checkArray(Object val) {
+ if (!(val instanceof JSObject)) {
+ return val;
+ }
+ int length = ((Number) arraySizeFn().call("array", val, null)).intValue();
+ if (length == -1) {
+ return val;
+ }
+ Object[] arr = new Object[length];
+ arraySizeFn().call("array", val, arr);
+ clearUndefinedArray(arr);
+ return arr;
+ }
+
+ private void clearUndefinedArray(Object[] arr) {
+ for (int i = 0; i < arr.length; i++) {
+ if (arr[i] == undefined) {
+ arr[i] = null;
+ continue;
+ }
+ if (arr[i] instanceof Object[]) {
+ clearUndefinedArray((Object[])arr[i]);
+ }
+ }
+ }
+
+ private final JSObject arraySizeFn() {
+ if (arraySize == null) {
+ try {
+ arraySize = (JSObject)defineJSFn(" var k = {};"
+ + " k.array = function(arr, to) {"
+ + " if (to === null) {"
+ + " if (Object.prototype.toString.call(arr) === '[object Array]') return arr.length;"
+ + " else return -1;"
+ + " } else {"
+ + " var l = arr.length;"
+ + " for (var i = 0; i < l; i++) to[i] = arr[i];"
+ + " return l;"
+ + " }"
+ + " };"
+ + " return k;", null, null
+ ).invokeImpl(null, false);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+ return arraySize;
+ }
+
+ @Override
+ public Object toJava(Object toJS) {
+ if (toJS instanceof Weak) {
+ toJS = ((Weak)toJS).get();
+ }
+ if (toJS == undefined()) {
+ return null;
+ }
+ return checkArray(toJS);
+ }
+
+ @Override
+ public Object toJavaScript(Object toReturn) {
+ if (toReturn instanceof Object[]) {
+ return convertArrays((Object[])toReturn);
+ } else {
+ if (toReturn instanceof Character) {
+ return (int)(Character)toReturn;
+ }
+ return toReturn;
+ }
+ }
+
+ @Override public void execute(final Runnable r) {
+ if (Platform.isFxApplicationThread()) {
+ Closeable c = Fn.activate(this);
+ try {
+ r.run();
+ } finally {
+ try {
+ c.close();
+ } catch (IOException ex) {
+ // ignore
+ }
+ }
+ } else {
+ class Wrap implements Runnable {
+ @Override
+ public void run() {
+ Closeable c = Fn.activate(AbstractFXPresenter.this);
+ try {
+ r.run();
+ } finally {
+ try {
+ c.close();
+ } catch (IOException ex) {
+ // ignore
+ }
+ }
+ }
+ }
+ Platform.runLater(new Wrap());
+ }
+ }
+
+ private static final class JSFn extends Fn {
+
+ private final JSObject fn;
+ private static int call;
+ private final int id;
+ private final boolean[] keepAlive;
+
+ public JSFn(AbstractFXPresenter p, JSObject fn, int id, boolean[] keepAlive) {
+ super(p);
+ this.fn = fn;
+ this.id = id;
+ this.keepAlive = keepAlive;
+ }
+
+ @Override
+ public Object invoke(Object thiz, Object... args) throws Exception {
+ return invokeImpl(thiz, true, args);
+ }
+
+ final Object invokeImpl(Object thiz, boolean arrayChecks, Object... args) throws Exception {
+ try {
+ final AbstractFXPresenter presenter = (AbstractFXPresenter) presenter();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.log(Level.FINE, "calling {0} function #{1}", new Object[]{++call, id});
+ LOG.log(Level.FINER, " thiz : {0}", thiz);
+ LOG.log(Level.FINER, " params: {0}", Arrays.asList(args));
+ }
+ List<Object> all = new ArrayList<Object>(args.length + 1);
+ all.add(thiz == null ? fn : thiz);
+ for (int i = 0; i < args.length; i++) {
+ Object conv = args[i];
+ if (arrayChecks) {
+ if (args[i] instanceof Object[]) {
+ Object[] arr = (Object[]) args[i];
+ conv = presenter.convertArrays(arr);
+ }
+ if (conv != null && keepAlive != null &&
+ !keepAlive[i] && !isJSReady(conv) &&
+ !conv.getClass().getSimpleName().equals("$JsCallbacks$") // NOI18N
+ ) {
+ conv = new Weak(conv);
+ }
+ if (conv instanceof Character) {
+ conv = (int)(Character)conv;
+ }
+ }
+ all.add(conv);
+ }
+ Object ret = fn.call("call", all.toArray()); // NOI18N
+ if (ret instanceof Weak) {
+ ret = ((Weak)ret).get();
+ }
+ if (ret == fn || ret == presenter.undefined()) {
+ return null;
+ }
+ if (!arrayChecks) {
+ return ret;
+ }
+ return presenter.checkArray(ret);
+ } catch (Error t) {
+ t.printStackTrace();
+ throw t;
+ } catch (Exception t) {
+ t.printStackTrace();
+ throw t;
+ }
+ }
+ }
+
+ private static boolean isJSReady(Object obj) {
+ if (obj == null) {
+ return true;
+ }
+ if (obj instanceof String) {
+ return true;
+ }
+ if (obj instanceof Number) {
+ return true;
+ }
+ if (obj instanceof JSObject) {
+ return true;
+ }
+ if (obj instanceof Character) {
+ return true;
+ }
+ return false;
+ }
+
+ private static final class Weak extends WeakReference<Object> {
+ public Weak(Object referent) {
+ super(referent);
+ assert !(referent instanceof Weak);
+ }
+ } // end of Weak
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-html4j/blob/226089a5/boot-fx/src/main/java/org/netbeans/html/boot/fx/Dbgr.java
----------------------------------------------------------------------
diff --git a/boot-fx/src/main/java/org/netbeans/html/boot/fx/Dbgr.java b/boot-fx/src/main/java/org/netbeans/html/boot/fx/Dbgr.java
new file mode 100644
index 0000000..0d2b325
--- /dev/null
+++ b/boot-fx/src/main/java/org/netbeans/html/boot/fx/Dbgr.java
@@ -0,0 +1,87 @@
+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013-2014 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]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Oracle. Portions Copyright 2013-2016 Oracle. All Rights Reserved.
+ *
+ * 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.
+ */
+package org.netbeans.html.boot.fx;
+
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import javafx.scene.web.WebEngine;
+import javafx.util.Callback;
+import static org.netbeans.html.boot.fx.AbstractFXPresenter.LOG;
+
+/** Debugger bridge to shield us from propriatory impl APIs.
+ *
+ * @author Jaroslav Tulach
+ */
+final class Dbgr {
+ final Object dbg;
+ final Method sendMsg;
+
+ Dbgr(WebEngine eng, Callback<String,Void> callback) {
+ Object d;
+ Method m;
+ try {
+ d = eng.getClass().getMethod("impl_getDebugger").invoke(eng); // NOI18N
+ Class<?> debugger = eng.getClass().getClassLoader().loadClass("com.sun.javafx.scene.web.Debugger"); // NOI18N
+ debugger.getMethod("setEnabled", boolean.class).invoke(d, true); // NOI18N
+ debugger.getMethod("setMessageCallback", Callback.class).invoke(d, callback); // NOI18N
+ m = debugger.getMethod("sendMessage", String.class); // NOI18N
+ } catch (Exception ex) {
+ LOG.log(Level.INFO, null, ex);
+ d = null;
+ m = null;
+ }
+ dbg = d;
+ sendMsg = m;
+ }
+
+ void sendMessage(String msg) {
+ try {
+ if (dbg != null) {
+ sendMsg.invoke(dbg, msg);
+ }
+ } catch (Exception ex) {
+ LOG.log(Level.INFO, null, ex);
+ }
+ }
+
+}