Skip to content

Commit 2ec8d9e

Browse files
committed
Merge remote-tracking branch 'origin/master' into stable
2 parents 4568444 + 9367027 commit 2ec8d9e

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ sudo: false
22

33
language: scala
44
scala:
5-
- 2.10.7
6-
- 2.11.12
7-
- 2.12.6
5+
#- 2.11.12
6+
- 2.12.7
87

98
before_install:
109
- "export DISPLAY=:99.0"

ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ It will also change the cursor in the root pane to busy.
112112
When task is done, the cursor will be changed back to default and root pane will enabled back.
113113

114114
```scala
115-
new BusyWorker("Simple Task", parentWindow).doTask {
115+
new BusyWorker("Simple Task", parentWindow).doTask { () =>
116116
Thread.sleep(1000)
117117
print(1 + 1)
118118
}

build.sbt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import java.net.URL
88
// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name")
99
//
1010

11-
val projectVersion = "0.2.1"
11+
val projectVersion = "0.2.2-SNAPSHOT"
1212
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v" + projectVersion
13-
val scalaVersions = Seq("2.11.12", "2.12.7")
13+
val _scalaVersions = Seq("2.12.7")
14+
val _scalaVersion = _scalaVersions.head
1415

15-
crossScalaVersions := scalaVersions
16-
scalaVersion := crossScalaVersions { versions => versions.head }.value
16+
crossScalaVersions := _scalaVersions
17+
scalaVersion := _scalaVersion
1718

1819
lazy val OSName = System.getProperty("os.name") match {
1920
case n if n.startsWith("Linux") => "linux"
@@ -31,23 +32,21 @@ lazy val scalaFXExtras = (project in file("scalafx-extras")).settings(
3132
scalaFXExtrasSettings,
3233
name := "scalafx-extras",
3334
description := "The ScalaFX Extras",
34-
fork in run := true,
3535
scalacOptions in(Compile, doc) ++= Seq(
3636
"-sourcepath", baseDirectory.value.toString,
3737
"-doc-root-content", baseDirectory.value + "/src/main/scala/root-doc.creole",
3838
"-doc-source-url", "https://github.com/SscalaFX-Extras/scalafx-extras/blob/" + versionTagDir + "/scalafx/€{FILE_PATH}.scala"
3939
) ++ (Option(System.getenv("GRAPHVIZ_DOT_PATH")) match {
4040
case Some(path) => Seq("-diagrams", "-diagrams-dot-path", path)
4141
case None => Seq.empty[String]
42-
}) ++ (if(scalaVersion.value.startsWith("2.11")) Seq("-Xexperimental") else Seq.empty[String])
42+
}) ++ (if (_scalaVersion.startsWith("2.11")) Seq("-Xexperimental") else Seq.empty[String])
4343
)
4444

4545
// ScalaFX Extras Demos project
4646
lazy val scalaFXExtrasDemos = (project in file("scalafx-extras-demos")).settings(
4747
scalaFXExtrasSettings,
4848
name := "scalafx-extras-demos",
4949
description := "The ScalaFX Extras demonstrations",
50-
fork in run := true,
5150
javaOptions ++= Seq(
5251
"-Xmx512M",
5352
"-Djavafx.verbose"
@@ -69,16 +68,17 @@ resolvers += Resolver.sonatypeRepo("snapshots")
6968
lazy val scalaFXExtrasSettings = Seq(
7069
organization := "org.scalafx",
7170
version := projectVersion,
72-
crossScalaVersions := scalaVersions,
73-
scalaVersion := crossScalaVersions { versions => versions.head }.value,
71+
crossScalaVersions := _scalaVersions,
72+
scalaVersion := _scalaVersion,
7473
scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8", "-feature"),
74+
scalacOptions in(Compile, doc) ++= (if (_scalaVersion.startsWith("2.11")) Seq("-Xexperimental") else Seq.empty[String]),
7575
scalacOptions in(Compile, doc) ++= Opts.doc.title("ScalaFX Extras API"),
7676
scalacOptions in(Compile, doc) ++= Opts.doc.version(projectVersion),
7777
scalacOptions in(Compile, doc) += s"-doc-external-doc:${scalaInstance.value.libraryJar}#http://www.scala-lang.org/api/${scalaVersion.value}/",
7878
scalacOptions in(Compile, doc) ++= Seq("-doc-footer", s"ScalaFX Extras API v.$projectVersion"),
7979
javacOptions ++= Seq(
80-
"-target", "1.8",
81-
"-source", "1.8",
80+
// "-target", "1.8",
81+
// "-source", "1.8",
8282
"-Xlint:deprecation"),
8383
libraryDependencies ++= Seq(
8484
"com.beachape" %% "enumeratum" % "1.5.13",
@@ -90,6 +90,7 @@ lazy val scalaFXExtrasSettings = Seq(
9090
autoAPIMappings := true,
9191
manifestSetting,
9292
publishSetting,
93+
fork in run := true,
9394
fork in Test := true,
9495
parallelExecution in Test := false,
9596
resolvers += Resolver.sonatypeRepo("snapshots"),

scalafx-extras-demos/src/main/scala/org/scalafx/extras/BusyWorkerDemo.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ object BusyWorkerDemo extends JFXApp {
8686
maxWidth = Double.MaxValue
8787
},
8888
new Button("Task with simple progress indicator") {
89-
onAction = () => busyWorker.doTask("Task 2") {
89+
onAction = () => busyWorker.doTask("Task 2") { () =>
9090
println("Task 2")
9191
Thread.sleep(3000)
9292
}
9393
maxWidth = Double.MaxValue
9494
},
9595
new Button("Task failing with exception (on 7)") {
96-
onAction = () => busyWorker.doTask("Task 1")(
96+
onAction = () => busyWorker.doTask("Task 3")(
9797
new SimpleTask[String] {
9898
override def call(): String = {
9999
val maxItems = 10
@@ -120,6 +120,15 @@ object BusyWorkerDemo extends JFXApp {
120120
}
121121
)
122122
maxWidth = Double.MaxValue
123+
},
124+
new Button("Print execution thread") {
125+
onAction = () => busyWorker.doTask("Task 4") { () =>
126+
println("1: Thread '" + Thread.currentThread().getName + "'")
127+
println("2: Thread '" + Thread.currentThread().getName + "'")
128+
println("3: Thread '" + Thread.currentThread().getName + "'")
129+
println("4: Thread '" + Thread.currentThread().getName + "'")
130+
}
131+
maxWidth = Double.MaxValue
123132
}
124133
).map(_.delegate)
125134
}

scalafx-extras/src/main/scala/org/scalafx/extras/BusyWorker.scala

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ import scala.runtime.NonLocalReturnControl
4343

4444
object BusyWorker {
4545

46-
//noinspection ConvertExpressionToSAM
47-
implicit def apply[R](op: => R): SimpleTask[R] = new SimpleTask[R] {
48-
def call(): R = op
49-
}
50-
5146
implicit def apply(nodes: Seq[Node]): Seq[jfxs.Node] = nodes.map(_.delegate)
5247

5348
/**
@@ -252,7 +247,7 @@ class BusyWorker private(val title: String,
252247
*
253248
* Example of running a task without waiting to complete, using a lambda
254249
* {{{
255-
* worker.doTask{
250+
* worker.doTask{ () =>
256251
* // Some workload code, does not produce value ot it is discard
257252
* Thread.sleep(1000)
258253
* print(1 + 1)
@@ -262,7 +257,7 @@ class BusyWorker private(val title: String,
262257
* Example of stating a task (with a lambda) and waiting till it finishes and returns a result
263258
* {{{
264259
* // This code will return before workload is completed
265-
* val future = worker.doTask{
260+
* val future = worker.doTask{ () =>
266261
* // Some workload code producing final value
267262
* Thread.sleep(1000)
268263
* 1 + 1
@@ -294,7 +289,7 @@ class BusyWorker private(val title: String,
294289
* @param task actions to perform, can be provided a as a lambda op: => R, see examples above.
295290
* @return `Future` that can be used to retrieve result produced the workload, if any.
296291
*/
297-
def doTask[R](implicit task: SimpleTask[R]): Future[R] = {
292+
def doTask[R](task: SimpleTask[R]): Future[R] = {
298293
doTask(title)(task)
299294
}
300295

@@ -305,7 +300,7 @@ class BusyWorker private(val title: String,
305300
*
306301
* Example of running a task without waiting to complete, using a lambda
307302
* {{{
308-
* worker.doTask("My Task") {
303+
* worker.doTask("My Task") { () =>
309304
* // Some workload code, does not produce value ot it is discard
310305
* Thread.sleep(1000)
311306
* print(1 + 1)
@@ -315,7 +310,7 @@ class BusyWorker private(val title: String,
315310
* Example of stating a task (with a lambda) and waiting till it finishes and returns a result
316311
* {{{
317312
* // This code will return before workload is completed
318-
* val future = worker.doTask("My Task") {
313+
* val future = worker.doTask("My Task") { () =>
319314
* // Some workload code producing final value
320315
* Thread.sleep(1000)
321316
* 1 + 1
@@ -348,7 +343,7 @@ class BusyWorker private(val title: String,
348343
* @param task actions to perform, can be provided a as a lambda op: => R, see examples above.
349344
* @return `Future` that can be used to retrieve result produced the workload, if any.
350345
*/
351-
def doTask[R](name: String)(implicit task: SimpleTask[R]): Future[R] = {
346+
def doTask[R](name: String)(task: SimpleTask[R]): Future[R] = {
352347
val jfxTask = new javafx.concurrent.Task[R] {
353348
override def call(): R = {
354349
task.call()

0 commit comments

Comments
 (0)