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
Table of Contents Introduction Part
Part 1: TornadoFX Fundamentals Part
1. Why TornadoFX? how Kotlin can si
1. Why TornadoFX? tableview { items
2. Setting Up 1.8 Then this goes
3. Components However, we might wan
3. Components Specify the name of y
3. Components class MyApp: App(MyVi
3. Components import javafx.scene.c
3. Components Here is a simple exam
3. Components The VBox contains a L
3. Components Argument Type Descrip
3. Components Argument Type Descrip
3. Components import tornadofx.* cl
3. Components Sometimes it is neces
4. Basic Controls Basic Controls On
4. Basic Controls 3. The Button is
4. Basic Controls If you need to sa
4. Basic Controls Figure 4.4 You ca
4. Basic Controls You do not need t
4. Basic Controls radiobutton("Powe
4. Basic Controls ProgressBar A Pro
4. Basic Controls Like most other c
4. Basic Controls Keep in mind that
4. Basic Controls button("Commit")
4. Basic Controls 51
5. Data Controls val greekLetters =
5. Data Controls class Person(id: I
5. Data Controls tableview(persons)
5. Data Controls This more closely
5. Data Controls The rowExpander()
5. Data Controls Let's break this d
5. Data Controls data class Departm
5. Data Controls val tableData = ma
5. Data Controls val numbers = (1..
6. Type Safe CSS Type-Safe CSS Whil
6. Type Safe CSS import javafx.scen
6. Type Safe CSS You can apply styl
6. Type Safe CSS Figure 6.3 Note al
6. Type Safe CSS label("Lore Ipsum"
6. Type Safe CSS If you want the bu
6. Type Safe CSS import javafx.scen
6. Type Safe CSS Modifier Selection
6. Type Safe CSS The DangerButtonSt
7. Layouts and Menus vbox { button(
7. Layouts and Menus Notice also wh
7. Layouts and Menus borderpane { l
7. Layouts and Menus 95
7. Layouts and Menus The example ab
7. Layouts and Menus One way to use
7. Layouts and Menus columnIndex: I
7. Layouts and Menus TabPane A TabP
7. Layouts and Menus Like many buil
7. Layouts and Menus Separators You
7. Layouts and Menus Note there are
7. Layouts and Menus Attribute Buil
7. Layouts and Menus item("SomeText
7. Layouts and Menus squeezebox { f
7. Layouts and Menus class DrawerVi
7. Layouts and Menus drawer(side =
8. Charts Charts JavaFX comes with
8. Charts val items = listOf( PieCh
8. Charts In the series() and data(
8. Charts Multiseries You can strea
8. Charts BubbleChart BubbleChart i
8. Charts Summary Charts are a an e
9. Shapes and Animation class MyVie
9. Shapes and Animation CubicCurve
9. Shapes and Animation Polyline A
9. Shapes and Animation Path Path r
9. Shapes and Animation A KeyValue
9. Shapes and Animation If you want
10. FXML If you are converting an e
10. FXML We have created an FXML fi
10. FXML class CounterView : View()
10. FXML FXML is helpful to know as
11. Editing Models and Validation F
11. Editing Models and Validation }
11. Editing Models and Validation p
11. Editing Models and Validation T
JSON and REST To configure authenti
Dependency Injection Dependency Inj
Dependency Injection This initializ
Wizard class BasicData : View("Basi
Wizard When the Next or Finish butt
Wizard val wizard = find() wizard.s
Wizard class CustomerWizard : Wizar
Wizard Structural modifications The