Skip to content

Commit 0831b9d

Browse files
committed
Merge branch 'master' into release
2 parents d5c8a50 + 7e274ff commit 0831b9d

File tree

22 files changed

+1506
-153
lines changed

22 files changed

+1506
-153
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ project/target
2626
.externalToolBuilders/
2727
/_local_/
2828
/.bsp/
29+
.DS_Store

.scalafmt.conf

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

33
runner.dialect = scala3
44
fileOverride {

ReadMe.md

Lines changed: 93 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ Extras do not have direct corresponding concepts in JavaFX.
1313
0. [Project Structure](#project-structure)
1414
0. [SBT](#sbt)
1515
0. [Features](#features)
16-
1. [Helper Methods](#helper-methods)
17-
1. [Simpler Display of Dialogs](#simpler-display-of-dialogs)
18-
1. [BusyWorker](#busyworker)
19-
1. [Simpler Use of FXML with MVCfx Pattern](#simpler-use-of-fxml-with-mvcfx-pattern)
20-
1. [Image Display Component](#imagedisplay-component)
16+
1. [Helper Methods](#helper-methods)
17+
1. [Simpler Display of Standard Dialogs](#simpler-display-of-standard-dialogs)
18+
1. [Easy Custom Dialogs](#easy-custom-dialogs)
19+
1. [BusyWorker](#busyworker)
20+
1. [Simpler Use of FXML with MVCfx Pattern](#simpler-use-of-fxml-with-mvcfx-pattern)
21+
1. [Image Display Component](#imagedisplay-component)
2122
0. [Demos](#demos)
22-
1. [StopWatch Application](#stopwatch-application)
23-
1. [ShowMessage Demo](#showmessage-demo)
24-
1. [BusyWorker Demo](#busyworker-demo)
25-
1. [ImageDisplay Demo](#imagedisplay-demo)
23+
1. [StopWatch Application](#stopwatch-application)
24+
1. [ShowMessage Demo](#showmessage-demo)
25+
1. [BusyWorker Demo](#busyworker-demo)
26+
1. [ImageDisplay Demo](#imagedisplay-demo)
2627
0. [Status](#status)
2728
0. [Discussion and Support](#discussion-and-support)
2829
0. [License](#license)
@@ -57,7 +58,6 @@ The main helper methods:
5758
* `onFXAndWait` run code on FX Application thread and wait till finished
5859
* `offFX` run code a thread in parallel
5960
* `offFXAndWait` run code a thread and wait till finished
60-
* `showException` show an exception dialog
6161

6262
Example scheduling some code on FX Application thread
6363

@@ -73,37 +73,106 @@ Example execution some code on a separate thread and waiting for the result of c
7373

7474
```scala
7575
val x = offFXAndWait {
76-
val a = 3
77-
val b = 7
78-
a * b
76+
val a = 3
77+
val b = 7
78+
a * b
7979
}
8080

8181
```
8282

83-
### Simpler Display of Dialogs
83+
### Simpler Display of Standard Dialogs
8484

85-
The mixin `ShowMessage` makes it easier to display dialogs. It is typically used with a UI `Model`. The dialogs can be
85+
Standard dialogs can be quickly displayed using functions provided my `ShowMessage`. For instance,
86+
87+
```scala
88+
import org.scalafx.extras.ShowMessage
89+
90+
ShowMessage.information(
91+
"Dialog Title",
92+
"This is the information 'header'",
93+
"This is the information detailed 'content'.",
94+
parentWindow
95+
)
96+
```
97+
98+
Dialog types supported:
99+
100+
* `confirmation`
101+
* `confirmationYesNoCancel`
102+
* `error`
103+
* `exception`
104+
* `information`
105+
* `warning`
106+
107+
`ShowMessage` can be also used as a mixin to be used within a class where there is the same `parentWindow`.
108+
It is typically used with a UI `Model`. The dialogs can be
86109
displayed using a single method, like `showInformation`, `showConfirmation`. `ShowMessage` takes care of blocking parent
87110
windows and using parent icons in dialogs. It can also log warnings, errors, and exceptions when warnings, errors, and
88111
exceptions dialogs are displayed.
89112

90113
```scala
91114
class MyUIModel extends Model with ShowMessage {
92115

93-
def onSomeUserAction(): Unit = {
94-
// ...
95-
showInformation("Dialog Title",
96-
"This is the information \"header\"",
97-
"This is the information detailed \"content\".")
98-
// ...
99-
}
116+
def onSomeUserAction(): Unit = {
117+
// ...
118+
showInformation("Dialog Title",
119+
"This is the information 'header'",
120+
"This is the information detailed 'content'.")
121+
// ...
122+
}
100123

101-
// ...
124+
// ...
102125
}
103126
```
104127

105128
The demos module has a complete example of a simple application in `ShowMessageDemoApp`.
106129

130+
### Easy Custom Dialogs
131+
132+
Custom dialogs can be quickly created using `GenericDialogFX` class. This class is particularly suited for creation of
133+
input dialogs.
134+
135+
There are 3 steps to using the `GenericDialogFX`:
136+
137+
1. Creation, where elements of the dialog are appended vertically using `add*(...)` methods, for
138+
instance,`addStringField(label, defaultText)`
139+
2. User interaction, dialog is displayed using `showDialog()` method
140+
3. Reading of input, once the dialog is closed, dialog content can be read using `next*()` methods. Content is read in
141+
the order it is added.
142+
143+
Here is en example:
144+
145+
```scala
146+
// Create a dialog
147+
val dialog =
148+
new GenericDialogFX(
149+
title = "GenericDialogFX Demo",
150+
header = "Fancy description can go here."
151+
) {
152+
// Add fields
153+
addCheckbox("Check me out!", defaultValue = false)
154+
addCheckbox("Check me too!", defaultValue = true)
155+
}
156+
157+
// Show dialog to the user
158+
dialog.showDialog()
159+
160+
// Read input provided by the user
161+
if (dialog.wasOKed) {
162+
val select1 = dialog.nextBoolean()
163+
val select2 = dialog.nextBoolean()
164+
165+
println(s"Selection 1: $select1")
166+
println(s"Selection 2: $select2")
167+
} else {
168+
println("Dialog was cancelled.")
169+
}
170+
```
171+
172+
![GenericDialogFX Demo](notes/assets/GenericDialogFX_2.png)
173+
174+
A more elaborate example is in the `GenericDialogFXDemo`.
175+
107176
### BusyWorker
108177

109178
BusyWorker helps running a UI task on separate threads (other than the JavaFX Application thread). It will show busy
@@ -129,7 +198,7 @@ new BusyWorker("Simple Task", parentWindow).doTask { () =>
129198
Here is a little more elaborated example. It updates a progress message and progress indicator.
130199

131200
```scala
132-
val buttonPane: Pane =
201+
val buttonPane: Pane =
133202
...
134203
val progressLabel: Label =
135204
...

build.sbt

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ 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.5.0"
13+
val projectVersion = "0.5.0.2-SNAPSHOT"
1414
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v." + projectVersion
15-
val _scalaVersions = Seq("3.0.2", "2.13.7", "2.12.15")
15+
val _scalaVersions = Seq("3.0.2", "2.13.8", "2.12.16")
1616
val _scalaVersion = _scalaVersions.head
17-
val _javaFXVersion = "17.0.1"
17+
val _javaFXVersion = "18.0.1"
1818

1919
ThisBuild / version := projectVersion
2020
ThisBuild / crossScalaVersions := _scalaVersions
@@ -24,18 +24,9 @@ ThisBuild / organization := "org.scalafx"
2424
publishArtifact := false
2525
publish / skip := true
2626

27-
lazy val OSName = System.getProperty("os.name") match {
28-
case n if n.startsWith("Linux") => "linux"
29-
case n if n.startsWith("Mac") => "mac"
30-
case n if n.startsWith("Windows") => "win"
31-
case _ => throw new Exception("Unknown platform!")
32-
}
33-
34-
lazy val JavaFXModuleNames = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
35-
lazy val JavaFXModuleLibsProvided: Seq[ModuleID] =
36-
JavaFXModuleNames.map(m => "org.openjfx" % s"javafx-$m" % _javaFXVersion % "provided" classifier OSName)
3727
lazy val JavaFXModuleLibs: Seq[ModuleID] =
38-
JavaFXModuleNames.map(m => "org.openjfx" % s"javafx-$m" % _javaFXVersion classifier OSName)
28+
Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
29+
.map(m => "org.openjfx" % s"javafx-$m" % _javaFXVersion)
3930

4031
def isScala2(scalaVersion: String): Boolean = {
4132
CrossVersion.partialVersion(scalaVersion) match {
@@ -93,14 +84,14 @@ lazy val scalaFXExtrasDemos = (project in file("scalafx-extras-demos")).settings
9384
publishArtifact := false,
9485
libraryDependencies ++= Seq(
9586
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4",
96-
"ch.qos.logback" % "logback-classic" % "1.2.9"
87+
"ch.qos.logback" % "logback-classic" % "1.2.11"
9788
)
9889
).dependsOn(scalaFXExtras % "compile;test->test")
9990

10091
// Resolvers
10192
// Add snapshots to root project to enable compilation with Scala SNAPSHOT compiler,
10293
// e.g., 2.11.0-SNAPSHOT
103-
resolvers += Resolver.sonatypeRepo("snapshots")
94+
resolvers ++= Resolver.sonatypeOssRepos("snapshots")
10495

10596
// Common settings
10697
lazy val scalaFXExtrasSettings = Seq(
@@ -113,7 +104,8 @@ lazy val scalaFXExtrasSettings = Seq(
113104
"-deprecation",
114105
"-encoding",
115106
"utf8",
116-
"-feature"
107+
"-feature",
108+
"-release", "8"
117109
) ++
118110
(
119111
if (isScala2(scalaVersion.value))
@@ -161,15 +153,10 @@ lazy val scalaFXExtrasSettings = Seq(
161153
else
162154
Seq.empty[sbt.ModuleID]
163155
),
164-
javacOptions ++= Seq(
165-
"-target", "1.8",
166-
"-source", "1.8",
167-
"-Xlint:deprecation"
168-
),
169156
libraryDependencies ++= Seq(
170-
"org.scalafx" %% "scalafx" % "17.0.1-R26",
171-
"org.scalatest" %% "scalatest" % "3.2.10" % "test"
172-
) ++ JavaFXModuleLibsProvided,
157+
"org.scalafx" %% "scalafx" % "18.0.1-R27",
158+
"org.scalatest" %% "scalatest" % "3.2.11" % "test"
159+
) ++ JavaFXModuleLibs,
173160
libraryDependencies ++= (
174161
if (isScala2(scalaVersion.value))
175162
Seq(
@@ -200,7 +187,7 @@ lazy val scalaFXExtrasSettings = Seq(
200187
run / fork := true,
201188
Test / fork := true,
202189
Test / parallelExecution := false,
203-
resolvers += Resolver.sonatypeRepo("snapshots"),
190+
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
204191
// print junit-style XML for CI
205192
Test / testOptions += {
206193
val t = (Test / target).value

notes/0.6.0.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
### ScalaFX-Extras Release v.0.6.0
2+
3+
This release add a new class for convenient creation of input dialogs: `GenericDialogFX`. You can easily add controls to
4+
he dialog then
5+
read their values after the dialog was closed
6+
7+
```scala
8+
// Create a dialog
9+
val dialog =
10+
new GenericDialogFX(
11+
title = "GenericDialogFX Demo",
12+
header = "Fancy description can go here."
13+
) {
14+
// Add fields
15+
addCheckbox("Check me out!", defaultValue = false)
16+
addCheckbox("Check me too!", defaultValue = true)
17+
}
18+
19+
// Show dialog to the user
20+
dialog.showDialog()
21+
22+
// Read input provided by the user
23+
if (dialog.wasOKed) {
24+
val select1 = dialog.nextBoolean()
25+
val select2 = dialog.nextBoolean()
26+
27+
println(s"Selection 1: $select1")
28+
println(s"Selection 2: $select2")
29+
} else {
30+
println("Dialog was cancelled.")
31+
}
32+
```
33+
34+
The `scalafx-extras-demos` subproject has a more elaborated example.
35+
36+
Enhancements:
37+
38+
* Support creation of custom dialogs, like ImageJ's GenericDialog #16
39+
* Let any standard dialog be displayed with a one-liner #17
40+
41+
To post questions please use [Project Discussions][Discussions] or [ScalaFX Users Group][scalafx-users]
42+
43+
[Discussions]: https://github.com/scalafx/scalafx-extras/discussions
44+
45+
[scalafx-users]: https://groups.google.com/forum/#!forum/scalafx-users
46+
47+
[Issue #16]: https://github.com/scalafx/scalafx-extras/issues/16
48+
49+
[Issue #17]: https://github.com/scalafx/scalafx-extras/issues/17
50+

notes/assets/GenericDialogFX_2.png

13.6 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-2021, ScalaFX Project
2+
# Copyright (c) 2011-2022, 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.6.0-RC1
27+
sbt.version=1.7.1
2828

project/sbt-sonatype.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// [https://github.com/xerial/sbt-sonatype]
2-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.10")
2+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13")
33
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.1.1")

0 commit comments

Comments
 (0)