1
1
/*
2
- * Copyright 2020 DiffPlug
2
+ * Copyright (C) 2020-2025 DiffPlug
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
15
15
*/
16
16
package com .diffplug .common .swt .widgets ;
17
17
18
-
18
+ import com . diffplug . common . rx . Rx ;
19
19
import com .diffplug .common .swt .ControlWrapper ;
20
- import io . reactivex . Observable ;
21
- import io . reactivex . subjects . PublishSubject ;
20
+ import kotlinx . coroutines . flow . Flow ;
21
+ import kotlinx . coroutines . flow . MutableSharedFlow ;
22
22
import org .eclipse .swt .SWT ;
23
23
import org .eclipse .swt .graphics .Color ;
24
24
import org .eclipse .swt .graphics .Image ;
@@ -38,7 +38,7 @@ public class NoBorderBtn extends ControlWrapper.AroundControl<Canvas> {
38
38
private Image img = null ;
39
39
private Rectangle imgBounds ;
40
40
private boolean enabled = true ;
41
- private PublishSubject <NoBorderBtn > selection = PublishSubject . create ();
41
+ private MutableSharedFlow <NoBorderBtn > selection = Rx . INSTANCE . createEmitFlow ();
42
42
43
43
public NoBorderBtn (Composite parent ) {
44
44
super (new Canvas (parent , SWT .NONE ));
@@ -61,17 +61,13 @@ public NoBorderBtn(Composite parent) {
61
61
// send a selection event on each click (if we aren't disabled)
62
62
wrapped .addListener (SWT .MouseDown , e -> {
63
63
if (enabled ) {
64
- selection . onNext ( this );
64
+ Rx . emit ( selection , this );
65
65
}
66
66
});
67
- // send a "completed" event when we finish
68
- wrapped .addListener (SWT .Dispose , e -> {
69
- selection .onComplete ();
70
- });
71
67
}
72
68
73
69
/** Returns an Observable which responds to clicks. */
74
- public Observable <NoBorderBtn > clicked () {
70
+ public Flow <NoBorderBtn > clicked () {
75
71
return selection ;
76
72
}
77
73
0 commit comments