Skip to content

Commit 57e4bbb

Browse files
committed
Merge branch 'master' into release
2 parents 7dcd55e + e3fcc5e commit 57e4bbb

File tree

24 files changed

+1112
-654
lines changed

24 files changed

+1112
-654
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 3.5.8
1+
version = 3.7.3
22

33
runner.dialect = scala3
44
fileOverride {

ReadMe.md

Lines changed: 113 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,36 @@ ScalaFX Extras
22
==============
33

44
[![Scala CI](https://github.com/scalafx/scalafx-extras/actions/workflows/scala.yml/badge.svg)](https://github.com/scalafx/scalafx-extras/actions/workflows/scala.yml)
5-
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.scalafx/scalafx-extras_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.scalafx/scalafx-extras_2.13)
6-
[![Scaladoc](https://javadoc.io/badge2/org.scalafx/scalafx-extras_2.13/scaladoc.svg)](https://javadoc.io/doc/org.scalafx/scalafx-extras_2.13)
5+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.scalafx/scalafx-extras_3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.scalafx/scalafx-extras_3)
6+
[![Scaladoc](https://javadoc.io/badge2/org.scalafx/scalafx-extras_3/scaladoc.svg)](https://javadoc.io/doc/org.scalafx/scalafx-extras_3)
77

88
ScalaFX Extras are additions to ScalaFX that simplify creation of User interfaces. In contrast to ScalaFX core, the
99
Extras do not have direct corresponding concepts in JavaFX.
1010

1111
**Contents**
1212

1313
<!-- TOC -->
14-
15-
* [Project Structure](#project-structure)
16-
* [SBT](#sbt)
17-
* [Features](#features)
18-
* [Helper Methods](#helper-methods)
19-
* [Simpler Display of Standard Dialogs](#simpler-display-of-standard-dialogs)
20-
* [Easy Custom Dialogs](#easy-custom-dialogs)
21-
* [Edit a Case Class object with AutoDialog](#edit-a-case-class-object-with-autodialog)
22-
* [BusyWorker](#busyworker)
14+
* [Project Structure](#project-structure)
15+
* [SBT](#sbt)
16+
* [Features](#features)
17+
* [Helper Methods](#helper-methods)
18+
* [Simpler Display of Standard Dialogs](#simpler-display-of-standard-dialogs)
19+
* [Easy Custom Panes](#easy-custom-panes)
20+
* [Easy Custom Dialogs](#easy-custom-dialogs)
21+
* [Edit a Case Class object with AutoDialog](#edit-a-case-class-object-with-autodialog)
22+
* [BusyWorker](#busyworker)
2323
* [Example 1](#example-1)
2424
* [Example 2](#example-2)
25-
* [Simpler Use of FXML with MVCfx Pattern](#simpler-use-of-fxml-with-mvcfx-pattern)
26-
* [ImageDisplay Component](#imagedisplay-component)
27-
* [Demos](#demos)
28-
* [StopWatch Application](#stopwatch-application)
29-
* [ShowMessage Demo](#showmessage-demo)
30-
* [BusyWorker Demo](#busyworker-demo)
31-
* [ImageDisplay Demo](#imagedisplay-demo)
32-
* [Status](#status)
33-
* [Discussion and Support](#discussion-and-support)
34-
* [License](#license)
35-
25+
* [Simpler Use of FXML with MVCfx Pattern](#simpler-use-of-fxml-with-mvcfx-pattern)
26+
* [ImageDisplay Component](#imagedisplay-component)
27+
* [Demos](#demos)
28+
* [StopWatch Application](#stopwatch-application)
29+
* [ShowMessage Demo](#showmessage-demo)
30+
* [BusyWorker Demo](#busyworker-demo)
31+
* [ImageDisplay Demo](#imagedisplay-demo)
32+
* [Status](#status)
33+
* [Discussion and Support](#discussion-and-support)
34+
* [License](#license)
3635
<!-- TOC -->
3736

3837
Project Structure
@@ -80,9 +79,9 @@ Example execution some code on a separate thread and waiting for the result of c
8079

8180
```scala
8281
val x = offFXAndWait {
83-
val a = 3
84-
val b = 7
85-
a * b
82+
val a = 3
83+
val b = 7
84+
a * b
8685
}
8786

8887
```
@@ -95,10 +94,10 @@ Standard dialogs can be quickly displayed using functions provided my `ShowMessa
9594
import org.scalafx.extras.ShowMessage
9695

9796
ShowMessage.information(
98-
"Dialog Title",
99-
"This is the information 'header'",
100-
"This is the information detailed 'content'.",
101-
parentWindow
97+
"Dialog Title",
98+
"This is the information 'header'",
99+
"This is the information detailed 'content'.",
100+
parentWindow
102101
)
103102
```
104103

@@ -120,20 +119,80 @@ exceptions dialogs are displayed.
120119
```scala
121120
class MyUIModel extends Model with ShowMessage {
122121

123-
def onSomeUserAction(): Unit = {
124-
// ...
125-
showInformation("Dialog Title",
126-
"This is the information 'header'",
127-
"This is the information detailed 'content'.")
128-
// ...
129-
}
122+
def onSomeUserAction(): Unit = {
123+
// ...
124+
showInformation("Dialog Title",
125+
"This is the information 'header'",
126+
"This is the information detailed 'content'.")
127+
// ...
128+
}
130129

131-
// ...
130+
// ...
132131
}
133132
```
134133

135134
The demos module has a complete example of a simple application in `ShowMessageDemoApp`.
136135

136+
### Easy Custom Panes
137+
138+
`GenericPane` is a helper class that simplifies creation of panes. Particularly suited for creation of input controls.
139+
140+
Typically there are 4 steps to using a `GenericPane`:
141+
142+
1. Creation, where elements of the pane are appended vertically using `add*(...)` methods, for instance,
143+
`addStringField(label, defaultText)`
144+
145+
2. Adding the pane to the UI
146+
147+
3. User interaction, after the pane is displayed
148+
149+
4. Optionally, reading of input. Pane's editable content can be read using `next*()` methods. Content is read in the
150+
order it is added. The whole pane content can be read multiple tiles. Remember to call `resetReadout()` to ensure
151+
that reading is restarted from the beginning of the pane.
152+
153+
A complete example in Scala 3. Shows a pane with 2 directory selection fields and a button "Print Fields". When the
154+
button is pressed values
155+
of the directory fields are printed
156+
157+
[//]: # (@formatter:off)
158+
```scala
159+
import scalafx.application.JFXApp3
160+
import scalafx.application.JFXApp3.PrimaryStage
161+
import scalafx.geometry.Insets
162+
import scalafx.scene.Scene
163+
import scalafx.scene.control.Button
164+
import scalafx.scene.layout.VBox
165+
import scalafx.scene.paint.*
166+
import scalafx.scene.paint.Color.*
167+
import scalafx.scene.text.Text
168+
169+
object GenericPaneDemo extends JFXApp3:
170+
171+
override def start(): Unit =
172+
173+
val gp = new GenericPane():
174+
addDirectoryField("Input", "images")
175+
addDirectoryField("Output", "output")
176+
177+
stage = new PrimaryStage:
178+
title = "GenericPane Demo"
179+
scene = new Scene:
180+
content = new VBox:
181+
padding = Insets(7, 7, 7, 7)
182+
spacing = 7
183+
children = Seq(
184+
gp.pane,
185+
new Button("Print Fields"):
186+
onAction = (_) =>
187+
gp.resetReadout()
188+
println(s"Input dir : ${gp.nextString()}")
189+
println(s"Output dir: ${gp.nextString()}")
190+
)
191+
```
192+
[//]: # (@formatter:off)
193+
194+
![GenericPane Demo](notes/assets/GenericPane.png)
195+
137196
### Easy Custom Dialogs
138197

139198
Custom dialogs can be quickly created using `GenericDialogFX` class. This class is particularly suited for creation of
@@ -152,27 +211,27 @@ Here is en example:
152211
```scala
153212
// Create a dialog
154213
val dialog =
155-
new GenericDialogFX(
156-
title = "GenericDialogFX Demo",
157-
header = "Fancy description can go here."
158-
) {
159-
// Add fields
160-
addCheckbox("Check me out!", defaultValue = false)
161-
addCheckbox("Check me too!", defaultValue = true)
162-
}
214+
new GenericDialogFX(
215+
title = "GenericDialogFX Demo",
216+
header = "Fancy description can go here."
217+
) {
218+
// Add fields
219+
addCheckbox("Check me out!", defaultValue = false)
220+
addCheckbox("Check me too!", defaultValue = true)
221+
}
163222

164223
// Show dialog to the user
165224
dialog.showDialog()
166225

167226
// Read input provided by the user
168227
if (dialog.wasOKed) {
169-
val select1 = dialog.nextBoolean()
170-
val select2 = dialog.nextBoolean()
228+
val select1 = dialog.nextBoolean()
229+
val select2 = dialog.nextBoolean()
171230

172-
println(s"Selection 1: $select1")
173-
println(s"Selection 2: $select2")
231+
println(s"Selection 1: $select1")
232+
println(s"Selection 2: $select2")
174233
} else {
175-
println("Dialog was cancelled.")
234+
println("Dialog was cancelled.")
176235
}
177236
```
178237

@@ -198,10 +257,10 @@ case class FilterOptions(kernelSize: Int = 7,
198257
val filterOptions = FilterOptions()
199258

200259
val result: Option[FilterOptions] =
201-
new AutoDialog(filterOptions)
202-
.showDialog(
203-
"AutoDialog Demo",
204-
"Fields are auto generated from `FilterOptions` object")
260+
new AutoDialog(filterOptions)
261+
.showDialog(
262+
"AutoDialog Demo",
263+
"Fields are auto generated from `FilterOptions` object")
205264

206265
println(s"Result: $result")
207266
```

build.sbt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _}
1010
// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name")
1111
//
1212

13-
val projectVersion = "0.7.0"
13+
val projectVersion = "0.7.0.1-SNAPSHOT"
1414
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v." + projectVersion
15-
val _scalaVersions = Seq("3.0.2", "2.13.8", "2.12.16")
15+
val _scalaVersions = Seq("3.2.2", "2.13.10", "2.12.17")
1616
val _scalaVersion = _scalaVersions.head
1717

1818
ThisBuild / version := projectVersion
@@ -77,8 +77,8 @@ lazy val scalaFXExtrasDemos = (project in file("scalafx-extras-demos")).settings
7777
),
7878
publishArtifact := false,
7979
libraryDependencies ++= Seq(
80-
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4",
81-
"ch.qos.logback" % "logback-classic" % "1.2.11"
80+
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
81+
"ch.qos.logback" % "logback-classic" % "1.4.7" % Runtime
8282
)
8383
).dependsOn(scalaFXExtras % "compile;test->test")
8484

@@ -148,13 +148,13 @@ lazy val scalaFXExtrasSettings = Seq(
148148
Seq.empty[sbt.ModuleID]
149149
),
150150
libraryDependencies ++= Seq(
151-
"org.scalafx" %% "scalafx" % "18.0.2-R29",
152-
"org.scalatest" %% "scalatest" % "3.2.11" % "test"
151+
"org.scalafx" %% "scalafx" % "20.0.0-R31",
152+
"org.scalatest" %% "scalatest" % "3.2.15" % "test"
153153
),
154154
libraryDependencies ++= (
155155
if (isScala2(scalaVersion.value))
156156
Seq(
157-
"com.beachape" %% "enumeratum" % "1.7.0",
157+
"com.beachape" %% "enumeratum" % "1.7.2",
158158
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
159159
"org.scalafx" %% "scalafxml-core-sfx8" % "0.5"
160160
)
@@ -204,7 +204,7 @@ lazy val manifestSetting = packageOptions += {
204204
)
205205
}
206206

207-
import xerial.sbt.Sonatype._
207+
import xerial.sbt.Sonatype.*
208208

209209
// Metadata needed by Maven Central
210210
// See also http://maven.apache.org/pom.html#Developers

notes/0.8.0.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
## ScalaFX-Extras Release v.0.8.0
2+
3+
This release of [ScalaFX-Extras] add ability to conveniently add fields and read data from a pane using `GenericPane`. Add a couple bug fixes
4+
5+
### New features
6+
7+
In addition to `GenericDialogFX` there is a `GenericPane` that can be used to build a `Pane` that can be used with more
8+
granularity in designing UIs. It can be used as a part of other, more complex, control. Example:
9+
10+
[//]: # (@formatter:off)
11+
```scala
12+
import scalafx.application.JFXApp3
13+
import scalafx.application.JFXApp3.PrimaryStage
14+
import scalafx.geometry.Insets
15+
import scalafx.scene.Scene
16+
import scalafx.scene.control.Button
17+
import scalafx.scene.layout.VBox
18+
import scalafx.scene.paint.*
19+
import scalafx.scene.paint.Color.*
20+
import scalafx.scene.text.Text
21+
22+
object GenericPaneDemo extends JFXApp3:
23+
24+
override def start(): Unit =
25+
26+
val gp = new GenericPane():
27+
addDirectoryField("Input", "images")
28+
addDirectoryField("Output", "output")
29+
30+
stage = new PrimaryStage:
31+
title = "GenericPane Demo"
32+
scene = new Scene:
33+
content = new VBox:
34+
padding = Insets(7, 7, 7, 7)
35+
spacing = 7
36+
children = Seq(
37+
gp.pane,
38+
new Button("Print Fields"):
39+
onAction = (_) =>
40+
gp.resetReadout()
41+
println(s"Input dir : ${gp.nextString()}")
42+
println(s"Output dir: ${gp.nextString()}")
43+
)
44+
```
45+
[//]: # (@formatter:on)
46+
47+
The `scalafx-extras-demos` subproject has an example.
48+
49+
#### Additional features:
50+
51+
* The preferred width (expressed in text columns) of the text field in `FileSelectionField` can now be controlled. This
52+
adds similar options to
53+
* `GenericPaneBase.addDirectoryField`
54+
* `GenericPaneBase.addFileField`
55+
56+
### Breaking Changes
57+
58+
* Package name `org.scalafx.extras.generic_dialog` was changed to `org.scalafx.extras.generic_pane`
59+
* The constructor of `GenericDialogFX` parameter's name `parentWindow` was changes to `ownerWindow` to avoid conflict
60+
with similarly named parameter in `GenericPaneBase`
61+
62+
### All changes:
63+
64+
* Add: Generic Pane [[#22]]
65+
* Fix: `GenericPaneBase.addDirectoryField` - is ignoring argument columns [[#23]]
66+
* Fix: `GenericPaneBase.addFileField` is missing argument columns [[#24]]
67+
* Fix: `IllegalAccessError` in `AutoDialog` (0.7.0) [[#25]]
68+
69+
To post questions please use [Project Discussions][Discussions] or [ScalaFX Users Group][scalafx-users]
70+
71+
[ScalaFX-Extras]: https://github.com/scalafx/scalafx-extras
72+
73+
[Discussions]: https://github.com/scalafx/scalafx-extras/discussions
74+
75+
[scalafx-users]: https://groups.google.com/forum/#!forum/scalafx-users
76+
77+
[#22]: https://github.com/scalafx/scalafx-extras/issues/22
78+
79+
[#23]: https://github.com/scalafx/scalafx-extras/issues/23
80+
81+
[#24]: https://github.com/scalafx/scalafx-extras/issues/24
82+
83+
[#25]: https://github.com/scalafx/scalafx-extras/issues/25
84+

notes/assets/GenericPane.png

6.22 KB
Loading

project/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011-2022, ScalaFX Project
2+
# Copyright (c) 2011-2023, ScalaFX Project
33
# All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
@@ -24,5 +24,5 @@
2424
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2525
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
#
27-
sbt.version=1.7.1
27+
sbt.version=1.8.2
2828

0 commit comments

Comments
 (0)