Skip to content

Commit e1c6775

Browse files
committed
Merge branch 'master' into release
2 parents 39aec01 + ce861b6 commit e1c6775

File tree

29 files changed

+1131
-428
lines changed

29 files changed

+1131
-428
lines changed

.scalafmt.conf

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version = 3.1.1
2+
3+
runner.dialect = scala3
4+
5+
preset = IntelliJ
6+
align.preset = more
7+
maxColumn = 120
8+
docstrings.style = Asterisk
9+
docstrings.blankFirstLine = yes
10+
importSelectors = singleLine
11+
newlines.source = keep

ReadMe.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ The demos module has a complete example of an simple application in `ShowMessage
100100

101101
### BusyWorker
102102

103-
BusyWorker helps running a UI task on separate threads (other than the JavaFX Application thread).
104-
It will show busy cursor and disable specified nodes while the task is performed.
105-
It gives an option to show progress and status messages.
106-
`BusyWorker` takes care of handling handling exceptions and displaying error dialogs.
107-
It provides for an option to perform custom finish actions after task is completed.
103+
BusyWorker helps running a UI task on separate threads (other than the JavaFX Application thread). It will show busy
104+
cursor and disable specified nodes while the task is performed. It gives an option to show progress and status messages.
105+
`BusyWorker` takes care of handling exceptions and displaying error dialogs. It provides for an option to perform custom
106+
finish actions after task is completed.
108107

109108
#### Example 1
110109

@@ -122,7 +121,7 @@ new BusyWorker("Simple Task", parentWindow).doTask { () =>
122121

123122
#### Examnple 2
124123

125-
Her is a little bit more elaborated example. It updates a progress message and progress indicator.
124+
Here is a little more elaborated example. It updates a progress message and progress indicator.
126125
```scala
127126
val buttonPane: Pane = ...
128127
val progressLabel: Label = ...
@@ -163,8 +162,8 @@ The demos module has a complete example of a simple application: [StopWatchApp][
163162

164163
### ImageDisplay Component
165164

166-
ImageDisplay Component is an image view with ability to zoom in, zoom out, zoom to fit.
167-
It can also automatically resizes to parent size.
165+
ImageDisplay Component is an image view with ability to zoom in, zoom out, zoom to fit. It can also automatically resize
166+
to parent size.
168167

169168

170169
Demos

build.sbt

+121-62
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,73 @@ 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.3.6"
14-
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v." + projectVersion
15-
val _scalaVersions = Seq("2.13.4", "2.12.12")
16-
val _scalaVersion = _scalaVersions.head
17-
val _javaFXVersion = "15.0.1"
18-
19-
version := projectVersion
20-
crossScalaVersions := _scalaVersions
21-
scalaVersion := _scalaVersion
22-
publishArtifact := false
23-
skip in publish := true
24-
sonatypeProfileName := "org.scalafx"
13+
val projectVersion = "0.3.6.1-SNAPSHOT"
14+
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v." + projectVersion
15+
val _scalaVersions = Seq("2.13.7", "2.12.15", "3.0.2", "3.1.0")
16+
val _scalaVersion = _scalaVersions.head
17+
val _javaFXVersion = "16"
18+
19+
ThisBuild / version := projectVersion
20+
ThisBuild / crossScalaVersions := _scalaVersions
21+
ThisBuild / scalaVersion := _scalaVersion
22+
ThisBuild / publishArtifact := false
23+
ThisBuild / publish / skip := true
24+
ThisBuild / sonatypeProfileName := "org.scalafx"
2525

2626
lazy val OSName = System.getProperty("os.name") match {
2727
case n if n.startsWith("Linux") => "linux"
2828
case n if n.startsWith("Mac") => "mac"
2929
case n if n.startsWith("Windows") => "win"
3030
case _ => throw new Exception("Unknown platform!")
3131
}
32-
32+
3333
lazy val JavaFXModuleNames = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
3434
lazy val JavaFXModuleLibsProvided: Seq[ModuleID] =
3535
JavaFXModuleNames.map(m => "org.openjfx" % s"javafx-$m" % _javaFXVersion % "provided" classifier OSName)
3636
lazy val JavaFXModuleLibs: Seq[ModuleID] =
3737
JavaFXModuleNames.map(m => "org.openjfx" % s"javafx-$m" % _javaFXVersion classifier OSName)
3838

39+
def isScala2(scalaVersion: String): Boolean = {
40+
CrossVersion.partialVersion(scalaVersion) match {
41+
case Some((2, _)) => true
42+
case _ => false
43+
}
44+
}
3945

40-
def isScala2_13plus(scalaVersion: String): Boolean = {
46+
def isScala2_12(scalaVersion: String): Boolean = {
4147
CrossVersion.partialVersion(scalaVersion) match {
42-
case Some((2, n)) if n >= 13 => true
43-
case _ => false
48+
case Some((2, 12)) => true
49+
case _ => false
4450
}
4551
}
4652

53+
def isScala2_13(scalaVersion: String): Boolean = {
54+
CrossVersion.partialVersion(scalaVersion) match {
55+
case Some((2, 13)) => true
56+
case _ => false
57+
}
58+
}
59+
60+
// Add src/main/scala-3- for Scala 2.13 and older
61+
// and src/main/scala-3+ for Scala versions older than 3 and newer
62+
def versionSubDir(scalaVersion: String): String =
63+
CrossVersion.partialVersion(scalaVersion) match {
64+
case Some((2, _)) => "scala-2"
65+
case Some((3, _)) => "scala-3"
66+
case _ => throw new Exception(s"Unsupported scala version $scalaVersion")
67+
}
68+
4769
// ScalaFX Extras project
4870
lazy val scalaFXExtras = (project in file("scalafx-extras")).settings(
4971
scalaFXExtrasSettings,
5072
name := "scalafx-extras",
5173
description := "The ScalaFX Extras",
52-
scalacOptions in(Compile, doc) ++= Seq(
53-
"-sourcepath", baseDirectory.value.toString,
54-
"-doc-root-content", baseDirectory.value + "/src/main/scala/root-doc.creole",
55-
"-doc-source-url", "https://github.com/SscalaFX-Extras/scalafx-extras/blob/" + versionTagDir + "/scalafx/€{FILE_PATH}.scala"
74+
Compile / doc / scalacOptions ++= Seq(
75+
"-sourcepath",
76+
baseDirectory.value.toString,
77+
"-doc-root-content",
78+
baseDirectory.value + "/src/main/scala/root-doc.creole"
5679
),
57-
scalacOptions in(Compile, doc) ++= (
58-
Option(System.getenv("GRAPHVIZ_DOT_PATH")) match {
59-
case Some(path) => Seq("-diagrams", "-diagrams-dot-path", path)
60-
case None => Seq.empty[String]
61-
})
6280
)
6381

6482
// ScalaFX Extras Demos project
@@ -70,13 +88,12 @@ lazy val scalaFXExtrasDemos = (project in file("scalafx-extras-demos")).settings
7088
"-Xmx512M",
7189
"-Djavafx.verbose"
7290
),
73-
scalacOptions ++= Seq("-deprecation"),
7491
libraryDependencies ++= JavaFXModuleLibs,
7592
publishArtifact := false,
7693
libraryDependencies ++= Seq(
77-
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
78-
"ch.qos.logback" % "logback-classic" % "1.2.3"
79-
),
94+
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4",
95+
"ch.qos.logback" % "logback-classic" % "1.2.7"
96+
)
8097
).dependsOn(scalaFXExtras % "compile;test->test")
8198

8299
// Resolvers
@@ -89,33 +106,71 @@ lazy val scalaFXExtrasSettings = Seq(
89106
organization := "org.scalafx",
90107
version := projectVersion,
91108
crossScalaVersions := _scalaVersions,
92-
scalaVersion := _scalaVersion,
93-
scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8", "-feature"),
94-
scalacOptions in(Compile, doc) ++= Opts.doc.title("ScalaFX Extras API"),
95-
scalacOptions in(Compile, doc) ++= Opts.doc.version(projectVersion),
96-
scalacOptions in(Compile, doc) += s"-doc-external-doc:${scalaInstance.value.libraryJars.head}#http://www.scala-lang.org/api/${scalaVersion.value}/",
97-
scalacOptions in(Compile, doc) ++= Seq("-doc-footer", s"ScalaFX Extras API v.$projectVersion"),
109+
scalaVersion := _scalaVersion,
110+
// SAdd version specific directories
111+
Compile / unmanagedSourceDirectories += (Compile / sourceDirectory).value / versionSubDir(scalaVersion.value),
112+
Test / unmanagedSourceDirectories += (Test / sourceDirectory).value / versionSubDir(scalaVersion.value),
113+
//
114+
scalacOptions ++= Seq(
115+
"-unchecked",
116+
"-deprecation",
117+
"-encoding",
118+
"utf8",
119+
"-feature"
120+
) ++
121+
(
122+
if (isScala2(scalaVersion.value))
123+
Seq("-Xcheckinit")
124+
else
125+
Seq.empty[String]
126+
),
127+
Compile / doc / scalacOptions ++= Opts.doc.title("ScalaFX Extras API"),
128+
Compile / doc / scalacOptions ++= Opts.doc.version(projectVersion),
129+
Compile / doc / scalacOptions ++= Seq("-doc-footer", s"ScalaFX Extras API v.$projectVersion"),
130+
Compile / doc / scalacOptions ++= (
131+
if(isScala2(scalaVersion.value))
132+
Seq(
133+
s"-doc-external-doc:${scalaInstance.value.libraryJars.head}#http://www.scala-lang.org/api/${scalaVersion.value}/",
134+
"-doc-source-url", "https://github.com/SscalaFX-Extras/scalafx-extras/blob/" + versionTagDir + "/scalafx/€{FILE_PATH}.scala"
135+
) ++ (
136+
Option(System.getenv("GRAPHVIZ_DOT_PATH")) match {
137+
case Some(path) => Seq("-diagrams", "-diagrams-dot-path", path)
138+
case None => Seq.empty[String]
139+
}
140+
)
141+
else
142+
Seq.empty[String]
143+
),
98144
// If using Scala 2.13 or better, enable macro processing through compiler option
99-
scalacOptions += (if (isScala2_13plus(scalaVersion.value)) "-Ymacro-annotations" else ""),
145+
scalacOptions += (if (isScala2_13(scalaVersion.value)) "-Ymacro-annotations" else ""),
100146
// If using Scala 2.12 or lower, enable macro processing through compiler plugin
101147
libraryDependencies ++= (
102-
if (!isScala2_13plus(scalaVersion.value))
148+
if (isScala2_12(scalaVersion.value))
103149
Seq(compilerPlugin(
104-
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full))
150+
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full
151+
))
105152
else
106153
Seq.empty[sbt.ModuleID]
107-
),
154+
),
108155
javacOptions ++= Seq(
109156
// "-target", "1.8",
110157
// "-source", "1.8",
111-
"-Xlint:deprecation"),
158+
"-Xlint:deprecation"
159+
),
112160
libraryDependencies ++= Seq(
113-
"com.beachape" %% "enumeratum" % "1.6.1",
114-
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
115-
"org.scalafx" %% "scalafx" % "15.0.1-R21",
116-
"org.scalafx" %% "scalafxml-core-sfx8" % "0.5",
117-
"org.scalatest" %% "scalatest" % "3.2.3" % "test"
161+
"org.scalafx" %% "scalafx" % "16.0.0-R25",
162+
"org.scalatest" %% "scalatest" % "3.2.10" % "test"
118163
) ++ JavaFXModuleLibsProvided,
164+
libraryDependencies ++= (
165+
if (isScala2(scalaVersion.value))
166+
Seq(
167+
"com.beachape" %% "enumeratum" % "1.7.0",
168+
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
169+
"org.scalafx" %% "scalafxml-core-sfx8" % "0.5"
170+
)
171+
else
172+
Seq.empty[sbt.ModuleID]
173+
),
119174
// Use `pomPostProcess` to remove dependencies marked as "provided" from publishing in POM
120175
// This is to avoid dependency on wrong OS version JavaFX libraries
121176
// See also [https://stackoverflow.com/questions/27835740/sbt-exclude-certain-dependency-only-during-publish]
@@ -124,30 +179,29 @@ lazy val scalaFXExtrasSettings = Seq(
124179
override def transform(node: XmlNode): XmlNodeSeq = node match {
125180
case e: Elem if e.label == "dependency" && e.child.exists(c => c.label == "scope" && c.text == "provided") =>
126181
val organization = e.child.filter(_.label == "groupId").flatMap(_.text).mkString
127-
val artifact = e.child.filter(_.label == "artifactId").flatMap(_.text).mkString
128-
val version = e.child.filter(_.label == "version").flatMap(_.text).mkString
182+
val artifact = e.child.filter(_.label == "artifactId").flatMap(_.text).mkString
183+
val version = e.child.filter(_.label == "version").flatMap(_.text).mkString
129184
Comment(s"provided dependency $organization#$artifact;$version has been omitted")
130185
case _ => node
131186
}
132187
}).transform(node).head
133188
},
134189
autoAPIMappings := true,
135190
manifestSetting,
136-
fork in run := true,
137-
fork in Test := true,
138-
parallelExecution in Test := false,
191+
run / fork := true,
192+
Test / fork := true,
193+
Test / parallelExecution := false,
139194
resolvers += Resolver.sonatypeRepo("snapshots"),
140195
// print junit-style XML for CI
141-
testOptions in Test += {
142-
val t = (target in Test).value
196+
Test / testOptions += {
197+
val t = (Test / target).value
143198
Tests.Argument(TestFrameworks.ScalaTest, "-u", s"$t/junitxmldir")
144-
},
145-
shellPrompt in ThisBuild := { state => "sbt:" + Project.extract(state).currentRef.project + "> " }
199+
}
146200
) ++ mavenCentralSettings
147201

148202
lazy val manifestSetting = packageOptions += {
149203
Package.ManifestAttributes(
150-
"Created-By" -> "Simple Build Tool",
204+
"Created-By" -> "Simple Build Tool",
151205
"Built-By" -> Option(System.getenv("JAR_BUILT_BY")).getOrElse(System.getProperty("user.name")),
152206
"Build-Jdk" -> System.getProperty("java.version"),
153207
"Specification-Title" -> name.value,
@@ -165,14 +219,19 @@ import xerial.sbt.Sonatype._
165219
// Metadata needed by Maven Central
166220
// See also http://maven.apache.org/pom.html#Developers
167221
lazy val mavenCentralSettings = Seq(
168-
homepage := Some(new URL("http://www.scalafx.org/")),
169-
startYear := Some(2016),
170-
licenses := Seq(("BSD", new URL("https://github.com/scalafx/scalafx-extras/blob/master/LICENSE.txt"))),
171-
sonatypeProfileName := "org.scalafx",
222+
homepage := Some(new URL("http://www.scalafx.org/")),
223+
startYear := Some(2016),
224+
licenses := Seq(("BSD", new URL("https://github.com/scalafx/scalafx-extras/blob/master/LICENSE.txt"))),
225+
sonatypeProfileName := "org.scalafx",
172226
sonatypeProjectHosting := Some(GitHubHosting("org.scalafx", "scalafx-extras", "[email protected]")),
173-
publishMavenStyle := true,
174-
publishTo := sonatypePublishToBundle.value,
227+
publishMavenStyle := true,
228+
publishTo := sonatypePublishToBundle.value,
175229
developers := List(
176-
Developer(id="jpsacha", name="Jarek Sacha", email="[email protected]", url=url("https://github.com/jpsacha"))
230+
Developer(
231+
id = "jpsacha",
232+
name = "Jarek Sacha",
233+
email = "[email protected]",
234+
url = url("https://github.com/jpsacha")
235+
)
177236
)
178237
)

notes/0.4.0.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### ScalaFX-Extras Release v.0.4.0
2+
3+
Enhancement:
4+
5+
* Support use in Scala 3 by removing use of ScalaFX (Scala 2 macros) [Issue #12][12]. That required some changes in
6+
MVCfx API (Scala 2 use stays the same). See demos for examples of the new use.
7+
* Update to ScalaFX 16.0.0-R25
8+
9+
To post questions please use [Project Discussions][Discussions] or [ScalaFX Users Group][scalafx-users]
10+
11+
[scalafx-users]: https://groups.google.com/forum/#!forum/scalafx-users
12+
13+
[Discussions]: https://github.com/scalafx/scalafx-extras/discussions
14+
15+
[12]: https://github.com/scalafx/scalafx-extras/issues/12
16+

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.4.6
27+
sbt.version=1.5.5
2828

scalafx-extras-demos/src/main/scala/org/scalafx/extras/mvcfx/stopwatch/StopWatch.scala renamed to scalafx-extras-demos/src/main/scala-2/org/scalafx/extras/mvcfx/stopwatch/StopWatch.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2016, ScalaFX Project
2+
* Copyright (c) 2011-2021, ScalaFX Project
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without

scalafx-extras-demos/src/main/scala/org/scalafx/extras/showmessage/ShowMessageDemo.scala renamed to scalafx-extras-demos/src/main/scala-2/org/scalafx/extras/showmessage/ShowMessageDemo.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2018, ScalaFX Project
2+
* Copyright (c) 2011-2021, ScalaFX Project
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2011-2021, ScalaFX Project
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the ScalaFX Project nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL THE SCALAFX PROJECT OR ITS CONTRIBUTORS BE LIABLE
20+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package org.scalafx.extras.mvcfx.stopwatch
29+
30+
import javafx.util as jfxu
31+
32+
import org.scalafx.extras.mvcfx.MVCfx
33+
34+
/**
35+
* StopWatch generator/loader.
36+
*/
37+
class StopWatch(val model: StopWatchModel = new StopWatchModel())
38+
extends MVCfx[StopWatchController]("/org/scalafx/extras/mvcfx/stopwatch/StopWatch.fxml") {
39+
40+
def controllerInstance: StopWatchController = new StopWatchController(model)
41+
}

0 commit comments

Comments
 (0)