Skip to content

Commit e99f705

Browse files
committed
Merge branch 'develop'
# Conflicts: # README.md
2 parents 7d387d9 + 8dbd623 commit e99f705

File tree

27 files changed

+368
-87
lines changed

27 files changed

+368
-87
lines changed

Communication/src/main/java/com/ak/comm/converter/Converter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static <T, R, V extends Enum<V> & Variable<V>> void doConvert(BytesInterceptor<T
3737
final int TRIES = 2;
3838
for (int i = 0; i < TRIES && !isProcessed(bytesInterceptor, responseConverter, path); i++) {
3939
try {
40-
TimeUnit.SECONDS.sleep(UIConstants.UI_DELAY.getSeconds());
40+
TimeUnit.SECONDS.sleep(UIConstants.UI_DELAY_3SEC.getSeconds());
4141
}
4242
catch (InterruptedException _) {
4343
Thread.currentThread().interrupt();

Communication/src/main/java/com/ak/comm/serial/CycleSerialService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void subscribe(Flow.Subscriber<? super int[]> s) {
5050
subscriber.onComplete();
5151
serialService = new SerialService<>(bytesInterceptor());
5252
}
53-
}, 1, UIConstants.UI_DELAY.getSeconds(), TimeUnit.SECONDS);
53+
}, 1, UIConstants.UI_DELAY_3SEC.getSeconds(), TimeUnit.SECONDS);
5454
}
5555

5656
@Override
@@ -141,8 +141,8 @@ public void onComplete() {
141141
private boolean isBreak() {
142142
try {
143143
okTime.set(Instant.now());
144-
while (Duration.between(okTime.get(), Instant.now()).minus(UIConstants.UI_DELAY).isNegative()) {
145-
if (latch.await(UIConstants.UI_DELAY.toMillis(), TimeUnit.MILLISECONDS)) {
144+
while (Duration.between(okTime.get(), Instant.now()).minus(UIConstants.UI_DELAY_3SEC).isNegative()) {
145+
if (latch.await(UIConstants.UI_DELAY_3SEC.toMillis(), TimeUnit.MILLISECONDS)) {
146146
break;
147147
}
148148
}

Communication/src/test/java/com/ak/comm/CycleSerialServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import java.util.concurrent.Flow;
1515
import java.util.concurrent.TimeUnit;
1616

17-
import static com.ak.util.UIConstants.UI_DELAY;
17+
import static com.ak.util.UIConstants.UI_DELAY_3SEC;
1818
import static org.junit.jupiter.api.Assertions.assertFalse;
1919
import static org.junit.jupiter.api.Assertions.fail;
2020

@@ -49,7 +49,7 @@ public void onComplete() {
4949
});
5050
service.write(new BufferFrame(new byte[] {1, 2}, ByteOrder.nativeOrder()));
5151
service.refresh(false);
52-
assertFalse(latch.await(UI_DELAY.getSeconds(), TimeUnit.SECONDS));
52+
assertFalse(latch.await(UI_DELAY_3SEC.getSeconds(), TimeUnit.SECONDS));
5353
service.close();
5454
}
5555
}

Desktop/src/main/java/com/ak/appliance/suntech/fx/desktop/NIBPViewController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@Component
1616
@Profile("suntech")
1717
public final class NIBPViewController extends AbstractNIBPViewController {
18-
private final Executor delayedExecutor = CompletableFuture.delayedExecutor(UIConstants.UI_DELAY.getSeconds(), TimeUnit.SECONDS);
18+
private final Executor delayedExecutor = CompletableFuture.delayedExecutor(UIConstants.UI_DELAY_3SEC.getSeconds(), TimeUnit.SECONDS);
1919
private volatile boolean isStartBPEnable;
2020

2121
public NIBPViewController() {

Desktop/src/main/java/com/ak/fx/FxApplication.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import com.ak.fx.storage.OSStageStorage;
77
import com.ak.fx.storage.SplitPaneStorage;
88
import com.ak.fx.storage.Storage;
9+
import com.ak.fx.util.FxUtils;
910
import com.ak.fx.util.OSDockImage;
1011
import com.ak.util.OS;
1112
import com.ak.util.Strings;
13+
import com.ak.util.UIConstants;
1214
import javafx.application.Application;
1315
import javafx.application.Platform;
1416
import javafx.event.EventTarget;
@@ -30,6 +32,8 @@
3032

3133
import java.io.IOException;
3234
import java.util.*;
35+
import java.util.concurrent.CompletableFuture;
36+
import java.util.concurrent.TimeUnit;
3337
import java.util.stream.Collectors;
3438
import java.util.stream.Stream;
3539

@@ -127,14 +131,14 @@ public final void start(Stage mainStage) throws IOException {
127131

128132
Storage<Stage> stageStorage = OSStageStorage.valueOf(OS.get().name()).newInstance(getClass(), Strings.EMPTY);
129133
stage.setOnCloseRequest(_ -> stageStorage.save(stage));
130-
stage.getScene().addPostLayoutPulseListener(new Runnable() {
131-
@Override
132-
public void run() {
133-
dividerStorage.update(root);
134-
stageStorage.update(stage);
135-
stage.getScene().removePostLayoutPulseListener(this);
136-
}
137-
});
134+
stage.getScene().getWindow().setOnShown(_ ->
135+
CompletableFuture.delayedExecutor(UIConstants.UI_DELAY_750MILLIS.toMillis(), TimeUnit.MILLISECONDS).execute(() ->
136+
FxUtils.invokeInFx(() -> {
137+
dividerStorage.update(root);
138+
stageStorage.update(stage);
139+
})
140+
)
141+
);
138142
stage.show();
139143
}
140144

Desktop/src/main/java/com/ak/fx/scene/GridCell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import com.ak.util.Numbers;
55
import javafx.scene.shape.Path;
66

7+
import java.util.ArrayList;
78
import java.util.Collections;
89
import java.util.EnumSet;
9-
import java.util.LinkedList;
1010
import java.util.List;
1111
import java.util.function.DoubleBinaryOperator;
1212
import java.util.function.ToDoubleFunction;
@@ -124,7 +124,7 @@ private double doCoordinate(DoubleBinaryOperator action, ToDoubleFunction<GridCe
124124
}
125125

126126
static List<Path> newPaths() {
127-
List<Path> paths = new LinkedList<>();
127+
List<Path> paths = new ArrayList<>();
128128
EnumSet.allOf(GridCell.class).forEach(gridCell -> paths.add(gridCell.newPath()));
129129
return Collections.unmodifiableList(paths);
130130
}

Desktop/src/test/java/com/ak/file/RecursiveWatcherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void test(@TempDir Path path) throws IOException, InterruptedException {
2222
assertNotNull(subDir, path::toString);
2323
CountDownLatch latch = new CountDownLatch(2);
2424
try (var _ = new RecursiveWatcher(path, _ -> latch.countDown(), Extension.TXT)) {
25-
while (!latch.await(UIConstants.UI_DELAY.getSeconds(), TimeUnit.SECONDS)) {
25+
while (!latch.await(UIConstants.UI_DELAY_3SEC.getSeconds(), TimeUnit.SECONDS)) {
2626
Files.createTempFile(Files.createTempDirectory(subDir, Strings.EMPTY), Strings.EMPTY, Extension.TXT.attachTo(Strings.EMPTY));
2727
}
2828
}

FxCore/src/main/java/com/ak/fx/stage/ScreenResolutionMonitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public enum ScreenResolutionMonitor {
3030
DPI.setValue(Screen.getPrimary().getDpi());
3131
}
3232
log();
33-
var timer = new Timer((int) UIConstants.UI_DELAY.toMillis(), _ ->
33+
var timer = new Timer((int) UIConstants.UI_DELAY_3SEC.toMillis(), _ ->
3434
Optional.ofNullable(SCENE_REFERENCE.get()).flatMap(scene ->
3535
Optional.ofNullable(scene.getWindow())).ifPresent(window -> {
3636
ObservableList<Screen> screens = Screen.getScreensForRectangle(

FxCore/src/main/java/com/ak/fx/storage/AbstractStageStorage.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.ak.fx.storage;
22

3+
import com.ak.fx.util.FxUtils;
4+
import com.ak.util.UIConstants;
35
import javafx.stage.Screen;
46
import javafx.stage.Stage;
57

68
import java.awt.geom.Rectangle2D;
79
import java.util.Optional;
10+
import java.util.concurrent.CompletableFuture;
11+
import java.util.concurrent.TimeUnit;
812
import java.util.prefs.BackingStoreException;
913

1014
abstract class AbstractStageStorage extends AbstractStorage<Stage> {
@@ -27,7 +31,7 @@ public void save(Stage stage) {
2731

2832
@Override
2933
public void update(Stage stage) {
30-
stage.maximizedProperty().addListener((observable, oldValue, newValue) -> preferences().putBoolean(MAXIMIZED, newValue));
34+
stage.maximizedProperty().addListener((_, _, newValue) -> preferences().putBoolean(MAXIMIZED, newValue));
3135
boundsStorage.get().ifPresentOrElse(
3236
r -> {
3337
if (Screen.getPrimary().getVisualBounds().contains(r.getX(), r.getY(), r.getWidth(), r.getHeight())) {
@@ -44,7 +48,9 @@ public void update(Stage stage) {
4448
}
4549
);
4650
stage.setMaximized(preferences().getBoolean(MAXIMIZED, false));
47-
stage.setFullScreen(preferences().getBoolean(FULL_SCREEN, false));
51+
CompletableFuture.delayedExecutor(UIConstants.UI_DELAY_750MILLIS.toMillis(), TimeUnit.MILLISECONDS).execute(() ->
52+
FxUtils.invokeInFx(() -> stage.setFullScreen(preferences().getBoolean(FULL_SCREEN, false)))
53+
);
4854
}
4955

5056
@Override

FxCore/src/main/java/com/ak/fx/storage/MacStageStorage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.time.Duration;
88
import java.time.Instant;
99

10-
import static com.ak.util.UIConstants.UI_DELAY;
10+
import static com.ak.util.UIConstants.UI_DELAY_3SEC;
1111

1212
final class MacStageStorage extends AbstractStageStorage {
1313
private Instant fullScreenEventInstant = Instant.now();
@@ -18,7 +18,7 @@ final class MacStageStorage extends AbstractStageStorage {
1818

1919
@Override
2020
public void save(Stage stage) {
21-
if (!Duration.between(fullScreenEventInstant, Instant.now()).minus(UI_DELAY).isNegative()) {
21+
if (!Duration.between(fullScreenEventInstant, Instant.now()).minus(UI_DELAY_3SEC).isNegative()) {
2222
saveFullScreenState(stage.isFullScreen());
2323
}
2424
if (stage.isMaximized()) {
@@ -37,7 +37,7 @@ public void save(Stage stage) {
3737

3838
@Override
3939
public void update(Stage stage) {
40-
stage.fullScreenProperty().addListener((observable, oldValue, newValue) -> {
40+
stage.fullScreenProperty().addListener((_, oldValue, _) -> {
4141
fullScreenEventInstant = Instant.now();
4242
saveFullScreenState(oldValue);
4343
stage.setResizable(false);

0 commit comments

Comments
 (0)