From d1bac490e2cbc8738fc432ac402c1f3c0ad932ae Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 7 Jun 2018 10:05:21 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-8393=20=E7=9B=91=E5=90=AC=E6=94=BE?= =?UTF-8?q?=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/start/SplashContext.java | 15 ++++++----- .../src/com/fr/start/fx/SplashFx.java | 19 +++----------- .../src/com/fr/start/fx/SplashFxWindow.java | 25 ++++++++++++++++--- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/designer-realize/src/com/fr/start/SplashContext.java b/designer-realize/src/com/fr/start/SplashContext.java index e5021b2b3..9ba4a72b1 100644 --- a/designer-realize/src/com/fr/start/SplashContext.java +++ b/designer-realize/src/com/fr/start/SplashContext.java @@ -34,7 +34,7 @@ public class SplashContext { private static final String GUEST = getRandomUser(); private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - + private Listener listener; @@ -43,7 +43,7 @@ public class SplashContext { } private SplashContext() { - + } /** @@ -57,18 +57,18 @@ public class SplashContext { * 展示启动动画 */ public void show() { + splashStrategy.show(); //监听 initListener(); - splashStrategy.show(); } /** * 隐藏启动动画 */ public void hide() { + splashStrategy.hide(); //取消监听 EventDispatcher.stopListen(listener); - splashStrategy.hide(); // 窗口关闭后取消定时获取模块信息的timer scheduler.shutdown(); // 一次性 @@ -83,19 +83,18 @@ public class SplashContext { updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); } }, 0, 300, TimeUnit.MILLISECONDS); - + listener = new Listener() { - + @Override public void on(Event event, String i18n) { - + showThanks(); moduleID = i18n; loadingIndex++; updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); } }; EventDispatcher.listen(ModuleEvent.MajorModuleStarting, listener); - showThanks(); } private void updateModuleLog(String text) { diff --git a/designer-realize/src/com/fr/start/fx/SplashFx.java b/designer-realize/src/com/fr/start/fx/SplashFx.java index b69de8946..7970e204f 100644 --- a/designer-realize/src/com/fr/start/fx/SplashFx.java +++ b/designer-realize/src/com/fr/start/fx/SplashFx.java @@ -18,7 +18,7 @@ import java.util.concurrent.Executors; */ public class SplashFx implements SplashStrategy { - private SplashFxWindow test; + private SplashFxWindow fxWindow; private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(); @Override @@ -29,7 +29,7 @@ public class SplashFx implements SplashStrategy { Application.launch(SplashFxWindow.class); } }); - test = SplashFxWindow.waitForStartUpTest(); + fxWindow = SplashFxWindow.waitForStartUpTest(); } @Override @@ -39,22 +39,11 @@ public class SplashFx implements SplashStrategy { @Override public void updateModuleLog(final String text) { - Platform.runLater(new Runnable() { - @Override - public void run() { - test.updateModuleInfo(text); - } - }); - + fxWindow.updateModuleInfo(text); } @Override public void updateThanksLog(final String text) { - Platform.runLater(new Runnable() { - @Override - public void run() { - test.updateThanks(text); - } - }); + fxWindow.updateThanks(text); } } diff --git a/designer-realize/src/com/fr/start/fx/SplashFxWindow.java b/designer-realize/src/com/fr/start/fx/SplashFxWindow.java index f048cebd5..486ba69b6 100644 --- a/designer-realize/src/com/fr/start/fx/SplashFxWindow.java +++ b/designer-realize/src/com/fr/start/fx/SplashFxWindow.java @@ -4,6 +4,7 @@ import com.bulenkov.iconloader.util.JBUI; import com.fr.base.FRContext; import com.fr.stable.OperatingSystem; import javafx.application.Application; +import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; @@ -119,8 +120,16 @@ public class SplashFxWindow extends Application { * * @param s 文字 */ - public void updateModuleInfo(String s) { - moduleInfo.setText(s); + public void updateModuleInfo(final String s) { + Platform.runLater(new Runnable() { + @Override + public void run() { + if (moduleInfo != null) { + moduleInfo.setText(s); + } + } + }); + } /** @@ -128,7 +137,15 @@ public class SplashFxWindow extends Application { * * @param s 文字 */ - public void updateThanks(String s) { - thanks.setText(s); + public void updateThanks(final String s) { + Platform.runLater(new Runnable() { + @Override + public void run() { + if (thanks != null) { + thanks.setText(s); + } + } + }); + } }