diff --git a/app/src/main/java/com/dlsc/jfxcentral2/app/JFXCentral2App.java b/app/src/main/java/com/dlsc/jfxcentral2/app/JFXCentral2App.java index 9e85ffe3..c9c38b6c 100644 --- a/app/src/main/java/com/dlsc/jfxcentral2/app/JFXCentral2App.java +++ b/app/src/main/java/com/dlsc/jfxcentral2/app/JFXCentral2App.java @@ -134,7 +134,7 @@ public void start(Stage stage) { routeNode.start(sessionManager); // tray icon - if (!WebAPI.isBrowser()) { + if (!WebAPI.isBrowser() && SystemTray.isSupported()) { RepositoryManager.repositoryUpdatedProperty().addListener(it -> { if (trayIconManager == null) { trayIconManager = new TrayIconManager(stage, sessionManager); @@ -147,7 +147,9 @@ public void start(Stage stage) { // customs stage for decorations / the chrome CustomStage customStage = new CustomStage(stage, routeNode, sessionManager); customStage.setCloseHandler(() -> { - trayIconManager.hide(); + if (SystemTray.isSupported()) { + trayIconManager.hide(); + } stage.close(); }); @@ -160,6 +162,7 @@ public void start(Stage stage) { updateSizeProperty(scene); stage.setScene(scene); + stage.setFullScreenExitHint(""); // do not store stage width, height, location when we are running in a browser if (!WebAPI.isBrowser()) { diff --git a/app/src/main/java/com/dlsc/jfxcentral2/app/RepositoryManager.java b/app/src/main/java/com/dlsc/jfxcentral2/app/RepositoryManager.java index 4868628b..25b33f15 100644 --- a/app/src/main/java/com/dlsc/jfxcentral2/app/RepositoryManager.java +++ b/app/src/main/java/com/dlsc/jfxcentral2/app/RepositoryManager.java @@ -40,7 +40,7 @@ public static void updateRepository(ProgressMonitor monitor) { if (!isRepositoryUpdated()) { try { initialLoad(monitor); - Platform.runLater(() -> repositoryUpdated.set(true)); + repositoryUpdated.set(true); } catch (Exception e) { LOGGER.error("Failed to update the repository", e); } @@ -54,8 +54,10 @@ public static boolean isFirstTimeSetup() { private static void initialLoad(ProgressMonitor monitor) throws Exception { // Network not available, skip the initial load if (!isNetworkAvailable()) { - monitor.beginTask("Network not available.", 1); - monitor.endTask(); + Platform.runLater(() -> { + monitor.beginTask("Network not available.", 1); + monitor.endTask(); + }); return; } @@ -64,9 +66,11 @@ private static void initialLoad(ProgressMonitor monitor) throws Exception { String repoUrl = GITHUB_REPOSITORY_URL; if (isCountryEqualToChina()) { - monitor.beginTask("Checking network...", 1); repoUrl = shouldUseGiteeMirror() ? GITEE_REPOSITORY_URL : GITHUB_REPOSITORY_URL; - monitor.endTask(); + Platform.runLater(() -> { + monitor.beginTask("Checking network...", 1); + monitor.endTask(); + }); } CloneCommand cloneCmd = Git.cloneRepository() diff --git a/app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java b/app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java index b491ef60..9f4c39e0 100644 --- a/app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java +++ b/app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java @@ -27,6 +27,10 @@ public class RefreshPage extends PageBase { + /** + * The invalidation listener is called from the RepositoryManager thread, + * so any changes done to the UI must be in Platform.runLater. + */ private final InvalidationListener invalidationListener = it -> { if (RepositoryManager.isRepositoryUpdated()) { Platform.runLater(() -> {