Views
1 week ago

tornadofx-guide

OSGi Artifact Version

OSGi Artifact Version Binary JavaFX 8 OSGi Support 8.0 jar TornadoFX 1.7.12 jar Kotlin OSGI Bundle* 1.5.11 jar Configuration Admin** 1.8.10 jar Commons Logging 1.2 jar Apache HTTP-Client 4.5.2 jar Apache HTTP-Core 4.4.5 jar JSON 1.0.4 jar * The Kotlin OSGi bundle contains special versions of kotlin-stdlib and kotlinreflect with the required OSGi manifest information. ** This links to the Apache Felix implementation of the OSGi Config Admin interface. Feel free to use the implementation from your OSGi container instead. Some containers, like Apache Karaf, already has the Config Admin bundle loaded, so you won't need it there. 212

Scopes Scopes Scope is a simple construct that enables some interesting and helpful behavior in a TornadoFX application. When you use inject() or find() to locate a Controller or a View , you will by default get back a singleton instance, meaning that wherever you locate that object in your code, you will get back the same instance. Scopes provide a way to make a View or Controller unique to a smaller subset of instances in your application. It can also be used to run multiple versions of the same application inside the same JVM, for example with JPro, which exposes TornadoFX application in a web browser. A Master/Detail example In an MDI Application you can open an editor in a new window, and ensure that all the injected resources are unique to that window. We will leverage that technique to create a person editor that allows you to open a new window to edit each person. We start by defining a table interface where you can double click to open the person editor in a separate window. class PersonList : View("Person List") { val ctrl: PersonController by inject() override val root = tableview() { column("#", Person::idProperty) column("Name", Person::nameProperty) onUserSelect { editPerson(it) } asyncItems { ctrl.people() } } } fun editPerson(person: Person) { val editScope = Scope() val model = PersonModel() model.item = person setInScope(model, editScope) find(PersonEditor::class, editScope).openWindow() } 213

Guide
guide
GUIDE
guide
Guide
Guide
GUIDE
A guide
Guide