Skip to content

Commit 655c0be

Browse files
committed
We don't need Rx.INSTANCE any more.
1 parent 5caaf6e commit 655c0be

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

durian-swt/src/main/java/com/diffplug/common/swt/SwtRx.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2022 DiffPlug
2+
* Copyright (C) 2020-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
1515
*/
1616
package com.diffplug.common.swt;
1717

18-
1918
import com.diffplug.common.base.Preconditions;
2019
import com.diffplug.common.collect.ImmutableList;
2120
import com.diffplug.common.primitives.Ints;
@@ -51,30 +50,30 @@ public class SwtRx {
5150

5251
/** Subscribes to the given widget and pipes the events to an {@link Flow}<{@link Event}>. */
5352
public static @SwtThread Flow<Event> addListener(Widget widget, Stream<Integer> events) {
54-
MutableSharedFlow<Event> observable = Rx.INSTANCE.createEmitFlow();
53+
MutableSharedFlow<Event> observable = Rx.createEmitFlow();
5554
events.forEach(event -> widget.addListener(event, e -> {
56-
Rx.INSTANCE.emit(observable, e);
55+
Rx.emit(observable, e);
5756
}));
5857
return observable;
5958
}
6059

6160
/** Returns an {@link Flow}<{@link Point}> of the right-click mouse-up on the given control, in global coordinates. */
6261
public static @SwtThread Flow<Point> rightClickGlobal(Control ctl) {
63-
MutableSharedFlow<Point> observable = Rx.INSTANCE.createEmitFlow();
62+
MutableSharedFlow<Point> observable = Rx.createEmitFlow();
6463
ctl.addListener(MouseClick.RIGHT_CLICK_EVENT, e -> {
6564
if (e.button == MouseClick.RIGHT.code()) {
66-
Rx.INSTANCE.emit(observable, ctl.toDisplay(e.x, e.y));
65+
Rx.emit(observable, ctl.toDisplay(e.x, e.y));
6766
}
6867
});
6968
return observable;
7069
}
7170

7271
/** Returns an {@link Flow}<{@link Point}> of the right-click mouse-up on the given control, in local coordinates. */
7372
public static @SwtThread Flow<Point> rightClickLocal(Control ctl) {
74-
MutableSharedFlow<Point> observable = Rx.INSTANCE.createEmitFlow();
73+
MutableSharedFlow<Point> observable = Rx.createEmitFlow();
7574
ctl.addListener(MouseClick.RIGHT_CLICK_EVENT, e -> {
7675
if (e.button == MouseClick.RIGHT.code()) {
77-
Rx.INSTANCE.emit(observable, new Point(e.x, e.y));
76+
Rx.emit(observable, new Point(e.x, e.y));
7877
}
7978
});
8079
return observable;

durian-swt/src/main/java/com/diffplug/common/swt/widgets/NoBorderBtn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class NoBorderBtn extends ControlWrapper.AroundControl<Canvas> {
3838
private Image img = null;
3939
private Rectangle imgBounds;
4040
private boolean enabled = true;
41-
private MutableSharedFlow<NoBorderBtn> selection = Rx.INSTANCE.createEmitFlow();
41+
private MutableSharedFlow<NoBorderBtn> selection = Rx.createEmitFlow();
4242

4343
public NoBorderBtn(Composite parent) {
4444
super(new Canvas(parent, SWT.NONE));

durian-swt/src/test/java/com/diffplug/common/swt/ShellsTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 DiffPlug
2+
* Copyright (C) 2020-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
1515
*/
1616
package com.diffplug.common.swt;
1717

18-
1918
import java.util.function.Consumer;
2019
import org.eclipse.swt.SWT;
2120
import org.eclipse.swt.graphics.Point;
@@ -27,7 +26,7 @@
2726

2827
@Category(InteractiveTest.class)
2928
public class ShellsTest {
30-
private static final int UNIT = SwtMisc.systemFontWidth() * 20;
29+
private static final int UNIT = SwtMisc.systemFontWidthTimes(20);
3130

3231
@Test
3332
public void testPack() {

durian-swt/src/test/java/com/diffplug/common/swt/SwtExecProfile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void addSwtExec(String name, SwtExec underTest) {
131131
public void run(Widget guard) {
132132
JuxtaProfiler profiler = new JuxtaProfiler();
133133
profiler.addTestNanoWrap2Sec("control", () -> {
134-
MutableSharedFlow<Integer> subject = Rx.INSTANCE.createEmitFlow();
134+
MutableSharedFlow<Integer> subject = Rx.createEmitFlow();
135135
drain(subject);
136136
});
137137
toProfile.forEach((name, underTest) -> {
@@ -141,7 +141,7 @@ public void run(Widget guard) {
141141

142142
@Override
143143
protected void init() throws Throwable {
144-
subject = Rx.INSTANCE.createEmitFlow();
144+
subject = Rx.createEmitFlow();
145145
sub = underTest.guardOn(guard).subscribeDisposable(subject, val -> {});
146146
}
147147

durian-swt/src/test/java/com/diffplug/common/swt/jface/ViewerMiscTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 DiffPlug
2+
* Copyright (C) 2020-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
1515
*/
1616
package com.diffplug.common.swt.jface;
1717

18-
1918
import com.diffplug.common.base.Errors;
2019
import com.diffplug.common.base.StringPrinter;
2120
import com.diffplug.common.collect.ImmutableList;
@@ -175,7 +174,7 @@ public void testLazyContentProviderFile() {
175174
.setLabelProviderText(File::getName);
176175
format.addColumn().setText("Last Modified")
177176
.setLabelProviderText(file -> new Date(file.lastModified()).toString())
178-
.setLayoutPixel(SwtMisc.systemFontWidth() * new Date().toString().length());
177+
.setLayoutPixel(SwtMisc.systemFontWidthTimes(new Date().toString()));
179178

180179
// create the tree viewer
181180
TreeViewer viewer = format.buildTree(cmp);
@@ -203,7 +202,7 @@ public void testLazyContentProviderPath() {
203202
.setLabelProviderText(path -> path.getFileName().toString());
204203
format.addColumn().setText("Last Modified")
205204
.setLabelProviderText(path -> Errors.suppress().getWithDefault(() -> Files.getLastModifiedTime(path).toString(), ""))
206-
.setLayoutPixel(SwtMisc.systemFontWidth() * new Date().toString().length());
205+
.setLayoutPixel(SwtMisc.systemFontWidthTimes(new Date().toString()));
207206

208207
// create the tree viewer
209208
TreeViewer viewer = format.buildTree(cmp);

0 commit comments

Comments
 (0)