@@ -21,8 +21,7 @@ import com.diffplug.common.swt.os.WS
21
21
import com.diffplug.common.tree.TreeIterable
22
22
import com.diffplug.common.tree.TreeQuery
23
23
import com.diffplug.common.tree.TreeStream
24
- import io.reactivex.disposables.Disposable
25
- import io.reactivex.disposables.Disposables
24
+ import kotlinx.coroutines.Job
26
25
import org.eclipse.swt.SWT
27
26
import org.eclipse.swt.graphics.Image
28
27
import org.eclipse.swt.graphics.Point
@@ -36,7 +35,7 @@ import java.util.*
36
35
37
36
/* * A fluent builder for creating SWT [Shell]s. */
38
37
class Shells private constructor(private val style : Int , private val coat : Coat ) {
39
- private var title: String = " "
38
+ private var title: String? = null
40
39
private var image: Image ? = null
41
40
private var alpha = SWT .DEFAULT
42
41
private val size = Point (SWT .DEFAULT , SWT .DEFAULT )
@@ -434,17 +433,19 @@ class Shells private constructor(private val style: Int, private val coat: Coat)
434
433
435
434
/* * Prevents the given shell from closing without prompting. Returns a Subscription which can cancel this blocking. */
436
435
@JvmStatic
437
- fun confirmClose (shell : Shell , title : String , question : String , runOnClose : Runnable ): Disposable {
436
+ fun confirmClose (shell : Shell , title : String , question : String , runOnClose : Runnable ): Job {
438
437
val listener = Listener { e: Event ->
439
438
e.doit = SwtMisc .blockForQuestion(title, question, shell)
440
439
if (e.doit) {
441
440
runOnClose.run ()
442
441
}
443
442
}
444
443
shell.addListener(SWT .Close , listener)
445
- return Disposables .fromRunnable {
446
- SwtExec .immediate().guardOn(shell).execute {
447
- shell.removeListener(SWT .Close , listener)
444
+ return Job ().apply {
445
+ invokeOnCompletion {
446
+ SwtExec .immediate().guardOn(shell).execute {
447
+ shell.removeListener(SWT .Close , listener)
448
+ }
448
449
}
449
450
}
450
451
}
0 commit comments