├── .github └── workflows │ ├── javadoc.yml │ ├── linux.yml │ ├── mac.yml │ └── windows.yml ├── .gitignore ├── COPYING ├── DEPENDENCIES ├── Jenkinsfile.groovy ├── LICENSE ├── NOTICE ├── README.md ├── boot-agent-test ├── pom.xml └── src │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── bootagent │ │ ├── AgentBootstrapTest.java │ │ ├── JavaScriptBodyTst.java │ │ └── KOFx.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── bootagent │ ├── empty.html │ ├── empty.js │ ├── empty_2.js │ └── empty_3.js ├── boot-fx ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── net │ │ │ └── java │ │ │ │ └── html │ │ │ │ └── boot │ │ │ │ └── fx │ │ │ │ ├── FXBrowsers.java │ │ │ │ └── package.html │ │ └── org │ │ │ └── netbeans │ │ │ └── html │ │ │ └── boot │ │ │ └── fx │ │ │ ├── AbstractFXPresenter.java │ │ │ ├── Dbgr.java │ │ │ ├── FXBrwsr.java │ │ │ ├── FXConsole.java │ │ │ ├── FXGCPresenter.java │ │ │ ├── FXInspect.java │ │ │ ├── FXPresenter.java │ │ │ ├── FXToolbar.java │ │ │ ├── InitializeWebView.java │ │ │ └── WatchDir.java │ └── resources │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── boot │ │ └── fx │ │ ├── Bundle.properties │ │ ├── desktop.png │ │ ├── handheldLandscape.png │ │ ├── handheldPortrait.png │ │ ├── netbook.png │ │ ├── selectionMode.png │ │ ├── sizeToFit.png │ │ ├── tabletLandscape.png │ │ ├── tabletPortrait.png │ │ └── widescreen.png │ └── test │ ├── java │ ├── net │ │ └── java │ │ │ └── html │ │ │ └── boot │ │ │ └── fx │ │ │ ├── FXBrowsersOnResourceTest.java │ │ │ └── FXBrowsersTest.java │ └── org │ │ ├── netbeans │ │ └── html │ │ │ └── boot │ │ │ └── fx │ │ │ ├── AbstractFXPresenterTest.java │ │ │ ├── DbgrTest.java │ │ │ ├── FXBrwsrTest.java │ │ │ ├── FXJavaScriptTest.java │ │ │ ├── FXPresenterTst.java │ │ │ ├── FxJavaScriptTst.java │ │ │ ├── KOFx.java │ │ │ ├── Periodicaly.java │ │ │ ├── PeriodicalyTest.java │ │ │ ├── PopupTest.java │ │ │ ├── ReloadTest.java │ │ │ ├── TestingProvider.java │ │ │ └── TitleTest.java │ │ └── sample │ │ └── app │ │ └── pkg │ │ └── SampleApp.java │ └── resources │ ├── net │ └── java │ │ └── html │ │ └── boot │ │ └── fx │ │ └── wnd.js │ └── org │ └── netbeans │ └── html │ └── boot │ └── fx │ ├── empty.html │ └── second.html ├── boot-script ├── pom.xml └── src │ ├── main │ ├── java │ │ └── net │ │ │ └── java │ │ │ └── html │ │ │ └── boot │ │ │ └── script │ │ │ ├── Sanitizer.java │ │ │ ├── ScriptPresenter.java │ │ │ ├── Scripts.java │ │ │ ├── impl │ │ │ ├── Callback.java │ │ │ └── PromisePolyfill.java │ │ │ └── package.html │ └── resources │ │ └── net │ │ └── java │ │ └── html │ │ └── boot │ │ └── script │ │ └── impl │ │ └── promisePolyfill.js │ └── test │ ├── java │ └── net │ │ └── java │ │ └── html │ │ └── boot │ │ └── script │ │ ├── DynamicHTTP.java │ │ ├── KOCase.java │ │ ├── ScriptEngineCase.java │ │ ├── ScriptEngineJavaScriptTCK.java │ │ ├── ScriptEngineTest.java │ │ └── ScriptsTest.java │ └── resources │ └── net │ └── java │ └── html │ └── boot │ └── script │ └── test.html ├── boot-truffle ├── empty.sigtest ├── pom.xml └── src │ ├── main │ └── java │ │ └── net │ │ └── java │ │ └── html │ │ └── boot │ │ └── truffle │ │ ├── IsArrayNode.java │ │ ├── IsNullNode.java │ │ ├── JavaArray.java │ │ ├── JavaObject.java │ │ ├── JavaValue.java │ │ ├── TrufflePresenter.java │ │ ├── TrufflePresenters.java │ │ └── package.html │ └── test │ └── java │ └── net │ └── java │ └── html │ └── boot │ └── truffle │ ├── JsArrayTruffleTest.java │ ├── SingleCase.java │ └── TruffleJavaScriptTest.java ├── boot ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── net │ │ │ └── java │ │ │ │ └── html │ │ │ │ ├── boot │ │ │ │ ├── BrowserBuilder.java │ │ │ │ └── package.html │ │ │ │ └── js │ │ │ │ ├── JavaScriptBody.java │ │ │ │ ├── JavaScriptResource.java │ │ │ │ └── package.html │ │ └── org │ │ │ └── netbeans │ │ │ └── html │ │ │ └── boot │ │ │ ├── impl │ │ │ ├── FindResources.java │ │ │ ├── FnContext.java │ │ │ ├── FnUtils.java │ │ │ ├── JavaScriptProcesor.java │ │ │ ├── JsAgent.java │ │ │ ├── JsCallback.java │ │ │ ├── JsClassLoader.java │ │ │ └── JsPkgCache.java │ │ │ └── spi │ │ │ ├── FallbackIdentity.java │ │ │ ├── Fn.java │ │ │ └── package.html │ └── resources │ │ └── net │ │ └── java │ │ └── html │ │ └── boot │ │ └── html4j.txt │ └── test │ ├── java │ ├── net │ │ └── java │ │ │ └── html │ │ │ └── boot │ │ │ └── BrowserBuilderTest.java │ └── org │ │ └── netbeans │ │ └── html │ │ └── boot │ │ ├── impl │ │ ├── Arithm.java │ │ ├── Compile.java │ │ ├── CountFnCreationTest.java │ │ ├── FnTest.java │ │ ├── JavaScriptCompletionTest.java │ │ ├── JavaScriptProcesorTest.java │ │ ├── JsCallbackTest.java │ │ ├── JsClassLoaderBase.java │ │ ├── JsClassLoaderTest.java │ │ ├── JsMethods.java │ │ ├── JsUtils.java │ │ ├── KeepAliveTest.java │ │ ├── MockProcessor.java │ │ └── Object.java │ │ └── spi │ │ └── FallbackIdentityTest.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── boot │ └── impl │ ├── empty.js │ └── jsmethods.js ├── browser ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── presenters │ │ └── browser │ │ ├── Browser.java │ │ ├── GrizzlyServer.java │ │ ├── HttpServer.java │ │ ├── SimpleServer.java │ │ └── package-info.java │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── presenters │ │ └── browser │ │ ├── BrowserTest.java │ │ ├── DumpStack.java │ │ ├── DynamicHTTP.java │ │ ├── JavaScriptUtilities.java │ │ ├── KOClose.java │ │ ├── KOScript.java │ │ ├── KoBrowserTest.java │ │ ├── ServerFactories.java │ │ ├── ServerMimeTypeTest.java │ │ ├── ServerTest.java │ │ └── SimpleServerTest.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── presenters │ └── browser │ ├── empty.html │ ├── server.html │ ├── test.css │ ├── test.js │ └── test.min.js ├── context ├── pom.xml └── src │ ├── main │ └── java │ │ ├── net │ │ └── java │ │ │ └── html │ │ │ ├── BrwsrCtx.java │ │ │ └── package.html │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── context │ │ ├── impl │ │ ├── CtxAccssr.java │ │ └── CtxImpl.java │ │ └── spi │ │ ├── Contexts.java │ │ └── package.html │ └── test │ └── java │ ├── net │ └── java │ │ └── html │ │ └── BrwsrCtxTest.java │ └── org │ └── netbeans │ └── html │ └── context │ └── spi │ └── ContextsTest.java ├── dynamic-loader-test ├── pom.xml └── src │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── dynamicloader │ │ ├── DynamicClassLoaderTest.java │ │ ├── JavaScriptBodyTst.java │ │ └── KOFx.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── dynamicloader │ ├── empty.html │ ├── empty.js │ ├── empty_2.js │ └── empty_3.js ├── ecj-test ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── ecjtest │ │ ├── PersonImpl.java │ │ └── dummy │ │ └── Dummy.java │ └── test │ └── java │ └── org │ └── netbeans │ └── html │ └── ecjtest │ └── PersonImplTest.java ├── equinox-agentclass-hook ├── pom.xml └── src │ └── main │ ├── java │ ├── java │ │ └── lang │ │ │ └── Module.java │ └── org │ │ └── netbeans │ │ └── html │ │ └── equinox │ │ └── agentclass │ │ ├── AgentHook.java │ │ └── NbInstrumentation.java │ └── resources │ └── hookconfigurators.properties ├── generic ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── presenters │ │ └── spi │ │ ├── Generic.java │ │ ├── Level.java │ │ ├── ProtoPresenter.java │ │ ├── ProtoPresenterBuilder.java │ │ └── package-info.java │ └── test │ └── java │ └── org │ └── netbeans │ └── html │ └── presenters │ └── spi │ ├── ValueOfTest.java │ └── test │ ├── AsyncJavaOnlyTest.java │ ├── Case.java │ ├── Counter.java │ ├── DumpStack.java │ ├── GenericTCK.java │ ├── GenericTest.java │ ├── SynchronizedTest.java │ └── Testing.java ├── geo ├── pom.xml └── src │ ├── main │ └── java │ │ ├── net │ │ └── java │ │ │ └── html │ │ │ └── geo │ │ │ ├── OnLocation.java │ │ │ ├── Position.java │ │ │ ├── doc-files │ │ │ └── GeoDuke.png │ │ │ └── package.html │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── geo │ │ ├── impl │ │ ├── Accessor.java │ │ ├── GeoProcessor.java │ │ └── JsGLProvider.java │ │ └── spi │ │ ├── CoordImpl.java │ │ ├── GLProvider.java │ │ └── package.html │ └── test │ └── java │ ├── net │ └── java │ │ └── html │ │ └── geo │ │ └── OnLocationTest.java │ └── org │ └── netbeans │ └── html │ └── geo │ ├── impl │ ├── Compile.java │ ├── GeoProcessorTest.java │ └── JsGLProviderTest.java │ └── spi │ └── CoordImplTest.java ├── html4j-maven-plugin ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── netbeans │ │ │ └── html │ │ │ └── mojo │ │ │ ├── ProcessJsAnnotations.java │ │ │ ├── ProcessJsAnnotationsGradle.java │ │ │ ├── ProcessJsAnnotationsMojo.java │ │ │ └── ProcessJsAnnotationsTask.java │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── html4j.properties │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── mojo │ │ └── Gradle1Test.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── mojo │ └── gradle1 │ ├── build.gradle │ └── src │ └── main │ ├── java │ └── Gradle1Check.java │ └── resources │ └── meaning.js ├── json-tck ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── META-INF │ │ │ └── upgrade │ │ │ │ └── AvoidCollections.hint │ │ ├── net │ │ │ └── java │ │ │ │ └── html │ │ │ │ ├── js │ │ │ │ └── tests │ │ │ │ │ ├── AsyncJava.java │ │ │ │ │ ├── AsyncJavaScriptAction.java │ │ │ │ │ ├── AsyncJavaTest.java │ │ │ │ │ ├── Bodies.java │ │ │ │ │ ├── ExposedPropertiesTest.java │ │ │ │ │ ├── Factorial.java │ │ │ │ │ ├── GCBodyTest.java │ │ │ │ │ ├── Global2String.java │ │ │ │ │ ├── GlobalString.java │ │ │ │ │ ├── JavaScriptBodyTest.java │ │ │ │ │ ├── JsUtils.java │ │ │ │ │ ├── Later.java │ │ │ │ │ ├── LaterJavaScriptAction.java │ │ │ │ │ ├── Receiver.java │ │ │ │ │ ├── ResourceOrder.java │ │ │ │ │ └── Sum.java │ │ │ │ └── json │ │ │ │ └── tests │ │ │ │ ├── ConvertTypesTest.java │ │ │ │ ├── GCKnockoutTest.java │ │ │ │ ├── JSONTest.java │ │ │ │ ├── KnockoutTest.java │ │ │ │ ├── MinesTest.java │ │ │ │ ├── ObtainAndComputeTest.java │ │ │ │ ├── OperationsTest.java │ │ │ │ ├── PairModel.java │ │ │ │ ├── PersonImpl.java │ │ │ │ ├── PhaseExecutor.java │ │ │ │ ├── Sex.java │ │ │ │ ├── SimpleMap.java │ │ │ │ ├── Utils.java │ │ │ │ └── WebSocketTest.java │ │ └── org │ │ │ └── netbeans │ │ │ └── html │ │ │ └── json │ │ │ └── tck │ │ │ ├── JavaScriptTCK.java │ │ │ ├── KOTest.java │ │ │ ├── KnockoutTCK.java │ │ │ └── package.html │ └── resources │ │ └── net │ │ └── java │ │ └── html │ │ └── js │ │ └── tests │ │ ├── addHello.js │ │ ├── addWorld.js │ │ ├── global.js │ │ ├── global2.js │ │ └── initArray.js │ └── test │ └── java │ └── net │ └── java │ └── html │ ├── js │ └── tests │ │ ├── BodiesTest.java │ │ └── ResourceOrderTest.java │ └── json │ └── tests │ └── PairModelTest.java ├── json ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── net │ │ │ └── java │ │ │ │ └── html │ │ │ │ └── json │ │ │ │ ├── ComputedProperty.java │ │ │ │ ├── FakeModel.java │ │ │ │ ├── Function.java │ │ │ │ ├── Model.java │ │ │ │ ├── ModelOperation.java │ │ │ │ ├── Models.java │ │ │ │ ├── OnPropertyChange.java │ │ │ │ ├── OnReceive.java │ │ │ │ ├── Property.java │ │ │ │ ├── doc-files │ │ │ │ ├── DukeHTML.png │ │ │ │ ├── html4j.png │ │ │ │ └── websockets.html │ │ │ │ └── package.html │ │ └── org │ │ │ └── netbeans │ │ │ └── html │ │ │ └── json │ │ │ ├── impl │ │ │ ├── Bindings.java │ │ │ ├── ClassValueTypes.java │ │ │ ├── JSON.java │ │ │ ├── JSONList.java │ │ │ ├── LinkedListTypes.java │ │ │ ├── ModelProcessor.java │ │ │ ├── ModelTypes.java │ │ │ ├── PropertyBindingAccessor.java │ │ │ ├── RcvrJSON.java │ │ │ ├── Reactive.java │ │ │ ├── ReactiveTech.java │ │ │ ├── ReactiveType.java │ │ │ ├── SimpleList.java │ │ │ └── Transitive.java │ │ │ └── spi │ │ │ ├── FunctionBinding.java │ │ │ ├── JSONCall.java │ │ │ ├── Observers.java │ │ │ ├── PropertyBinding.java │ │ │ ├── Proto.java │ │ │ ├── Technology.java │ │ │ ├── Transfer.java │ │ │ ├── WSTransfer.java │ │ │ └── package.html │ └── resources │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── json │ │ └── impl │ │ └── Bundle.properties │ └── test │ └── java │ ├── net │ └── java │ │ └── html │ │ └── json │ │ ├── AdressTest.java │ │ ├── BoardTest.java │ │ ├── BooleanArrayTest.java │ │ ├── Compile.java │ │ ├── ComputedChainTest.java │ │ ├── KeywordsTest.java │ │ ├── MapModelNotMutableTest.java │ │ ├── MapModelTest.java │ │ ├── ModelProcessorTest.java │ │ ├── ModelTest.java │ │ ├── ModelsTest.java │ │ ├── OperationTest.java │ │ ├── PersonImpl.java │ │ ├── PowerTest.java │ │ ├── PrimitiveArrayTest.java │ │ ├── ReactionChainTest.java │ │ ├── ReactionTest.java │ │ ├── Sex.java │ │ ├── SexTest.java │ │ ├── SquaresTest.java │ │ ├── TypesTest.java │ │ ├── UnderscoreTest.java │ │ ├── VarArgTest.java │ │ ├── WebSocketCallTest.java │ │ └── sub │ │ ├── StreetCntrl.java │ │ └── TelephoneCntrl.java │ └── org │ └── netbeans │ └── html │ └── json │ ├── impl │ ├── BuilderTest.java │ ├── ConstructorTest.java │ ├── DeepChangeTest.java │ ├── DependsChangeTest.java │ ├── EmployeeImpl.java │ ├── EmployerTest.java │ ├── InfinityTest.java │ ├── InnerTest.java │ ├── JSONListTest.java │ ├── JSONTest.java │ ├── NoPropertiesTest.java │ ├── OnReceiveTest.java │ ├── ParallelChangeTest.java │ ├── SimpleListTest.java │ ├── ToDoTest.java │ └── WritablePropertyTest.java │ └── spi │ └── ProtoTest.java ├── ko-felix-test ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── ko │ │ └── felix │ │ └── test │ │ └── KnockoutFelixTCKImpl.java │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── ko │ │ └── felix │ │ └── test │ │ ├── DynamicHTTP.java │ │ ├── KOFx.java │ │ ├── KnockoutFelixAriesIT.java │ │ └── KnockoutFelixIT.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── ko │ └── felix │ └── test │ └── test.html ├── ko-osgi-test ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── ko │ │ └── osgi │ │ └── test │ │ └── KnockoutEquinoxTCKImpl.java │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── ko │ │ └── osgi │ │ └── test │ │ ├── DynamicHTTP.java │ │ ├── KOFx.java │ │ └── KnockoutEquinoxIT.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── ko │ └── osgi │ └── test │ └── test.html ├── ko-ws-tyrus ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── wstyrus │ │ ├── LoadJSON.java │ │ └── TyrusContext.java │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── wstyrus │ │ ├── TyrusDynamicHTTP.java │ │ ├── TyrusFX.java │ │ └── TyrusKnockoutTest.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── wstyrus │ └── test.html ├── ko4j ├── pom.xml └── src │ ├── main │ ├── appended-resources │ │ └── META-INF │ │ │ ├── DEPENDENCIES │ │ │ └── LICENSE │ ├── java │ │ └── org │ │ │ └── netbeans │ │ │ └── html │ │ │ └── ko4j │ │ │ ├── CacheObjs.java │ │ │ ├── KO4J.java │ │ │ ├── KOSockets.java │ │ │ ├── KOTech.java │ │ │ ├── KOTransfer.java │ │ │ ├── Knockout.java │ │ │ ├── LoadJSON.java │ │ │ ├── LoadWS.java │ │ │ └── MapObjs.java │ └── resources │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── ko4j │ │ └── knockout-3.5.0.js │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── ko4j │ │ ├── DoubleViewTest.java │ │ ├── DumpStack.java │ │ ├── DynamicHTTP.java │ │ ├── InitializeKnockoutTest.java │ │ ├── KOFx.java │ │ ├── KnockoutFXTest.java │ │ ├── LessCallbacksCheck.java │ │ ├── LicenseTest.java │ │ ├── MapObjsTest.java │ │ ├── OffThreadInitializationTest.java │ │ └── ReferenceKnockoutTest.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── ko4j │ ├── double.html │ └── test.html ├── pom.xml ├── renderer ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── netbeans │ └── html │ └── presenters │ └── render │ ├── AWT.java │ ├── Cocoa.java │ ├── GTK.java │ ├── JSC.java │ ├── Show.java │ └── package-info.java ├── sound ├── pom.xml └── src │ ├── main │ └── java │ │ ├── net │ │ └── java │ │ │ └── html │ │ │ └── sound │ │ │ ├── AudioClip.java │ │ │ └── package.html │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── sound │ │ ├── impl │ │ └── BrowserAudioEnv.java │ │ └── spi │ │ ├── AudioEnvironment.java │ │ └── package.html │ └── test │ └── java │ └── net │ └── java │ └── html │ └── sound │ └── AudioClipTest.java ├── src └── main │ └── javadoc │ ├── overview.html │ └── resources │ └── teavm.js ├── webkit ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── netbeans │ │ └── html │ │ └── presenters │ │ └── webkit │ │ ├── UnJarResources.java │ │ ├── WebKitPresenter.java │ │ └── package-info.java │ └── test │ ├── java │ └── org │ │ └── netbeans │ │ └── html │ │ └── presenters │ │ └── webkit │ │ ├── Case.java │ │ ├── DynamicHTTP.java │ │ ├── GtkJavaScriptTest.java │ │ ├── GtkKnockoutTest.java │ │ ├── Skip.java │ │ └── Timeout.java │ └── resources │ └── org │ └── netbeans │ └── html │ └── presenters │ └── webkit │ └── empty.html └── xhr4j ├── pom.xml └── src ├── main └── java │ └── org │ └── netbeans │ └── html │ └── xhr4j │ ├── LoadJSON.java │ └── XmlHttpResourceContext.java └── test ├── java └── org │ └── netbeans │ └── html │ └── xhr4j │ ├── JsonDynamicHTTP.java │ ├── JsonFX.java │ └── JsonKnockoutTest.java └── resources └── org └── netbeans └── html └── xhr4j └── test.html /.github/workflows/javadoc.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | name: Javadoc 21 | 22 | on: 23 | push: 24 | branches: [ master ] 25 | pull_request: 26 | branches: [ master ] 27 | 28 | jobs: 29 | build: 30 | 31 | runs-on: ${{ matrix.os }} 32 | strategy: 33 | matrix: 34 | java: [ '17' ] 35 | os: [ ubuntu-22.04 ] 36 | 37 | steps: 38 | - uses: actions/checkout@v2 39 | - name: Set up Java 40 | uses: actions/setup-java@v2 41 | with: 42 | distribution: 'zulu' 43 | java-version: ${{ matrix.java }} 44 | 45 | - name: Build 46 | run: mvn -q install -DskipTests 47 | 48 | - name: Javadoc 49 | run: mvn -q "javadoc:aggregate" 50 | -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | name: Linux 21 | 22 | on: 23 | push: 24 | branches: [ master ] 25 | pull_request: 26 | branches: [ master ] 27 | 28 | jobs: 29 | build: 30 | 31 | runs-on: ${{ matrix.os }} 32 | strategy: 33 | matrix: 34 | java: [ '8', '11', '17', '21' ] 35 | os: [ ubuntu-22.04 ] 36 | 37 | steps: 38 | - uses: actions/checkout@v2 39 | - name: Set up Java 40 | uses: actions/setup-java@v2 41 | with: 42 | distribution: 'zulu' 43 | java-version: ${{ matrix.java }} 44 | 45 | - name: Build with Maven 46 | run: mvn -q install -DskipTests 47 | 48 | - name: Run tests 49 | run: xvfb-run -a mvn -q verify "-Dorg.netbeans.html.Generic.wait4js=true" "-DskipBrowserTests=true" 50 | -------------------------------------------------------------------------------- /.github/workflows/mac.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | name: Mac OS X 21 | 22 | on: 23 | push: 24 | branches: [ master ] 25 | pull_request: 26 | branches: [ master ] 27 | 28 | jobs: 29 | build: 30 | 31 | runs-on: ${{ matrix.os }} 32 | strategy: 33 | matrix: 34 | java: [ '11', '17' ] 35 | os: [ macos-14 ] 36 | 37 | steps: 38 | - uses: actions/checkout@v2 39 | - name: Set up Java 40 | uses: actions/setup-java@v2 41 | with: 42 | distribution: 'zulu' 43 | java-version: ${{ matrix.java }} 44 | 45 | - name: Build with Maven 46 | run: mvn -q install -DskipTests 47 | 48 | - name: Run tests 49 | run: mvn -q verify "-Dorg.netbeans.html.Generic.wait4js=true" 50 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | name: Windows 21 | 22 | on: 23 | push: 24 | branches: [ master ] 25 | pull_request: 26 | branches: [ master ] 27 | 28 | jobs: 29 | build: 30 | 31 | runs-on: ${{ matrix.os }} 32 | strategy: 33 | matrix: 34 | java: [ '8', '11', '17', '21' ] 35 | os: [ windows-2022 ] 36 | 37 | steps: 38 | - uses: actions/checkout@v2 39 | - name: Set up Java 40 | uses: actions/setup-java@v2 41 | with: 42 | distribution: 'zulu' 43 | java-version: ${{ matrix.java }} 44 | 45 | - name: Build with Maven 46 | run: mvn -q install -DskipTests 47 | 48 | - name: Run tests 49 | run: mvn -q verify "-Dorg.netbeans.html.Generic.wait4js=true" "-DskipBrowserTests=true" 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | */target/ 2 | /target/ 3 | *.orig 4 | */nb-configuration.xml 5 | */dependency-reduced-pom.xml 6 | */nbactions.xml 7 | /html4j-maven-plugin/src/test/resources/org/netbeans/html/mojo/gradle*/build/* 8 | /html4j-maven-plugin/src/test/resources/org/netbeans/html/mojo/gradle*/.gradle/* 9 | /html4j-maven-plugin/src/test/resources/org/netbeans/html/mojo/gradle*/.nb*gradle/* 10 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Licensed to the Apache Software Foundation (ASF) under one 2 | or more contributor license agreements. See the NOTICE file 3 | distributed with this work for additional information 4 | regarding copyright ownership. The ASF licenses this file 5 | to you under the Apache License, Version 2.0 (the 6 | "License"); you may not use this file except in compliance 7 | with the License. You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, 12 | software distributed under the License is distributed on an 13 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, either express or implied. See the License for the 15 | specific language governing permissions and limitations 16 | under the License. 17 | -------------------------------------------------------------------------------- /Jenkinsfile.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | asfStandardBuild jdk:"jdk_15_latest",xvfb:true,cmdline:"clean -DskipTests javadoc:aggregate site:jar install" 21 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Apache NetBeans HTML/Java API 2 | Copyright 2017-2025 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | 7 | The initial code is based on NetBeans HTML/Java API modules kindly 8 | donated by Oracle Corp to the Apache Software Foundation. 9 | -------------------------------------------------------------------------------- /boot-agent-test/src/test/java/org/netbeans/html/bootagent/AgentBootstrapTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.bootagent; 20 | 21 | import java.lang.reflect.Method; 22 | import java.lang.reflect.Modifier; 23 | import java.util.ArrayList; 24 | import net.java.html.boot.script.Scripts; 25 | import static org.testng.AssertJUnit.assertNotNull; 26 | import org.testng.annotations.Factory; 27 | 28 | /** 29 | * 30 | * @author Jaroslav Tulach 31 | */ 32 | public class AgentBootstrapTest { 33 | public AgentBootstrapTest() { 34 | } 35 | 36 | @Factory 37 | public static Object[] compatibilityTests() throws Exception { 38 | var presenter = Scripts.newPresenter().build(); 39 | assertNotNull("Presenter has been initialized", presenter); 40 | 41 | var res = new ArrayList(); 42 | 43 | Class[] arr = new Class[] { JavaScriptBodyTst.class }; 44 | for (Class c : arr) { 45 | for (Method m : c.getDeclaredMethods()) { 46 | if ((m.getModifiers() & Modifier.PUBLIC) != 0) { 47 | res.add(new KOFx(presenter, m)); 48 | } 49 | } 50 | } 51 | return res.toArray(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Bootstrap Dynamically 25 | 26 | 27 | 28 | 29 |
Bootstrap Dynamically
30 | 31 | 32 | -------------------------------------------------------------------------------- /boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Licensed to the Apache Software Foundation (ASF) under one 4 | or more contributor license agreements. See the NOTICE file 5 | distributed with this work for additional information 6 | regarding copyright ownership. The ASF licenses this file 7 | to you under the Apache License, Version 2.0 (the 8 | "License"); you may not use this file except in compliance 9 | with the License. You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, 14 | software distributed under the License is distributed on an 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | KIND, either express or implied. See the License for the 17 | specific language governing permissions and limitations 18 | under the License. 19 | 20 | */ 21 | this.empty = true; 22 | -------------------------------------------------------------------------------- /boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty_2.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Licensed to the Apache Software Foundation (ASF) under one 4 | or more contributor license agreements. See the NOTICE file 5 | distributed with this work for additional information 6 | regarding copyright ownership. The ASF licenses this file 7 | to you under the Apache License, Version 2.0 (the 8 | "License"); you may not use this file except in compliance 9 | with the License. You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, 14 | software distributed under the License is distributed on an 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | KIND, either express or implied. See the License for the 17 | specific language governing permissions and limitations 18 | under the License. 19 | 20 | */ 21 | this.empty2 = true; 22 | -------------------------------------------------------------------------------- /boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty_3.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Licensed to the Apache Software Foundation (ASF) under one 4 | or more contributor license agreements. See the NOTICE file 5 | distributed with this work for additional information 6 | regarding copyright ownership. The ASF licenses this file 7 | to you under the Apache License, Version 2.0 (the 8 | "License"); you may not use this file except in compliance 9 | with the License. You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, 14 | software distributed under the License is distributed on an 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | KIND, either express or implied. See the License for the 17 | specific language governing permissions and limitations 18 | under the License. 19 | 20 | */ 21 | this.empty3 = true; 22 | -------------------------------------------------------------------------------- /boot-fx/src/main/java/net/java/html/boot/fx/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 |

23 | Implementation of {@link net.java.html.boot.BrowserBuilder} that renders 24 | using JavaFX WebView and additional {@link net.java.html.boot.fx.FXBrowsers utilities} 25 | to configure individual WebViews. 26 |

27 | 28 | -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/Bundle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | AlertTitle=Warning 21 | AlertCloseButton=Close 22 | 23 | ConfirmTitle=Question 24 | ConfirmOKButton=OK 25 | ConfirmCancelButton=Cancel 26 | 27 | PromptTitle=Question 28 | PromptOKButton=OK 29 | PromptCancelButton=Cancel 30 | 31 | -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/desktop.png -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/handheldLandscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/handheldLandscape.png -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/handheldPortrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/handheldPortrait.png -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/netbook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/netbook.png -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/selectionMode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/selectionMode.png -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/sizeToFit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/sizeToFit.png -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/tabletLandscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/tabletLandscape.png -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/tabletPortrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/tabletPortrait.png -------------------------------------------------------------------------------- /boot-fx/src/main/resources/org/netbeans/html/boot/fx/widescreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/boot-fx/src/main/resources/org/netbeans/html/boot/fx/widescreen.png -------------------------------------------------------------------------------- /boot-fx/src/test/java/org/netbeans/html/boot/fx/DbgrTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.fx; 20 | 21 | import java.util.concurrent.CountDownLatch; 22 | import javafx.application.Platform; 23 | import javafx.scene.web.WebEngine; 24 | import javafx.scene.web.WebView; 25 | import javafx.util.Callback; 26 | import static org.testng.Assert.assertNotNull; 27 | import org.testng.annotations.Test; 28 | 29 | public class DbgrTest implements Callback { 30 | 31 | public DbgrTest() { 32 | } 33 | 34 | @Test 35 | public void initializeDebuggerForWebView() throws Exception { 36 | Dbgr[] instance = { null }; 37 | CountDownLatch cdl = new CountDownLatch(1); 38 | Platform.runLater(() -> { 39 | WebView wv = new WebView(); 40 | WebEngine engine = wv.getEngine(); 41 | instance[0] = new Dbgr(engine, this); 42 | cdl.countDown(); 43 | }); 44 | 45 | cdl.await(); 46 | assertNotNull(instance[0], "Instance of Dbgr class created"); 47 | assertNotNull(instance[0].dbg, "Debugger initialized"); 48 | assertNotNull(instance[0].sendMsg, "Send method initialized"); 49 | } 50 | 51 | @Override 52 | public Void call(String p) { 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /boot-fx/src/test/java/org/netbeans/html/boot/fx/FXBrwsrTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.fx; 20 | 21 | import org.sample.app.pkg.SampleApp; 22 | import static org.testng.Assert.assertEquals; 23 | import org.testng.annotations.Test; 24 | 25 | public class FXBrwsrTest { 26 | 27 | public FXBrwsrTest() { 28 | } 29 | 30 | @Test 31 | public void testFindCalleeClassName() throws InterruptedException { 32 | String callee = invokeMain(); 33 | assertEquals(callee, SampleApp.class.getName(), "Callee is found correctly"); 34 | } 35 | 36 | synchronized static String invokeMain() throws InterruptedException { 37 | new Thread("starting main") { 38 | @Override 39 | public void run() { 40 | SampleApp.main(); 41 | } 42 | }.start(); 43 | for (;;) { 44 | String callee = System.getProperty("callee"); 45 | if (callee != null) { 46 | return callee; 47 | } 48 | FXBrwsrTest.class.wait(); 49 | } 50 | } 51 | 52 | 53 | public static void computeCalleeClassName() { 54 | String name = FXBrwsr.findCalleeClassName(); 55 | System.setProperty("callee", name); 56 | synchronized (FXBrwsrTest.class) { 57 | FXBrwsrTest.class.notifyAll(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /boot-fx/src/test/java/org/netbeans/html/boot/fx/FxJavaScriptTst.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.fx; 20 | 21 | import org.netbeans.html.json.tck.JavaScriptTCK; 22 | 23 | /** 24 | * 25 | * @author Jaroslav Tulach 26 | */ 27 | public final class FxJavaScriptTst extends JavaScriptTCK { 28 | public static Class[] tests() { 29 | return testClasses(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /boot-fx/src/test/java/org/netbeans/html/boot/fx/PeriodicalyTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.fx; 20 | 21 | import java.util.concurrent.Executors; 22 | import net.java.html.boot.BrowserBuilder; 23 | import org.testng.annotations.Test; 24 | 25 | public final class PeriodicalyTest { 26 | @Test 27 | public void runPeriodically() throws Exception { 28 | final BrowserBuilder bb = BrowserBuilder.newBrowser(new FXPresenter()) 29 | .loadPage("empty.html") 30 | .loadClass(Periodicaly.class) 31 | .invoke("onPageLoad"); 32 | Executors.newSingleThreadExecutor().execute(new Runnable() { 33 | @Override 34 | public void run() { 35 | bb.showAndWait(); 36 | } 37 | }); 38 | Periodicaly.assertTen(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /boot-fx/src/test/java/org/netbeans/html/boot/fx/TestingProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.fx; 20 | 21 | import org.netbeans.html.context.spi.Contexts; 22 | import org.openide.util.lookup.ServiceProvider; 23 | import static org.testng.Assert.assertTrue; 24 | 25 | /** 26 | * 27 | * @author Jaroslav Tulach 28 | */ 29 | @ServiceProvider(service = Contexts.Provider.class) 30 | public final class TestingProvider implements Contexts.Provider { 31 | 32 | static void assertCalled(String msg) { 33 | assertTrue(Boolean.getBoolean(TestingProvider.class.getName()), msg); 34 | } 35 | 36 | @Override 37 | public void fillContext(Contexts.Builder context, Class requestor) { 38 | System.setProperty(TestingProvider.class.getName(), "true"); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /boot-fx/src/test/java/org/sample/app/pkg/SampleApp.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.sample.app.pkg; 20 | 21 | import net.java.html.boot.BrowserBuilder; 22 | import org.netbeans.html.boot.fx.FXBrwsrTest; 23 | 24 | public class SampleApp implements Runnable { 25 | 26 | public static void main() { 27 | BrowserBuilder.newBrowser() 28 | .loadPage("org/netbeans/html/boot/fx/empty.html") // NOI18N 29 | .loadFinished(new SampleApp()) 30 | .showAndWait(); 31 | } 32 | 33 | @Override 34 | public void run() { 35 | FXBrwsrTest.computeCalleeClassName(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /boot-fx/src/test/resources/net/java/html/boot/fx/wnd.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | if (typeof wnd !== 'undefined') { 20 | throw 'Window should not be defined yet: ' + wnd; 21 | } 22 | 23 | wnd = { 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /boot-fx/src/test/resources/org/netbeans/html/boot/fx/empty.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | FX Presenter Harness 25 | 26 | 27 | 28 | 29 |
FX Presenter Harness
30 | 31 | 32 | -------------------------------------------------------------------------------- /boot-fx/src/test/resources/org/netbeans/html/boot/fx/second.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Second Window 25 | 26 | 27 | 28 | 29 |
Second Window
30 | 31 | 32 | -------------------------------------------------------------------------------- /boot-script/src/main/java/net/java/html/boot/script/impl/Callback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package net.java.html.boot.script.impl; 21 | 22 | public abstract class Callback { 23 | public abstract void callback(Object obj); 24 | } 25 | -------------------------------------------------------------------------------- /boot-script/src/main/java/net/java/html/boot/script/impl/PromisePolyfill.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.boot.script.impl; 20 | 21 | import java.io.IOException; 22 | import java.io.InputStreamReader; 23 | import java.util.concurrent.CompletableFuture; 24 | import java.util.concurrent.Executor; 25 | import javax.script.Invocable; 26 | import javax.script.ScriptEngine; 27 | import javax.script.ScriptException; 28 | 29 | public final class PromisePolyfill { 30 | private PromisePolyfill() { 31 | } 32 | 33 | public static void initialize(ScriptEngine eng, Executor pool) { 34 | try ( InputStreamReader r = new InputStreamReader( 35 | PromisePolyfill.class.getResourceAsStream("promisePolyfill.js")) 36 | ) { 37 | if ("undefined".equals(eng.eval("typeof Promise"))) { 38 | Object fn = eng.eval(r); 39 | ((Invocable) eng).invokeMethod(fn, "call", null, PromisePolyfill.class); 40 | } 41 | } catch (IOException | NoSuchMethodException | ScriptException ex) { 42 | throw new IllegalStateException("Cannot install Promise polyfill into Nashorn", ex); 43 | } 44 | 45 | } 46 | 47 | public static boolean isFuture(Object obj) { 48 | return obj instanceof CompletableFuture; 49 | } 50 | 51 | public static CompletableFuture create() { 52 | CompletableFuture future = new CompletableFuture<>(); 53 | return future; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /boot-script/src/main/java/net/java/html/boot/script/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 |

23 | {@link net.java.html.boot.script.Scripts Factories} to create headless 24 | {@link net.java.html.boot.BrowserBuilder browser environment} which is 25 | useful for testing. 26 |

27 | 28 | -------------------------------------------------------------------------------- /boot-script/src/main/resources/net/java/html/boot/script/impl/promisePolyfill.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | (function (PromisePolyfillClass) { 21 | var global = (0 || eval)('this'); 22 | var promisePolyfill = PromisePolyfillClass.static; 23 | 24 | var Promise = function (resolver) { 25 | if (promisePolyfill.isFuture(resolver)) { 26 | this._future = resolver; 27 | } else { 28 | var future = promisePolyfill.create(); 29 | resolver(function(value) { 30 | future.complete(value); 31 | }, function(error) { 32 | future.completeExceptionally(error); 33 | }); 34 | this._future = future; 35 | } 36 | }; 37 | 38 | Promise.resolve = function (value) { 39 | if (value instanceof Promise) { 40 | return value; 41 | } else { 42 | return new Promise(function(success) { 43 | success(value); 44 | }); 45 | } 46 | }; 47 | 48 | Promise.prototype.then = function (success, error) { 49 | var future = this._future; 50 | if (success) { 51 | future = future.thenApply(success); 52 | } 53 | if (error) { 54 | future = future.exceptionally(error); 55 | } 56 | return new Promise(future); 57 | }; 58 | 59 | global.Promise = Promise; 60 | }) 61 | -------------------------------------------------------------------------------- /boot-script/src/test/java/net/java/html/boot/script/ScriptEngineJavaScriptTCK.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.boot.script; 20 | 21 | import java.lang.reflect.Method; 22 | import java.util.List; 23 | import java.util.function.Function; 24 | import org.netbeans.html.json.tck.JavaScriptTCK; 25 | import org.netbeans.html.json.tck.KOTest; 26 | 27 | /** 28 | * 29 | * @author Jaroslav Tulach 30 | */ 31 | // BEGIN: net.java.html.boot.script.ScriptEngineJavaScriptTCK 32 | public final class ScriptEngineJavaScriptTCK extends JavaScriptTCK { 33 | static void collectTckTests(List res, Function factory) { 34 | for (Class c : testClasses()) { 35 | for (Method m : c.getMethods()) { 36 | if (m.getAnnotation(KOTest.class) != null) { 37 | res.add(factory.apply(m)); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | // END: net.java.html.boot.script.ScriptEngineJavaScriptTCK 44 | -------------------------------------------------------------------------------- /boot-script/src/test/resources/net/java/html/boot/script/test.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Knockout.fx Execution Harness 25 | 26 | 27 | 28 | 29 |

Knockout in Env.Execution Harness

30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /boot-truffle/empty.sigtest: -------------------------------------------------------------------------------- 1 | #Signature file v4.1 2 | #Version 2.0-SNAPSHOT 3 | 4 | CLSS public java.lang.Object 5 | cons public init() 6 | meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException 7 | meth protected void finalize() throws java.lang.Throwable 8 | meth public boolean equals(java.lang.Object) 9 | meth public final java.lang.Class getClass() 10 | meth public final void notify() 11 | meth public final void notifyAll() 12 | meth public final void wait() throws java.lang.InterruptedException 13 | meth public final void wait(long) throws java.lang.InterruptedException 14 | meth public final void wait(long,int) throws java.lang.InterruptedException 15 | meth public int hashCode() 16 | meth public java.lang.String toString() 17 | 18 | CLSS public final net.java.html.boot.truffle.TrufflePresenters 19 | meth public static org.netbeans.html.boot.spi.Fn$Presenter create(java.util.concurrent.Executor) 20 | supr java.lang.Object 21 | 22 | -------------------------------------------------------------------------------- /boot-truffle/src/main/java/net/java/html/boot/truffle/IsArrayNode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.boot.truffle; 20 | 21 | import com.oracle.truffle.api.TruffleLanguage; 22 | import com.oracle.truffle.api.frame.VirtualFrame; 23 | import com.oracle.truffle.api.interop.ForeignAccess; 24 | import com.oracle.truffle.api.interop.Message; 25 | import com.oracle.truffle.api.interop.TruffleObject; 26 | import com.oracle.truffle.api.nodes.Node; 27 | import com.oracle.truffle.api.nodes.RootNode; 28 | 29 | final class IsArrayNode extends RootNode { 30 | @Child 31 | private Node check; 32 | 33 | IsArrayNode() { 34 | super(TruffleLanguage.class, null, null); 35 | this.check = Message.HAS_SIZE.createNode(); 36 | } 37 | 38 | @Override 39 | public Object execute(VirtualFrame frame) { 40 | final Object[] args = frame.getArguments(); 41 | Object result = ForeignAccess.sendHasSize(check, frame, (TruffleObject) args[0]); 42 | return result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /boot-truffle/src/main/java/net/java/html/boot/truffle/IsNullNode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.boot.truffle; 20 | 21 | import com.oracle.truffle.api.TruffleLanguage; 22 | import com.oracle.truffle.api.frame.VirtualFrame; 23 | import com.oracle.truffle.api.interop.ForeignAccess; 24 | import com.oracle.truffle.api.interop.Message; 25 | import com.oracle.truffle.api.interop.TruffleObject; 26 | import com.oracle.truffle.api.nodes.Node; 27 | import com.oracle.truffle.api.nodes.RootNode; 28 | 29 | final class IsNullNode extends RootNode { 30 | @Child 31 | private Node check; 32 | 33 | IsNullNode() { 34 | super(TruffleLanguage.class, null, null); 35 | this.check = Message.IS_NULL.createNode(); 36 | } 37 | 38 | @Override 39 | public Object execute(VirtualFrame frame) { 40 | final Object[] args = frame.getArguments(); 41 | Object result = ForeignAccess.sendIsNull(check, frame, (TruffleObject) args[0]); 42 | return result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /boot-truffle/src/main/java/net/java/html/boot/truffle/TrufflePresenters.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.boot.truffle; 20 | 21 | import java.util.concurrent.Executor; 22 | import org.netbeans.html.boot.spi.Fn; 23 | 24 | 25 | /** Integration with Truffle and 26 | * GraalVM. 27 | * 28 | * @since 1.4 29 | */ 30 | public final class TrufflePresenters { 31 | private TrufflePresenters() { 32 | } 33 | 34 | /** Creates new instance of Truffle based presenter. 35 | * 36 | * @param executor the executor to run requests in 37 | * @return new instance of the presenter 38 | */ 39 | public static Fn.Presenter create(Executor executor) { 40 | return new TrufflePresenter(executor, null); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /boot-truffle/src/main/java/net/java/html/boot/truffle/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 |

23 | Integration with Truffle 24 | useful to execute against node.js running on top of 25 | the GraalVM. 26 |

27 | 28 | -------------------------------------------------------------------------------- /boot/src/main/java/net/java/html/boot/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 |
{@link net.java.html.boot.BrowserBuilder Builder} class to bootstrap your Java/HTML based application.
25 | See {@link net.java.html.boot.BrowserBuilder} for description how to 26 | launch your application. Look at {@link net.java.html.js.JavaScriptBody} 27 | and its usage in case you want to directly talk between Java and 28 | JavaScript. 29 | 30 | 31 | -------------------------------------------------------------------------------- /boot/src/main/java/org/netbeans/html/boot/impl/FindResources.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.impl; 20 | 21 | import java.net.URL; 22 | import java.util.Collection; 23 | 24 | /** 25 | * 26 | * @author Jaroslav Tulach 27 | */ 28 | public interface FindResources { 29 | 30 | public void findResources(String path, Collection results, boolean oneIsEnough); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /boot/src/main/java/org/netbeans/html/boot/impl/JsClassLoader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.impl; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | 23 | /** Marker class to help us recognize we assigned classloader is 24 | * capable to handle {@link JavaScriptBody} annotated methods. 25 | * 26 | * @author Jaroslav Tulach 27 | */ 28 | abstract class JsClassLoader extends ClassLoader { 29 | JsClassLoader(ClassLoader parent) { 30 | super(parent); 31 | setDefaultAssertionStatus(JsClassLoader.class.desiredAssertionStatus()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /boot/src/main/java/org/netbeans/html/boot/spi/FallbackIdentity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.spi; 20 | 21 | import java.lang.ref.WeakReference; 22 | 23 | final class FallbackIdentity extends WeakReference implements Fn.Ref { 24 | private final int hashCode; 25 | 26 | FallbackIdentity(Fn.Presenter p) { 27 | super(p); 28 | this.hashCode = p.hashCode(); 29 | } 30 | 31 | @Override 32 | public Fn.Ref reference() { 33 | return this; 34 | } 35 | 36 | @Override 37 | public Fn.Presenter presenter() { 38 | return get(); 39 | } 40 | 41 | @Override 42 | public int hashCode() { 43 | return hashCode; 44 | } 45 | 46 | @Override 47 | public boolean equals(Object obj) { 48 | if (obj == this) { 49 | return true; 50 | } 51 | if (obj instanceof FallbackIdentity) { 52 | return ((FallbackIdentity) obj).presenter() == presenter(); 53 | } 54 | return false; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /boot/src/main/java/org/netbeans/html/boot/spi/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 |
Interfaces for integrators of various execution environments.
25 | Not really interesting for clients. The clients should rather use 26 | {@link net.java.html.boot.BrowserBuilder} to launch their applications, 27 | or (if they need to do some JavaScript calls themselves) look at 28 | {@link net.java.html.js.JavaScriptBody} annotation and its usage. 29 | 30 | 31 | -------------------------------------------------------------------------------- /boot/src/main/resources/net/java/html/boot/html4j.txt: -------------------------------------------------------------------------------- 1 | ==== 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | ==== 19 | 20 | -------------------------------------------------------------------------------- /boot/src/test/java/org/netbeans/html/boot/impl/Arithm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.impl; 20 | 21 | /** 22 | * 23 | * @author Jaroslav Tulach 24 | */ 25 | public class Arithm { 26 | private Arithm() { 27 | } 28 | 29 | public int sumTwo(int a, int b) { 30 | return a + b; 31 | } 32 | 33 | public int sumArr(java.lang.Object[] arr) { 34 | Integer[] copy = new Integer[arr.length]; 35 | for (int i = 0; i < arr.length; i++) { 36 | copy[i] = ((Number)arr[i]).intValue(); 37 | } 38 | return 0; 39 | } 40 | 41 | public static Arithm create() { 42 | return new Arithm(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /boot/src/test/java/org/netbeans/html/boot/impl/JsCallbackTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.impl; 20 | 21 | import static org.testng.Assert.*; 22 | import org.testng.annotations.Test; 23 | 24 | /** Verify behavior of the callback parser. 25 | * 26 | * @author Jaroslav Tulach 27 | */ 28 | public class JsCallbackTest { 29 | 30 | public JsCallbackTest() { 31 | } 32 | @Test public void missingTypeSpecification() { 33 | String body = """ 34 | console[attr] = function(msg) { 35 | @org.netbeans.html.charts.Main::log(msg); 36 | }; 37 | """; 38 | JsCallback instance = new JsCallbackImpl(); 39 | try { 40 | String result = instance.parse(body, false); 41 | fail("The parsing should fail!"); 42 | } catch (IllegalStateException ex) { 43 | // OK 44 | } 45 | } 46 | 47 | 48 | public class JsCallbackImpl extends JsCallback { 49 | private String ident; 50 | private String fqn; 51 | private String method; 52 | private String params; 53 | 54 | @Override 55 | public CharSequence callMethod(String ident, boolean promise, String fqn, String method, String params) { 56 | this.ident = ident; 57 | this.fqn = fqn; 58 | this.method = method; 59 | this.params = params; 60 | return "call"; 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /boot/src/test/java/org/netbeans/html/boot/impl/Object.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.boot.impl; 20 | 21 | /** Fake class to cause confusion in the generated code and force it 22 | * to use fully qualified names 23 | */ 24 | final class Object { 25 | } 26 | -------------------------------------------------------------------------------- /boot/src/test/resources/org/netbeans/html/boot/impl/empty.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | -------------------------------------------------------------------------------- /boot/src/test/resources/org/netbeans/html/boot/impl/jsmethods.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | function mul(x, y) { return x * y; } 20 | -------------------------------------------------------------------------------- /browser/src/main/java/org/netbeans/html/presenters/browser/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * Generic {@link org.netbeans.html.presenters.browser.Browser} presenter 22 | * and its {@link org.netbeans.html.presenters.browser.Browser.Config configuration}. 23 | */ 24 | package org.netbeans.html.presenters.browser; 25 | -------------------------------------------------------------------------------- /browser/src/test/java/org/netbeans/html/presenters/browser/BrowserTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.browser; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | import org.netbeans.html.json.tck.JavaScriptTCK; 24 | import org.netbeans.html.json.tck.KOTest; 25 | import org.testng.annotations.Factory; 26 | 27 | public class BrowserTest extends JavaScriptTCK { 28 | public BrowserTest() { 29 | } 30 | 31 | @Factory public static Object[] compatibilityTests() throws Exception { 32 | List res = new ArrayList<>(); 33 | ServerFactories.collect("BrowserTest", res, KOTest.class, JavaScriptTCK::testClasses); 34 | return res.toArray(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /browser/src/test/java/org/netbeans/html/presenters/browser/DumpStack.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.browser; 20 | 21 | import java.util.Map; 22 | import java.util.Timer; 23 | import java.util.TimerTask; 24 | 25 | final class DumpStack extends TimerTask { 26 | 27 | private static final Timer TIMER = new Timer("Dump Stack Watchdog"); 28 | private final long created = System.currentTimeMillis(); 29 | 30 | @Override 31 | public void run() { 32 | StringBuilder sb = new StringBuilder(); 33 | long after = (System.currentTimeMillis() - created) / 1000; 34 | sb.append("Thread dump after ").append(after).append(" s from start:\n"); 35 | for (Map.Entry info : Thread.getAllStackTraces().entrySet()) { 36 | sb.append(info.getKey().getName()).append("\n"); 37 | for (StackTraceElement e : info.getValue()) { 38 | sb.append(" ").append(e.getClassName()).append("."). 39 | append(e.getMethodName()).append("(").append(e.getFileName()). 40 | append(":").append(e.getLineNumber()).append(")\n"); 41 | } 42 | } 43 | System.err.println(sb.toString()); 44 | } 45 | 46 | public static void initialize() { 47 | final int minute = 60000; 48 | TIMER.schedule(new DumpStack(), minute, 2 * minute); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /browser/src/test/java/org/netbeans/html/presenters/browser/JavaScriptUtilities.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.browser; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | 23 | final class JavaScriptUtilities { 24 | private JavaScriptUtilities() { 25 | } 26 | 27 | @JavaScriptBody(args = { }, body = 28 | """ 29 | var h; 30 | if (!!window && !!window.location && !!window.location.href) { 31 | h = window.location.href; 32 | } else { 33 | h = null; 34 | } 35 | return h; 36 | """ 37 | ) 38 | static native String findBaseURL(); 39 | 40 | @JavaScriptBody(args = {"value"}, body = "document.getElementById('loaded').innerHTML = value;") 41 | static native void setLoaded(String value); 42 | 43 | @JavaScriptBody(args = {"ms"}, body = "window.setTimeout(function() { window.close(); }, ms);") 44 | static native void closeSoon(int ms); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /browser/src/test/java/org/netbeans/html/presenters/browser/KOClose.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.browser; 20 | 21 | import java.util.concurrent.Executor; 22 | import org.netbeans.html.boot.spi.Fn; 23 | import org.testng.ITest; 24 | import org.testng.annotations.Test; 25 | 26 | public class KOClose implements ITest { 27 | 28 | private final Fn.Presenter presenter; 29 | private final String prefix; 30 | private final Fn updateName; 31 | 32 | public KOClose(Fn updateName, String prefix, Fn.Presenter presenter) { 33 | this.updateName = updateName; 34 | this.prefix = prefix; 35 | this.presenter = presenter; 36 | } 37 | 38 | @Test(dependsOnGroups = "BrowserTest") 39 | public void closeWindow() { 40 | ((Executor)this.presenter).execute(() -> { 41 | try { 42 | updateName.invoke(null, getTestName(), "5s"); 43 | } catch (Exception ex) { 44 | } 45 | JavaScriptUtilities.closeSoon(5000); 46 | }); 47 | } 48 | 49 | @Override 50 | public String getTestName() { 51 | return prefix + ": Closing window"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /browser/src/test/resources/org/netbeans/html/presenters/browser/empty.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Browser Test 25 | 26 | 27 | 28 | 29 |

Browser Test

30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /browser/src/test/resources/org/netbeans/html/presenters/browser/server.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Server 25 | 26 | 27 | 28 | 29 |

Server

30 |
31 | Loaded ? times. 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /browser/src/test/resources/org/netbeans/html/presenters/browser/test.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | -------------------------------------------------------------------------------- /browser/src/test/resources/org/netbeans/html/presenters/browser/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | -------------------------------------------------------------------------------- /browser/src/test/resources/org/netbeans/html/presenters/browser/test.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | -------------------------------------------------------------------------------- /context/src/main/java/net/java/html/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 |

23 | Representation of the {@link net.java.html.BrwsrCtx browser context}. 24 |

25 | 26 | -------------------------------------------------------------------------------- /context/src/main/java/org/netbeans/html/context/impl/CtxAccssr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.context.impl; 20 | 21 | import net.java.html.BrwsrCtx; 22 | import org.netbeans.html.context.spi.Contexts.Builder; 23 | 24 | /** Internal communication between API (e.g. {@link BrwsrCtx}), SPI 25 | * (e.g. {@link Builder}) and the implementation package. 26 | * 27 | * @author Jaroslav Tulach 28 | */ 29 | public abstract class CtxAccssr { 30 | private static CtxAccssr DEFAULT; 31 | static { 32 | // run initializers 33 | BrwsrCtx.findDefault(CtxAccssr.class); 34 | } 35 | 36 | protected CtxAccssr() { 37 | if (DEFAULT != null) throw new IllegalStateException(); 38 | DEFAULT = this; 39 | } 40 | 41 | protected abstract BrwsrCtx newContext(CtxImpl impl); 42 | protected abstract CtxImpl find(BrwsrCtx context); 43 | 44 | static CtxAccssr getDefault() { 45 | return DEFAULT; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /context/src/main/java/org/netbeans/html/context/spi/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 |

23 | Service provider classes to build {@link net.java.html.BrwsrCtx} 24 | instances. 25 |

26 | 27 | -------------------------------------------------------------------------------- /dynamic-loader-test/src/test/resources/org/netbeans/html/dynamicloader/empty.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Bootstrap Dynamically 25 | 26 | 27 | 28 | 29 |
Bootstrap Dynamically
30 | 31 | 32 | -------------------------------------------------------------------------------- /dynamic-loader-test/src/test/resources/org/netbeans/html/dynamicloader/empty.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Licensed to the Apache Software Foundation (ASF) under one 4 | or more contributor license agreements. See the NOTICE file 5 | distributed with this work for additional information 6 | regarding copyright ownership. The ASF licenses this file 7 | to you under the Apache License, Version 2.0 (the 8 | "License"); you may not use this file except in compliance 9 | with the License. You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, 14 | software distributed under the License is distributed on an 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | KIND, either express or implied. See the License for the 17 | specific language governing permissions and limitations 18 | under the License. 19 | 20 | */ 21 | this.empty = true; 22 | -------------------------------------------------------------------------------- /dynamic-loader-test/src/test/resources/org/netbeans/html/dynamicloader/empty_2.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Licensed to the Apache Software Foundation (ASF) under one 4 | or more contributor license agreements. See the NOTICE file 5 | distributed with this work for additional information 6 | regarding copyright ownership. The ASF licenses this file 7 | to you under the Apache License, Version 2.0 (the 8 | "License"); you may not use this file except in compliance 9 | with the License. You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, 14 | software distributed under the License is distributed on an 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | KIND, either express or implied. See the License for the 17 | specific language governing permissions and limitations 18 | under the License. 19 | 20 | */ 21 | this.empty2 = true; 22 | -------------------------------------------------------------------------------- /dynamic-loader-test/src/test/resources/org/netbeans/html/dynamicloader/empty_3.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Licensed to the Apache Software Foundation (ASF) under one 4 | or more contributor license agreements. See the NOTICE file 5 | distributed with this work for additional information 6 | regarding copyright ownership. The ASF licenses this file 7 | to you under the Apache License, Version 2.0 (the 8 | "License"); you may not use this file except in compliance 9 | with the License. You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, 14 | software distributed under the License is distributed on an 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | KIND, either express or implied. See the License for the 17 | specific language governing permissions and limitations 18 | under the License. 19 | 20 | */ 21 | this.empty3 = true; 22 | -------------------------------------------------------------------------------- /ecj-test/src/main/java/org/netbeans/html/ecjtest/PersonImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.ecjtest; 20 | 21 | import net.java.html.json.Model; 22 | import net.java.html.json.Property; 23 | 24 | @Model(className = "Person", targetId = "x", properties = { 25 | @Property(name = "firstName", type = String.class), 26 | @Property(name = "lastName", type = String.class), 27 | @Property(name = "sex", type = PersonImpl.Sex.class), 28 | @Property(name = "address", type = Address.class), 29 | }) 30 | final class PersonImpl { 31 | public enum Sex { 32 | MALE, FEMALE; 33 | } 34 | 35 | @Model(className = "Address", properties = { 36 | @Property(name = "street", type = String.class), 37 | @Property(name = "town", type = String.class), 38 | }) 39 | static class AddressImpl { 40 | private AddressImpl() { 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ecj-test/src/main/java/org/netbeans/html/ecjtest/dummy/Dummy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */package org.netbeans.html.ecjtest.dummy; 19 | 20 | /** Dummy class. 21 | */ 22 | public final class Dummy { 23 | private Dummy() { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ecj-test/src/test/java/org/netbeans/html/ecjtest/PersonImplTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.ecjtest; 20 | 21 | import static org.testng.Assert.*; 22 | import org.testng.annotations.Test; 23 | 24 | public class PersonImplTest { 25 | @Test 26 | @SuppressWarnings("static-method") 27 | public void testPerson() { 28 | Person p = new Person("J", "T", PersonImpl.Sex.MALE, new Address("sch", "prg")); 29 | assertEquals(p.applyBindings().getFirstName(), "J"); 30 | assertEquals(p.getAddress().getTown(), "prg"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /equinox-agentclass-hook/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 4.0.0 24 | 25 | org.netbeans.html 26 | pom 27 | 2.0-SNAPSHOT 28 | 29 | AgentClass Hook for Equinox 30 | equinox-agentclass-hook 31 | bundle 32 | 33 | 34 | 35 | org.apache.felix 36 | maven-bundle-plugin 37 | 38 | 39 | org.eclipse.osgi;bundle-version="[3.8.0,4.0)" 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.eclipse 49 | org.eclipse.osgi 50 | 3.8.0.v20120529-1548 51 | 52 | 53 | -------------------------------------------------------------------------------- /equinox-agentclass-hook/src/main/java/java/lang/Module.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package java.lang; 20 | 21 | /** Dummy */ 22 | public class Module { 23 | } 24 | -------------------------------------------------------------------------------- /equinox-agentclass-hook/src/main/resources/hookconfigurators.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | hook.configurators=org.netbeans.html.equinox.agentclass.AgentHook 21 | -------------------------------------------------------------------------------- /generic/src/main/java/org/netbeans/html/presenters/spi/Level.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.spi; 20 | 21 | /** Logging levels similar to java.util.logging ones. */ 22 | enum Level { 23 | FINE, INFO, WARNING, SEVERE; 24 | 25 | public int intValue() { 26 | switch (this) { 27 | case SEVERE: return 1000; 28 | case WARNING: return 900; 29 | case INFO: return 800; 30 | case FINE: return 500; 31 | } 32 | return 0; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /generic/src/main/java/org/netbeans/html/presenters/spi/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * The {@link org.netbeans.html.presenters.spi.ProtoPresenter prototypical presenter} 22 | * based on textual protocol between JavaScript VM and Java VM. 23 | */ 24 | package org.netbeans.html.presenters.spi; 25 | -------------------------------------------------------------------------------- /generic/src/test/java/org/netbeans/html/presenters/spi/ValueOfTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.spi; 20 | 21 | import java.net.URL; 22 | import static org.testng.Assert.*; 23 | import org.testng.annotations.BeforeMethod; 24 | import org.testng.annotations.Test; 25 | 26 | public class ValueOfTest { 27 | private Generic p; 28 | @BeforeMethod public void initInstance() { 29 | p = new Generic(true, true, "type", "app") { 30 | @Override 31 | void handleLog(Level level, String msg, Object... args) { 32 | } 33 | 34 | @Override 35 | void callbackFn(ProtoPresenterBuilder.OnPrepared onReady) { 36 | } 37 | 38 | @Override 39 | void loadJS(String js) { 40 | } 41 | 42 | @Override 43 | void dispatch(Runnable r) { 44 | } 45 | 46 | @Override 47 | public void displayPage(URL url, Runnable r) { 48 | } 49 | }; 50 | } 51 | 52 | 53 | @Test public void parseSimpleArray() { 54 | Object res = p.valueOf("array:1:8:number:6"); 55 | assertTrue(res instanceof Object[], "It is an array: " + res); 56 | Object[] arr = (Object[]) res; 57 | assertEquals(arr.length, 1, "One array item"); 58 | assertEquals(arr[0], 6.0, "Value is six"); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /generic/src/test/java/org/netbeans/html/presenters/spi/test/Counter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.spi.test; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | 23 | public final class Counter { 24 | static int calls; 25 | static int callbacks; 26 | 27 | static int count() { 28 | return ++callbacks; 29 | } 30 | 31 | public static final void registerCounter() { 32 | if (rCounter()) { 33 | callbacks = 0; 34 | } 35 | } 36 | 37 | @JavaScriptBody(args = {}, javacall = true, body = """ 38 | if (!this.counter) { 39 | this.counter = function() { return @org.netbeans.html.presenters.spi.test.Counter::count()(); }; 40 | return true; 41 | } else { 42 | return false; 43 | } 44 | """ 45 | ) 46 | private static native boolean rCounter(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /generic/src/test/java/org/netbeans/html/presenters/spi/test/DumpStack.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.spi.test; 20 | 21 | import java.util.Map; 22 | import java.util.Timer; 23 | import java.util.TimerTask; 24 | 25 | final class DumpStack extends TimerTask { 26 | 27 | private static final Timer TIMER = new Timer("Dump Stack Watchdog"); 28 | private final long created = System.currentTimeMillis(); 29 | 30 | @Override 31 | public void run() { 32 | StringBuilder sb = new StringBuilder(); 33 | long after = (System.currentTimeMillis() - created) / 1000; 34 | sb.append("Thread dump after ").append(after).append(" s from start:\n"); 35 | for (Map.Entry info : Thread.getAllStackTraces().entrySet()) { 36 | sb.append(info.getKey().getName()).append("\n"); 37 | for (StackTraceElement e : info.getValue()) { 38 | sb.append(" ").append(e.getClassName()).append("."). 39 | append(e.getMethodName()).append("(").append(e.getFileName()). 40 | append(":").append(e.getLineNumber()).append(")\n"); 41 | } 42 | } 43 | System.err.println(sb.toString()); 44 | } 45 | 46 | public static void initialize() { 47 | final int minute = 60000; 48 | TIMER.schedule(new DumpStack(), minute, 2 * minute); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /geo/src/main/java/net/java/html/geo/doc-files/GeoDuke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/geo/src/main/java/net/java/html/geo/doc-files/GeoDuke.png -------------------------------------------------------------------------------- /geo/src/main/java/net/java/html/geo/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Geolocation API for Java 25 | 26 | 27 | 28 | 29 | 30 |
31 | HTML Geo API for Java provides annotation based way of 32 | obtaining geolocation information from a browser or any other 33 | device capable of providing it. 34 | The primary way to use this API is to 35 | create a non-private method and annotate it with @OnLocation 36 | annotation. 37 |
38 | Illustrative picture 39 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /geo/src/main/java/org/netbeans/html/geo/impl/Accessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.geo.impl; 20 | 21 | import net.java.html.geo.Position; 22 | import org.netbeans.html.geo.spi.GLProvider; 23 | 24 | /** Connection between API and SPI parts of the module. 25 | * 26 | * @author Jaroslav Tulach 27 | */ 28 | public abstract class Accessor { 29 | public static Accessor SPI; 30 | static { 31 | JsGLProvider initGLProviderClass = new JsGLProvider(); 32 | } 33 | 34 | protected Accessor(boolean api) { 35 | if (!api) { 36 | assert SPI == null; 37 | SPI = this; 38 | } 39 | } 40 | 41 | public abstract Watch start( 42 | GLProvider p, Accessor peer, 43 | boolean oneTime, boolean enableHighAccuracy, 44 | long timeout, long maximumAge 45 | ); 46 | 47 | public abstract void stop(GLProvider p, Watch w); 48 | 49 | public abstract void onError(Exception ex); 50 | 51 | public abstract void onLocation(Position position); 52 | } 53 | -------------------------------------------------------------------------------- /geo/src/main/java/org/netbeans/html/geo/spi/CoordImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.geo.spi; 20 | 21 | import net.java.html.geo.Position; 22 | 23 | /** 24 | * 25 | * @author Jaroslav Tulach 26 | */ 27 | final class CoordImpl extends Position.Coordinates { 28 | private final Coords data; 29 | private final GLProvider provider; 30 | 31 | CoordImpl(Coords data, GLProvider p) { 32 | this.data = data; 33 | this.provider = p; 34 | } 35 | 36 | @Override public double getLatitude() { 37 | return provider.latitude(data); 38 | } 39 | 40 | @Override public double getLongitude() { 41 | return provider.longitude(data); 42 | } 43 | 44 | @Override public double getAccuracy() { 45 | return provider.accuracy(data); 46 | } 47 | 48 | @Override public Double getAltitude() { 49 | return provider.altitude(data); 50 | } 51 | 52 | @Override public Double getAltitudeAccuracy() { 53 | return provider.altitudeAccuracy(data); 54 | } 55 | 56 | @Override public Double getHeading() { 57 | return provider.heading(data); 58 | } 59 | 60 | @Override public Double getSpeed() { 61 | return provider.speed(data); 62 | } 63 | } // end of CoordImpl 64 | -------------------------------------------------------------------------------- /geo/src/main/java/org/netbeans/html/geo/spi/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Geolocation SPI 25 | 26 | 27 | 28 | 29 |
30 | Service provider interfaces for those willing to 31 | {@link org.netbeans.html.geo.spi.GLProvider provide their own way} 32 | of obtaining proper geolocation. 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /geo/src/test/java/org/netbeans/html/geo/impl/JsGLProviderTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.geo.impl; 20 | 21 | import net.java.html.geo.Position; 22 | import static org.testng.Assert.*; 23 | import org.testng.annotations.Test; 24 | 25 | /** 26 | * 27 | * @author Jaroslav Tulach 28 | */ 29 | public class JsGLProviderTest extends Position.Handle { 30 | public JsGLProviderTest() { 31 | super(true); 32 | } 33 | 34 | @Test public void checkWhetherWeCanInstantiate() { 35 | assertNotNull(new JsGLProvider()); 36 | } 37 | 38 | @Test public void canCallIsSupported() { 39 | assertFalse(isSupported(), "Well, it is not, as we are not in a browser context"); 40 | } 41 | 42 | @Override 43 | protected void onLocation(Position p) throws Throwable { 44 | throw new UnsupportedOperationException(); 45 | } 46 | 47 | @Override 48 | protected void onError(Exception ex) throws Throwable { 49 | throw new UnsupportedOperationException(); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /html4j-maven-plugin/src/main/resources/META-INF/gradle-plugins/html4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | implementation-class=org.netbeans.html.mojo.ProcessJsAnnotationsGradle 21 | 22 | -------------------------------------------------------------------------------- /html4j-maven-plugin/src/test/resources/org/netbeans/html/mojo/gradle1/build.gradle: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | defaultTasks 'clean', 'build' 21 | 22 | buildscript { 23 | repositories { 24 | mavenLocal() 25 | } 26 | dependencies { 27 | classpath "org.ow2.asm:asm:5.0" 28 | classpath files("../../../../../../../../target/classes/") 29 | } 30 | } 31 | 32 | 33 | group 'org.netbeans.html.gradle1' 34 | version '1.0-SNAPSHOT' 35 | 36 | apply plugin: 'java' 37 | apply plugin: 'html4j' 38 | 39 | //compileJava { 40 | // classpath += files("src/main/resources") 41 | //} 42 | 43 | def jars = fileTree(dir: '../../../../../../../../../boot/target/', include: ['*.jar']) 44 | 45 | dependencies { 46 | implementation jars 47 | annotationProcessor jars 48 | } 49 | 50 | -------------------------------------------------------------------------------- /html4j-maven-plugin/src/test/resources/org/netbeans/html/mojo/gradle1/src/main/java/Gradle1Check.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import net.java.html.js.JavaScriptBody; 21 | import java.util.concurrent.Callable; 22 | import net.java.html.js.JavaScriptResource; 23 | 24 | @JavaScriptResource("/meaning.js") 25 | public class Gradle1Check implements Callable { 26 | 27 | @Override 28 | public Integer call() throws Exception { 29 | return compute(); 30 | } 31 | 32 | @JavaScriptBody(args = {}, body = "return meaningOfWorld;") 33 | private static int compute() { 34 | return -1; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /html4j-maven-plugin/src/test/resources/org/netbeans/html/mojo/gradle1/src/main/resources/meaning.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | meaningOfWorld = 42; 21 | -------------------------------------------------------------------------------- /json-tck/src/main/java/META-INF/upgrade/AvoidCollections.hint: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | new java.util.ArrayList<>() 21 | => 'Models.asList() is more lightweight': 22 | net.java.html.json.Models.asList() 23 | ;; 24 | 25 | new java.util.ArrayList() 26 | => 'Models.asList() is more lightweight': 27 | net.java.html.json.Models.asList() 28 | ;; 29 | 30 | new java.util.ArrayList<$T>() 31 | => 'Models.asList() is more lightweight': 32 | net.java.html.json.Models.<$T>asList() 33 | ;; 34 | 35 | 36 | java.util.HashSet 37 | => 'Avoid HashSet': SimpleMap.create() 38 | ;; 39 | 40 | java.util.HashMap 41 | => 'Avoid HashMap': SimpleMap.create() 42 | ;; 43 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/js/tests/AsyncJava.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.js.tests; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | 23 | public class AsyncJava { 24 | private AsyncJava() { 25 | } 26 | 27 | @JavaScriptBody(args = { "n", "fac", "done" }, javacall = true, wait4java = false, body = """ 28 | var result = { 29 | x : -1 30 | }; 31 | var facN = fac.@net.java.html.js.tests.AsyncJava$Fac::fac(I)(n); 32 | facN.then(function (res) { 33 | result.x = res; 34 | done.@java.lang.Runnable::run()(); 35 | }); 36 | return result; 37 | """) 38 | static native Object computeInAsyncJava(int n, Fac fac, Runnable done); 39 | 40 | interface Fac { 41 | int fac(int n); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/js/tests/Factorial.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.js.tests; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | 23 | /** 24 | * 25 | * @author Jaroslav Tulach 26 | */ 27 | public final class Factorial { 28 | int minusOne(int i) { 29 | return i - 1; 30 | } 31 | 32 | @JavaScriptBody(args = { "i" }, javacall = true,body = 33 | """ 34 | if (i <= 1) return 1; 35 | var im1 = this.@net.java.html.js.tests.Factorial::minusOne(I)(i); 36 | return this.@net.java.html.js.tests.Factorial::factorial(I)(im1) * i;""" 37 | ) 38 | native int factorial(int n); 39 | } 40 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/js/tests/Global2String.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.js.tests; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | import net.java.html.js.JavaScriptResource; 23 | 24 | @JavaScriptResource("global2.js") 25 | class Global2String { 26 | @JavaScriptBody(args = {}, body = "return global2String;") 27 | public static native String init(); 28 | } 29 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/js/tests/GlobalString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.js.tests; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | import net.java.html.js.JavaScriptResource; 23 | 24 | @JavaScriptResource("global.js") 25 | class GlobalString { 26 | @JavaScriptBody(args = {}, body = "return globalString;") 27 | public static native String init(); 28 | } 29 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/js/tests/Later.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.js.tests; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | 23 | /** 24 | * 25 | * @author Jaroslav Tulach 26 | */ 27 | public final class Later { 28 | volatile int call; 29 | 30 | @JavaScriptBody(args = { }, javacall = true, body = 31 | "var self = this;" 32 | + "window.later = function() {" 33 | + " self.@net.java.html.js.tests.Later::call(I)(42);" 34 | + "};" 35 | ) 36 | native void register(); 37 | 38 | void call(int value) { 39 | this.call = value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/js/tests/Receiver.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.js.tests; 20 | 21 | import java.lang.ref.Reference; 22 | import java.lang.ref.WeakReference; 23 | import net.java.html.js.JavaScriptBody; 24 | 25 | /** 26 | */ 27 | public final class Receiver { 28 | private final Object fn; 29 | Object value; 30 | final Reference ref; 31 | 32 | public Receiver(Object v) { 33 | this.fn = initFn(v); 34 | this.ref = new WeakReference(v); 35 | this.value = this; 36 | } 37 | 38 | public void apply() { 39 | fnApply(fn, this); 40 | } 41 | 42 | void set(Object v) { 43 | value = v; 44 | } 45 | 46 | @JavaScriptBody(args = { "v" }, keepAlive = false, javacall = true, 47 | body = """ 48 | return function(rec) { 49 | rec.@net.java.html.js.tests.Receiver::set(Ljava/lang/Object;)(v); 50 | }; 51 | """) 52 | private static native Object initFn(Object v); 53 | 54 | @JavaScriptBody(args = { "fn", "thiz" }, body = 55 | "fn(thiz);" 56 | ) 57 | private static native void fnApply(Object fn, Receiver thiz); 58 | } 59 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/js/tests/ResourceOrder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.js.tests; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | import net.java.html.js.JavaScriptResource; 23 | 24 | @JavaScriptResource("initArray.js") 25 | @JavaScriptResource("addHello.js") 26 | @JavaScriptResource("addWorld.js") 27 | public class ResourceOrder { 28 | @JavaScriptBody(args = { }, body = "return testArray.join(' ');") 29 | public static native String helloWorld(); 30 | } 31 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/json/tests/PairModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json.tests; 20 | 21 | import java.util.List; 22 | import net.java.html.BrwsrCtx; 23 | import net.java.html.json.ComputedProperty; 24 | import net.java.html.json.Function; 25 | import net.java.html.json.Model; 26 | import net.java.html.json.Models; 27 | import net.java.html.json.Property; 28 | 29 | /** 30 | * 31 | * @author Jaroslav Tulach 32 | */ 33 | @Model(className = "Pair", targetId = "", properties = { 34 | @Property(name = "firstName", type = String.class), 35 | @Property(name = "lastName", type = String.class), 36 | @Property(name = "next", type = Pair.class) 37 | }) 38 | class PairModel { 39 | static BrwsrCtx ctx; 40 | 41 | @ComputedProperty 42 | static List bothNames(String firstName, String lastName) { 43 | return Models.asList(firstName, lastName); 44 | } 45 | 46 | @ComputedProperty 47 | static Pair nextOne(Pair next) { 48 | return next; 49 | } 50 | 51 | @Function 52 | static void assignFirstName(Pair m, String data) { 53 | ctx = BrwsrCtx.findDefault(Pair.class); 54 | m.setFirstName(data); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /json-tck/src/main/java/net/java/html/json/tests/Sex.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json.tests; 20 | 21 | /** 22 | * 23 | * @author Jaroslav Tulach 24 | */ 25 | public enum Sex { 26 | MALE, FEMALE; 27 | } 28 | -------------------------------------------------------------------------------- /json-tck/src/main/java/org/netbeans/html/json/tck/KOTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.tck; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** Annotates method that is part of {@link KnockoutTCK visual test compatibility kit} 27 | * or {@link JavaScriptTCK headless test compatibility kit} 28 | * and should be executed in appropriate environment. The method annotated by 29 | * this annotation will be public instance method of its class 30 | * with no arguments. A typical way to enumerate such methods is: 31 | *

32 | * {@codesnippet net.java.html.boot.script.ScriptEngineJavaScriptTCK} 33 | * and then one can execute such methods as 34 | *

35 | * {@codesnippet net.java.html.boot.script.ScriptEngineCase#run} 36 | * 37 | * @author Jaroslav Tulach 38 | */ 39 | @Retention(RetentionPolicy.RUNTIME) 40 | @Target(ElementType.METHOD) 41 | public @interface KOTest { 42 | } 43 | -------------------------------------------------------------------------------- /json-tck/src/main/java/org/netbeans/html/json/tck/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |

Entry point to the 29 | test compatibility kit. 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /json-tck/src/main/resources/net/java/html/js/tests/addHello.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | testArray.push("Hello"); 20 | 21 | -------------------------------------------------------------------------------- /json-tck/src/main/resources/net/java/html/js/tests/addWorld.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | testArray.push("World!"); 20 | 21 | -------------------------------------------------------------------------------- /json-tck/src/main/resources/net/java/html/js/tests/global.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | var globalString = 'HTML/Java'; 20 | 21 | -------------------------------------------------------------------------------- /json-tck/src/main/resources/net/java/html/js/tests/global2.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | var global2String = 'NetBeans'; 20 | 21 | -------------------------------------------------------------------------------- /json-tck/src/main/resources/net/java/html/js/tests/initArray.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | var testArray = []; 20 | 21 | -------------------------------------------------------------------------------- /json-tck/src/test/java/net/java/html/js/tests/BodiesTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.js.tests; 20 | 21 | import java.io.InputStream; 22 | import static org.testng.Assert.*; 23 | import org.testng.annotations.Test; 24 | 25 | /** 26 | * 27 | * @author Jaroslav Tulach 28 | */ 29 | public class BodiesTest { 30 | 31 | public BodiesTest() { 32 | } 33 | 34 | @Test public void annotationIsStillPresent() throws Exception { 35 | InputStream is = Bodies.class.getResourceAsStream("Bodies.class"); 36 | assertNotNull(is, "Class Stream found"); 37 | 38 | byte[] arr = new byte[is.available()]; 39 | int len = is.read(arr); 40 | 41 | assertEquals(len, arr.length, "Fully read"); 42 | 43 | String bytes = new String(arr, "UTF-8"); 44 | 45 | { 46 | int idx = bytes.indexOf("Lnet/java/html/js/JavaScriptBody"); 47 | if (idx == -1) { 48 | fail("Expecting JavaScriptBody reference in: " + bytes); 49 | } 50 | } 51 | { 52 | int idx = bytes.indexOf("return a + b"); 53 | if (idx == -1) { 54 | fail("Expecting 'return a + b' in the class file: " + bytes); 55 | } 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /json/src/main/java/net/java/html/json/doc-files/DukeHTML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/json/src/main/java/net/java/html/json/doc-files/DukeHTML.png -------------------------------------------------------------------------------- /json/src/main/java/net/java/html/json/doc-files/html4j.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/netbeans-html4j/393aea48ff734c19cdb0fcead4ce59982ed2a5f6/json/src/main/java/net/java/html/json/doc-files/html4j.png -------------------------------------------------------------------------------- /json/src/main/java/org/netbeans/html/json/impl/ClassValueTypes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import org.netbeans.html.json.spi.Proto; 22 | 23 | final class ClassValueTypes extends ClassValue implements ModelTypes { 24 | 25 | @Override 26 | protected Proto.Type[] computeValue(Class type) { 27 | return new Proto.Type[1]; 28 | } 29 | 30 | @Override 31 | public Proto.Type[] find(Class type) { 32 | return get(type); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /json/src/main/java/org/netbeans/html/json/impl/LinkedListTypes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import org.netbeans.html.json.spi.Proto; 22 | 23 | final class LinkedListTypes implements ModelTypes { 24 | 25 | private Item items; 26 | 27 | private static final class Item { 28 | 29 | final Item next; 30 | final Class clazz; 31 | final Proto.Type[] type = {null}; 32 | 33 | Item(Item next, Class clazz) { 34 | this.next = next; 35 | this.clazz = clazz; 36 | } 37 | } 38 | 39 | @Override 40 | public synchronized Proto.Type[] find(Class clazz) { 41 | Item it = items; 42 | while (it != null) { 43 | if (it.clazz == clazz) { 44 | return it.type; 45 | } 46 | it = it.next; 47 | } 48 | it = new Item(items, clazz); 49 | items = it; 50 | return it.type; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /json/src/main/java/org/netbeans/html/json/impl/ModelTypes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import org.netbeans.html.json.spi.Proto; 22 | 23 | interface ModelTypes { 24 | Proto.Type[] find(Class type); 25 | 26 | static final ModelTypes MODELS = JSON.initModelTypes( 27 | "java.lang.ClassValue", 28 | "org.netbeans.html.json.impl.ClassValueTypes" 29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /json/src/main/java/org/netbeans/html/json/impl/ReactiveTech.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import net.java.html.BrwsrCtx; 22 | import org.netbeans.html.context.spi.Contexts; 23 | import org.netbeans.html.json.spi.FunctionBinding; 24 | import org.netbeans.html.json.spi.PropertyBinding; 25 | import org.netbeans.html.json.spi.Technology; 26 | 27 | final class ReactiveTech implements Technology { 28 | static final BrwsrCtx CTX = Contexts.newBuilder().register(Technology.class, new ReactiveTech(), 10).build(); 29 | 30 | private ReactiveTech() { 31 | } 32 | 33 | @Override 34 | public Reactive wrapModel(Object model) { 35 | return (Reactive) model; 36 | } 37 | 38 | @Override 39 | public M toModel(Class modelClass, Object data) { 40 | return modelClass.cast(data); 41 | } 42 | 43 | @Override 44 | public void bind(PropertyBinding b, Object model, Reactive data) { 45 | } 46 | 47 | @Override 48 | public void valueHasMutated(Reactive data, String propertyName) { 49 | data.valueHasMutated(propertyName); 50 | } 51 | 52 | @Override 53 | public void expose(FunctionBinding fb, Object model, Reactive d) { 54 | } 55 | 56 | @Override 57 | public void applyBindings(Reactive data) { 58 | } 59 | 60 | @Override 61 | public Object wrapArray(Object[] arr) { 62 | return arr; 63 | } 64 | 65 | @Override 66 | public void runSafe(Runnable r) { 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /json/src/main/java/org/netbeans/html/json/impl/ReactiveType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import net.java.html.BrwsrCtx; 22 | import org.netbeans.html.json.spi.Proto; 23 | 24 | final class ReactiveType extends Proto.Type { 25 | 26 | public static final ReactiveType TYPE = new ReactiveType(); 27 | 28 | private ReactiveType() { 29 | super(Reactive.class, Reactive.class, 1, 0); 30 | } 31 | 32 | @Override 33 | protected void setValue(Reactive model, int index, Object value) { 34 | } 35 | 36 | @Override 37 | protected Object getValue(Reactive model, int index) { 38 | return null; 39 | } 40 | 41 | @Override 42 | protected void call(Reactive model, int index, Object data, Object event) throws Exception { 43 | } 44 | 45 | @Override 46 | protected Reactive cloneTo(Reactive model, BrwsrCtx ctx) { 47 | return model; 48 | } 49 | 50 | @Override 51 | protected Reactive read(BrwsrCtx c, Object json) { 52 | return null; 53 | } 54 | 55 | @Override 56 | protected void onChange(Reactive model, int index) { 57 | } 58 | 59 | @Override 60 | protected Proto protoFor(Object object) { 61 | return ((Reactive)object).getProto(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /json/src/main/java/org/netbeans/html/json/impl/Transitive.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** A way to control {@link ComputedProperty} behavior - whether it tracks 27 | * deeply or not. Not public yet, maybe it won't be needed in the API at all. 28 | * Used in tests only. 29 | * 30 | * @author Jaroslav Tulach 31 | */ 32 | @Retention(RetentionPolicy.SOURCE) 33 | @Target(ElementType.METHOD) 34 | @interface Transitive { 35 | boolean deep() default false; 36 | } 37 | -------------------------------------------------------------------------------- /json/src/main/java/org/netbeans/html/json/spi/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 |
Service Provider Interfaces for those who wish to integrate own 24 | technology with the HTML for Java API. 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/AdressTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json; 20 | 21 | import static org.testng.Assert.assertNotNull; 22 | import org.testng.annotations.Test; 23 | import net.java.html.json.sub.Street; 24 | import net.java.html.json.sub.Telephone; 25 | @Model(className = "Address", properties = { 26 | @Property(name = "street", type = net.java.html.json.sub.Street.class) 27 | }) 28 | public class AdressTest { 29 | @Test 30 | public void addressHoldsAPerson() { 31 | Address address = new Address(); 32 | assertNotNull(address.getStreet(), "Street is initialized"); 33 | } 34 | 35 | @ComputedProperty 36 | public static String lowerCaseStreetName(Street street){ 37 | return street.getName().toLowerCase(); 38 | } 39 | 40 | @OnReceive(url = "") 41 | public static void getTelephone(Address model, Telephone phone){} 42 | } 43 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/BoardTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json; 20 | 21 | import static org.testng.Assert.assertFalse; 22 | import static org.testng.Assert.assertTrue; 23 | import org.testng.annotations.Test; 24 | 25 | /** 26 | * 27 | * @author Jaroslav Tulach 28 | */ 29 | @Model(className = "Board", properties = { 30 | @Property(name = "rows", type = Row.class, array = true) 31 | }) 32 | public class BoardTest { 33 | 34 | @Model(className = "Row", properties = { 35 | @Property(name = "column", type = Column.class, array = true) 36 | }) 37 | static class RowModel { 38 | } 39 | 40 | @Model(className = "Column", properties = { 41 | @Property(name = "black", type = boolean.class) 42 | }) 43 | static class ColumnModel { 44 | } 45 | 46 | @Test public void deepClone() { 47 | Board orig = new Board(new Row(new Column(true))); 48 | assertTrue(orig.getRows().get(0).getColumn().get(0).isBlack(), "Really true"); 49 | 50 | Board clone = orig.clone(); 51 | assertTrue(clone.getRows().get(0).getColumn().get(0).isBlack(), "Clone also true"); 52 | 53 | clone.getRows().get(0).getColumn().get(0).setBlack(false); 54 | 55 | assertFalse(clone.getRows().get(0).getColumn().get(0).isBlack(), "Clone also is not false"); 56 | assertTrue(orig.getRows().get(0).getColumn().get(0).isBlack(), "Orig still true"); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/ModelsTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json; 20 | 21 | import static org.testng.Assert.*; 22 | import org.testng.annotations.Test; 23 | 24 | /** 25 | * 26 | * @author Jaroslav Tulach 27 | */ 28 | public class ModelsTest { 29 | 30 | public ModelsTest() { 31 | } 32 | 33 | @Test public void peopleAreModel() { 34 | assertTrue(Models.isModel(People.class), "People are generated class"); 35 | } 36 | 37 | @Test public void personIsModel() { 38 | assertTrue(Models.isModel(Person.class), "Person is generated class"); 39 | } 40 | 41 | @Test public void implClassIsNotModel() { 42 | assertFalse(Models.isModel(PersonImpl.class), "Impl is not model"); 43 | } 44 | 45 | @Test public void randomClassIsNotModel() { 46 | assertFalse(Models.isModel(StringBuilder.class), "JDK classes are not model"); 47 | } 48 | } -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/PrimitiveArrayTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json; 20 | 21 | import java.util.Collections; 22 | import java.util.List; 23 | import org.testng.Assert; 24 | import org.testng.annotations.Test; 25 | 26 | /** 27 | * 28 | * @author Jaroslav Tulach 29 | */ 30 | @Model(className="ByteArray", properties = { 31 | @Property(name = "array", type = byte.class, array = true) 32 | }) 33 | public class PrimitiveArrayTest { 34 | @ComputedProperty static int length(List array) { 35 | return array.size(); 36 | } 37 | 38 | @ComputedProperty static List lengthAsList(List array) { 39 | return Collections.nCopies(1, array.size()); 40 | } 41 | 42 | @ComputedProperty static List lengthTextList(List array) { 43 | return Collections.nCopies(1, "" + array.size()); 44 | } 45 | 46 | @Test public void generatedConstructorWithPrimitiveType() { 47 | byte[] arr = new byte[10]; 48 | arr[3] = 10; 49 | ByteArray a = new ByteArray(arr); 50 | Assert.assertEquals(a.getArray().size(), 10, "Ten elements"); 51 | Assert.assertEquals(a.getArray().get(3).byteValue(), 10, "Value ten"); 52 | Assert.assertEquals(a.getLength(), 10, "Derived property is OK too"); 53 | Assert.assertEquals(a.getLengthTextList().get(0), "10", "Derived string list property is OK"); 54 | Assert.assertEquals((int)a.getLengthAsList().get(0), 10, "Derived Integer list property is OK"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/Sex.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json; 20 | 21 | @Model(className = "MaleOrFemale", properties = { 22 | @Property(name = "sex", type = Sex.class) 23 | }) 24 | public enum Sex { 25 | MALE, FEMALE; 26 | 27 | @ComputedProperty 28 | static boolean woman(Sex sex) { 29 | return FEMALE == sex; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/SexTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json; 20 | 21 | import static org.testng.AssertJUnit.assertFalse; 22 | import static org.testng.AssertJUnit.assertTrue; 23 | import org.testng.annotations.Test; 24 | 25 | public class SexTest { 26 | @Test 27 | public void checkWoman() { 28 | MaleOrFemale mof = new MaleOrFemale(); 29 | mof.setSex(Sex.FEMALE); 30 | assertTrue("Woman", mof.isWoman()); 31 | } 32 | 33 | @Test 34 | public void noWoman() { 35 | MaleOrFemale mof = new MaleOrFemale(); 36 | mof.setSex(Sex.MALE); 37 | assertFalse("No woman", mof.isWoman()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/UnderscoreTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json; 20 | 21 | import static org.testng.Assert.assertEquals; 22 | import static org.testng.Assert.assertNotNull; 23 | import org.testng.annotations.Test; 24 | 25 | 26 | @Model(className = "UnderscoreModel", targetId="", properties = { 27 | @Property(name="__meta", type = MetaModel.class), 28 | }) 29 | public class UnderscoreTest { 30 | @Model(className = "MetaModel", properties = { 31 | }) 32 | static final class MetaCntrl { 33 | } 34 | 35 | @Test 36 | public void accessMeta() { 37 | UnderscoreModel model = new UnderscoreModel(); 38 | assertNotNull(model); 39 | MetaModel meta = new MetaModel(); 40 | model.set__meta(meta); 41 | assertEquals(model.get__meta(), meta); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/VarArgTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package net.java.html.json; 21 | 22 | import org.testng.Assert; 23 | import org.testng.annotations.Test; 24 | 25 | @Model(className = "VarArg", instance = true, properties = { 26 | }) 27 | public class VarArgTest { 28 | @ModelOperation 29 | void read(VarArg square, VarArgTest[] arr) { 30 | Assert.assertNotNull(arr, "Array passed in"); 31 | Assert.assertEquals(arr.length, 1, "One slot ready"); 32 | arr[0] = this; 33 | } 34 | 35 | @Test 36 | public void canReadThis() { 37 | VarArgTest[] arr = { null }; 38 | VarArg model = new VarArg(); 39 | model.read(arr); 40 | Assert.assertNotNull(arr[0]); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/WebSocketCallTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json; 20 | 21 | /** 22 | * 23 | * @author Jaroslav Tulach 24 | */ 25 | @Model(className = "WebSocketCallTestMode", properties = { 26 | @Property(name = "nic", type = int.class) 27 | }) 28 | public class WebSocketCallTest { 29 | @OnReceive(method = "WebSocket", data = Person.class, url="{url}") 30 | static void wsCall(WebSocketCallTestMode model, Person data) { 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/sub/StreetCntrl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json.sub; 20 | 21 | import net.java.html.json.Model; 22 | import net.java.html.json.Property; 23 | 24 | @Model(className = "Street", properties = { 25 | @Property(name = "name", type = String.class), 26 | @Property(name = "id", type = int.class), 27 | }) 28 | class StreetCntrl { 29 | } 30 | -------------------------------------------------------------------------------- /json/src/test/java/net/java/html/json/sub/TelephoneCntrl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.json.sub; 20 | 21 | import net.java.html.json.Model; 22 | 23 | @Model(className = "Telephone", properties = {}) 24 | public class TelephoneCntrl { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /json/src/test/java/org/netbeans/html/json/impl/EmployerTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import net.java.html.BrwsrCtx; 22 | import net.java.html.json.Model; 23 | import net.java.html.json.Models; 24 | import net.java.html.json.Property; 25 | import org.testng.Assert; 26 | import org.testng.annotations.Test; 27 | 28 | /** 29 | * 30 | * @author Jaroslav Tulach 31 | */ 32 | @Model(className = "Employer", properties = { 33 | @Property(name = "name", type = String.class) 34 | }) 35 | public class EmployerTest { 36 | @Test public void preLoadsTheClass() { 37 | Employer em = Models.fromRaw(BrwsrCtx.EMPTY, Employer.class, this); 38 | Assert.assertNotNull(em, "Class loaded"); 39 | Models.applyBindings(em); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /json/src/test/java/org/netbeans/html/json/impl/InnerTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import net.java.html.json.Model; 22 | import net.java.html.json.OnReceive; 23 | 24 | public class InnerTest { 25 | @Model(className = "InnerModel", properties = { 26 | }) 27 | public final static class Inner { 28 | @OnReceive(url = "http://github.com/api", onError = "apiError") 29 | static void apiCall(InnerModel model, String data) { 30 | } 31 | 32 | static void apiError(InnerModel model, Exception err) { 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /json/src/test/java/org/netbeans/html/json/impl/JSONTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import static org.testng.Assert.*; 22 | import org.testng.annotations.Test; 23 | 24 | /** 25 | * 26 | * @author Jaroslav Tulach 27 | */ 28 | public class JSONTest { 29 | 30 | public JSONTest() { 31 | } 32 | 33 | @Test public void longToStringValue() { 34 | assertEquals(JSON.stringValue(Long.valueOf(1)), "1"); 35 | } 36 | 37 | @Test public void booleanIsSortOfNumber() { 38 | assertEquals(JSON.numberValue(Boolean.TRUE), Integer.valueOf(1)); 39 | assertEquals(JSON.numberValue(Boolean.FALSE), Integer.valueOf(0)); 40 | } 41 | 42 | @Test public void numberToChar() { 43 | assertEquals(JSON.charValue(65), Character.valueOf('A')); 44 | } 45 | @Test public void booleanToChar() { 46 | assertEquals(JSON.charValue(false), Character.valueOf((char)0)); 47 | assertEquals(JSON.charValue(true), Character.valueOf((char)1)); 48 | } 49 | @Test public void stringToChar() { 50 | assertEquals(JSON.charValue("Ahoj"), Character.valueOf('A')); 51 | } 52 | @Test public void stringToBoolean() { 53 | assertEquals(JSON.boolValue("false"), Boolean.FALSE); 54 | assertEquals(JSON.boolValue("True"), Boolean.TRUE); 55 | } 56 | @Test public void numberToBoolean() { 57 | assertEquals(JSON.boolValue(0), Boolean.FALSE); 58 | assertEquals(JSON.boolValue(1), Boolean.TRUE); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /json/src/test/java/org/netbeans/html/json/impl/NoPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.json.impl; 20 | 21 | import net.java.html.json.Model; 22 | 23 | /** Originally could not compile. 24 | * 25 | * @author Jaroslav Tulach 26 | */ 27 | @Model(className="NoProperties", properties = { 28 | }) 29 | public class NoPropertiesTest { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ko-felix-test/src/test/resources/org/netbeans/html/ko/felix/test/test.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Knockout.fx Execution Harness 25 | 26 | 27 | 28 | 29 |

Knockout.fx in Felix Execution Harness

30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ko-osgi-test/src/test/resources/org/netbeans/html/ko/osgi/test/test.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Knockout.fx Execution Harness 25 | 26 | 27 | 28 | 29 |

Knockout.fx in Equinox Execution Harness

30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ko-ws-tyrus/src/test/resources/org/netbeans/html/wstyrus/test.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Tyrus WebSockets Execution Harness 25 | 26 | 27 | 28 | 29 |

Tyrus WebSockets Execution Harness

30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ko4j/src/main/appended-resources/META-INF/DEPENDENCIES: -------------------------------------------------------------------------------- 1 | From: 'Knockout.js team' (http://knockoutjs.com/) 2 | - Knockout JavaScript library v3.5.0 3 | License: MIT (http://www.opensource.org/licenses/mit-license.php) 4 | -------------------------------------------------------------------------------- /ko4j/src/main/appended-resources/META-INF/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | 3 | This product bundles Knockout JavaScript library v3.5.0, 4 | which is available under a MIT license: 5 | 6 | The MIT License (MIT) - http://www.opensource.org/licenses/mit-license.php 7 | 8 | Copyright (c) Steven Sanderson, the Knockout.js team, and other contributors 9 | http://knockoutjs.com/ 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in 19 | all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | -------------------------------------------------------------------------------- /ko4j/src/main/java/org/netbeans/html/ko4j/KOSockets.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.ko4j; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | import org.netbeans.html.context.spi.Contexts; 23 | import org.netbeans.html.json.spi.JSONCall; 24 | import org.netbeans.html.json.spi.WSTransfer; 25 | 26 | /** This is an implementation package - just 27 | * include its JAR on classpath and use official {@link Context} API 28 | * to access the functionality. 29 | * 30 | * @author Jaroslav Tulach 31 | */ 32 | @Contexts.Id("websocket") 33 | final class KOSockets 34 | implements WSTransfer { 35 | KOSockets() { 36 | } 37 | 38 | @Override 39 | public LoadWS open(String url, JSONCall onReply) { 40 | return new LoadWS(onReply, url); 41 | } 42 | 43 | @Override 44 | public void send(LoadWS socket, JSONCall data) { 45 | socket.send(data); 46 | } 47 | 48 | @Override 49 | public void close(LoadWS socket) { 50 | socket.close(); 51 | } 52 | 53 | @JavaScriptBody(args = {}, body = "if (typeof window === 'object' && window['WebSocket']) return true; else return false;") 54 | static final boolean areWebSocketsSupported() { 55 | return false; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ko4j/src/test/java/org/netbeans/html/ko4j/DumpStack.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.ko4j; 20 | 21 | import java.util.Map; 22 | import java.util.Timer; 23 | import java.util.TimerTask; 24 | 25 | final class DumpStack extends TimerTask { 26 | 27 | private static final Timer TIMER = new Timer("Dump Stack Watchdog"); 28 | private final long created = System.currentTimeMillis(); 29 | 30 | @Override 31 | public void run() { 32 | StringBuilder sb = new StringBuilder(); 33 | long after = (System.currentTimeMillis() - created) / 1000; 34 | sb.append("Thread dump after ").append(after).append(" s from start:\n"); 35 | for (Map.Entry info : Thread.getAllStackTraces().entrySet()) { 36 | sb.append(info.getKey().getName()).append("\n"); 37 | for (StackTraceElement e : info.getValue()) { 38 | sb.append(" ").append(e.getClassName()).append("."). 39 | append(e.getMethodName()).append("(").append(e.getFileName()). 40 | append(":").append(e.getLineNumber()).append(")\n"); 41 | } 42 | } 43 | System.err.println(sb.toString()); 44 | } 45 | 46 | public static void initialize() { 47 | final int fiveSec = 5000; 48 | TIMER.schedule(new DumpStack(), fiveSec, 2 * fiveSec); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ko4j/src/test/java/org/netbeans/html/ko4j/ReferenceKnockoutTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.ko4j; 20 | 21 | import static org.testng.Assert.assertNull; 22 | import org.testng.annotations.Test; 23 | 24 | /** 25 | * 26 | * @author Jaroslav Tulach 27 | */ 28 | public class ReferenceKnockoutTest { 29 | @Test public void canLoadKnockout() { 30 | Object ret = null; 31 | try { 32 | ret = Knockout.toModel(null); 33 | } catch (IllegalStateException ex) { 34 | // ISE is OK as we don't have any 35 | // context for the 36 | } 37 | assertNull(ret, "Either null"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ko4j/src/test/resources/org/netbeans/html/ko4j/double.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Double Usage 25 | 26 | 27 | 28 | 29 |

Double Usage

30 |
Message as property
31 |
Message as function
32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /ko4j/src/test/resources/org/netbeans/html/ko4j/test.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Knockout.fx Execution Harness 25 | 26 | 27 | 28 | 29 |

Knockout.fx Execution Harness

30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /renderer/src/main/java/org/netbeans/html/presenters/render/AWT.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.render; 20 | 21 | import com.sun.jna.Pointer; 22 | import java.io.IOException; 23 | import java.net.URI; 24 | import java.util.logging.Level; 25 | 26 | final class AWT extends Show { 27 | @Override 28 | public void show(URI page) throws IOException { 29 | try { 30 | LOG.log(Level.FINE, "Trying Desktop.browse on {0} {2} by {1}", new Object[]{ 31 | System.getProperty("java.vm.name"), 32 | System.getProperty("java.vm.vendor"), 33 | System.getProperty("java.vm.version"),}); 34 | java.awt.Desktop.getDesktop().browse(page); 35 | LOG.log(Level.FINE, "Desktop.browse successfully finished"); 36 | System.in.read(); 37 | } catch (UnsupportedOperationException ex) { 38 | LOG.log(Level.FINE, "Desktop.browse not supported: {0}", ex.getMessage()); 39 | throw new IOException(ex); 40 | } 41 | } 42 | 43 | @Override 44 | public JSC jsc() { 45 | return null; 46 | } 47 | 48 | @Override 49 | public Pointer jsContext() { 50 | return null; 51 | } 52 | 53 | @Override 54 | public void execute(Runnable command) { 55 | command.run(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /renderer/src/main/java/org/netbeans/html/presenters/render/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * {@link org.netbeans.html.presenters.render.Show Show} a browser 22 | * component. 23 | */ 24 | package org.netbeans.html.presenters.render; 25 | -------------------------------------------------------------------------------- /sound/src/main/java/net/java/html/sound/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 |

23 | Control {@link net.java.html.sound.AudioClip sound} in your HTML for 24 | Java applications. 25 |

26 | 27 | -------------------------------------------------------------------------------- /sound/src/main/java/org/netbeans/html/sound/impl/BrowserAudioEnv.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.sound.impl; 20 | 21 | import net.java.html.js.JavaScriptBody; 22 | import org.netbeans.html.sound.spi.AudioEnvironment; 23 | 24 | /** The default audio provider that delegates to HTML5 Audio tag 25 | * it is used if no other {@link AudioEnvironment} is found. 26 | * 27 | * @author Jaroslav Tulach 28 | */ 29 | public final class BrowserAudioEnv implements AudioEnvironment { 30 | public static final AudioEnvironment DEFAULT = new BrowserAudioEnv(); 31 | 32 | private BrowserAudioEnv() { 33 | } 34 | 35 | @Override 36 | @JavaScriptBody(args = { "src" }, body = "" 37 | + "if (typeof Audio !== 'object') return null;" 38 | + "return new Audio(src);") 39 | public Object create(String src) { 40 | // null if not running in browser 41 | return null; 42 | } 43 | 44 | @Override @JavaScriptBody(args = { "a" }, body = "a.play();") 45 | public void play(Object a) { 46 | } 47 | 48 | @Override @JavaScriptBody(args = { "a" }, body = "a.pause();") 49 | public void pause(Object a) { 50 | } 51 | 52 | @Override @JavaScriptBody(args = { "a", "volume" }, body = "a.setVolume(volume);") 53 | public void setVolume(Object a, double volume) { 54 | } 55 | 56 | @Override 57 | @JavaScriptBody(args = "a", body = "return true;") 58 | public boolean isSupported(Object a) { 59 | return false; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /sound/src/main/java/org/netbeans/html/sound/spi/package.html: -------------------------------------------------------------------------------- 1 | 21 | 22 |

23 | Give your {@link net.java.html.sound.AudioClip} real behavior! 24 |

25 | 26 | -------------------------------------------------------------------------------- /sound/src/test/java/net/java/html/sound/AudioClipTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package net.java.html.sound; 20 | 21 | import net.java.html.junit.BrowserRunner; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | 25 | @RunWith(BrowserRunner.class) 26 | public class AudioClipTest { 27 | 28 | public AudioClipTest() { 29 | } 30 | 31 | @Test 32 | public void testPlayNonExistingClip() { 33 | AudioClip.create("non-existing.mp3").play(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /webkit/src/main/java/org/netbeans/html/presenters/webkit/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * Native {@link org.netbeans.html.presenters.webkit.WebKitPresenter} for 22 | * Linux and Mac OS X. 23 | */ 24 | package org.netbeans.html.presenters.webkit; 25 | -------------------------------------------------------------------------------- /webkit/src/test/java/org/netbeans/html/presenters/webkit/Skip.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.webkit; 20 | 21 | import org.testng.IHookCallBack; 22 | import org.testng.IHookable; 23 | import org.testng.ITest; 24 | import org.testng.ITestResult; 25 | import org.testng.SkipException; 26 | import org.testng.annotations.Test; 27 | 28 | public final class Skip implements ITest, IHookable { 29 | private final String msg; 30 | 31 | Skip(String msg) { 32 | this.msg = msg; 33 | } 34 | 35 | @Override 36 | public String getTestName() { 37 | return "Skip"; 38 | } 39 | 40 | @Test 41 | public void executeTest() throws Exception { 42 | throw new SkipException(msg); 43 | } 44 | 45 | @Override 46 | public void run(IHookCallBack ihcb, ITestResult itr) { 47 | ihcb.runTestMethod(itr); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /webkit/src/test/java/org/netbeans/html/presenters/webkit/Timeout.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.netbeans.html.presenters.webkit; 20 | 21 | import java.io.PrintStream; 22 | import java.util.Map.Entry; 23 | 24 | final class Timeout implements Runnable { 25 | private final long timeout; 26 | private final Thread thread; 27 | 28 | Timeout(long timeout) { 29 | this.timeout = timeout; 30 | this.thread = new Thread(this, "Timeout Watcher"); 31 | this.thread.setDaemon(true); 32 | this.thread.start(); 33 | } 34 | 35 | @Override 36 | public void run() { 37 | try { 38 | Thread.sleep(timeout); 39 | } catch (InterruptedException ex) { 40 | ex.printStackTrace(); 41 | } 42 | System.err.println("Timeout in " + timeout + " ms"); 43 | dumpThreads(System.err); 44 | } 45 | 46 | private static void dumpThreads(PrintStream ps) { 47 | for (Entry e : Thread.getAllStackTraces().entrySet()) { 48 | ps.println("Thread " + e.getKey().getName() + ":"); 49 | for (StackTraceElement t : e.getValue()) { 50 | ps.println(" " + t); 51 | } 52 | } 53 | ps.println(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /webkit/src/test/resources/org/netbeans/html/presenters/webkit/empty.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | Empty 25 | 26 | 27 | 28 | 29 |
Empty
30 | 31 | 32 | -------------------------------------------------------------------------------- /xhr4j/src/test/resources/org/netbeans/html/xhr4j/test.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | XHR via Java Harness 25 | 26 | 27 | 28 | 29 |

XHR via Java Harness

30 | 31 | 32 | 33 | --------------------------------------------------------------------------------