Browse Source

Merge pull request #95 in DESIGN/design from ~VITO/c-design:feature/10.0 to feature/10.0

* commit 'd1bac490e2cbc8738fc432ac402c1f3c0ad932ae':
  REPORT-8393 监听放后
master
superman 6 years ago
parent
commit
897b2cfe54
  1. 15
      designer-realize/src/com/fr/start/SplashContext.java
  2. 19
      designer-realize/src/com/fr/start/fx/SplashFx.java
  3. 25
      designer-realize/src/com/fr/start/fx/SplashFxWindow.java

15
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<String> 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<String>() {
@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) {

19
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);
}
}

25
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);
}
}
});
}
}

Loading…
Cancel
Save