diff --git a/pom.xml b/pom.xml
index ce7a5b2..61ef960 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,7 +117,7 @@
scm:git:git://github.com/saalfeldlab/saalfx
scm:git:git@github.com:saalfeldlab/saalfx.git
- saalfx-1.3.0
+ saalfx-2.0.0
https://github.com/saalfeldlab/saalfx
diff --git a/src/main/kotlin/org/janelia/saalfeldlab/fx/actions/Action.kt b/src/main/kotlin/org/janelia/saalfeldlab/fx/actions/Action.kt
index 73ac209..7b9d929 100644
--- a/src/main/kotlin/org/janelia/saalfeldlab/fx/actions/Action.kt
+++ b/src/main/kotlin/org/janelia/saalfeldlab/fx/actions/Action.kt
@@ -196,9 +196,8 @@ open class Action(val eventType: EventType) {
for ((description, check) in checks) {
valid = valid && check(event)
if (!valid) {
- val msg = description?.let {
- "$it (${check::class.java})"
- } ?: "(${check::class.java})"
+ val startMsg = description?.let { "$it " } ?: ""
+ val msg ="$startMsg(${check::class.java})"
logger.trace { "Check: $msg did not pass" }
break
}
diff --git a/src/main/kotlin/org/janelia/saalfeldlab/fx/actions/ActionSet.kt b/src/main/kotlin/org/janelia/saalfeldlab/fx/actions/ActionSet.kt
index 1e713ed..bd25818 100644
--- a/src/main/kotlin/org/janelia/saalfeldlab/fx/actions/ActionSet.kt
+++ b/src/main/kotlin/org/janelia/saalfeldlab/fx/actions/ActionSet.kt
@@ -64,21 +64,19 @@ open class ActionSet(val name: String, var keyTracker: () -> KeyTracker? = { nul
apply?.let { it(this) }
}
- private fun testChecksForEventType(event: Event, eventType: EventType = event.eventType): Boolean {
- return checks[eventType]?.let { checks ->
- var pass = true
- for ((reason, check) in checks) {
- if (!check(event)) {
- ACTION_SET_LOGGER.debug { "Verify All Failed: $reason" }
- pass = false
- break
- }
+ private fun Action.testChecksForEventType(event: Event, eventType: EventType = event.eventType): Boolean {
+ val checks = checks[eventType] ?: return true
+
+ for ((reason, check) in checks) {
+ if (!check(event)) {
+ logger.debug { "Verify All Failed: $reason" }
+ return false
}
- pass
- } ?: true
+ }
+ return true
}
- private tailrec fun testChecksForInheritedEventTypes(event: Event, eventType: EventType? = event.eventType): Boolean {
+ private tailrec fun Action.testChecksForInheritedEventTypes(event: Event, eventType: EventType? = event.eventType): Boolean {
if (eventType == null) return true
return if (!testChecksForEventType(event, eventType)) false else testChecksForInheritedEventTypes(event, eventType.superType)
}
@@ -391,9 +389,7 @@ open class ActionSet(val name: String, var keyTracker: () -> KeyTracker? = { nul
try {
action(event)
} catch (e: Exception) {
- val logger = if (action.filter) FILTER_LOGGER else ACTION_LOGGER
- val nameText = action.name?.let { "$name: $it" } ?: name
- logger.error(e) { "$nameText (${event.eventType} was valid, but failed" }
+ action.logger.error(e) {"${event.eventType} was valid, but failed" }
throw e
}
} else {
@@ -410,7 +406,9 @@ open class ActionSet(val name: String, var keyTracker: () -> KeyTracker? = { nul
* @param action the [Action] to handle [event]
* @param event to handle
*/
- protected open fun preInvokeCheck(action: Action, event: E) = action.canHandleEvent(event.eventType) && testChecksForInheritedEventTypes(event)
+ protected open fun preInvokeCheck(action: Action, event: E) = action.run {
+ canHandleEvent(event.eventType) && testChecksForInheritedEventTypes(event)
+ }
/**
* Optional callback for before the extension functions [installActionSet] are called.
@@ -441,10 +439,6 @@ open class ActionSet(val name: String, var keyTracker: () -> KeyTracker? = { nul
companion object {
- private val ACTION_SET_LOGGER: KLogger = KotlinLogging.logger {}
- private val ACTION_LOGGER: KLogger = KotlinLogging.logger("${MethodHandles.lookup().lookupClass().name}-Action")
- private val FILTER_LOGGER: KLogger = KotlinLogging.logger("${MethodHandles.lookup().lookupClass().name}-Filter")
-
/**
* Install [actionSet] in the receiver [Node]
*
diff --git a/src/main/kotlin/org/janelia/saalfeldlab/fx/util/InvokeOnJavaFXApplicationThread.kt b/src/main/kotlin/org/janelia/saalfeldlab/fx/util/InvokeOnJavaFXApplicationThread.kt
index 8eb93fe..e72d3b7 100644
--- a/src/main/kotlin/org/janelia/saalfeldlab/fx/util/InvokeOnJavaFXApplicationThread.kt
+++ b/src/main/kotlin/org/janelia/saalfeldlab/fx/util/InvokeOnJavaFXApplicationThread.kt
@@ -28,7 +28,6 @@
*/
package org.janelia.saalfeldlab.fx.util
-import javafx.application.Platform
import kotlinx.coroutines.*
import java.lang.Runnable
@@ -42,10 +41,7 @@ class InvokeOnJavaFXApplicationThread {
operator fun invoke(task: suspend CoroutineScope.() -> Unit) = sharedMainScope.launch(block = task)
@JvmStatic
- operator fun invoke(task: Runnable) {
- if (Platform.isFxApplicationThread()) task.run()
- else invoke { task.run() }
- }
+ operator fun invoke(task: Runnable) = invoke { task.run() }
@Throws(InterruptedException::class)
fun invokeAndWait(task: suspend CoroutineScope.() -> Unit) = runBlocking {