Browse Source

REPORT-8393 监听放后

master
vito 7 years ago
parent
commit
d1bac490e2
  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 static final String GUEST = getRandomUser();
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private Listener<String> listener; private Listener<String> listener;
@ -43,7 +43,7 @@ public class SplashContext {
} }
private SplashContext() { private SplashContext() {
} }
/** /**
@ -57,18 +57,18 @@ public class SplashContext {
* 展示启动动画 * 展示启动动画
*/ */
public void show() { public void show() {
splashStrategy.show();
//监听 //监听
initListener(); initListener();
splashStrategy.show();
} }
/** /**
* 隐藏启动动画 * 隐藏启动动画
*/ */
public void hide() { public void hide() {
splashStrategy.hide();
//取消监听 //取消监听
EventDispatcher.stopListen(listener); EventDispatcher.stopListen(listener);
splashStrategy.hide();
// 窗口关闭后取消定时获取模块信息的timer // 窗口关闭后取消定时获取模块信息的timer
scheduler.shutdown(); scheduler.shutdown();
// 一次性 // 一次性
@ -83,19 +83,18 @@ public class SplashContext {
updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]);
} }
}, 0, 300, TimeUnit.MILLISECONDS); }, 0, 300, TimeUnit.MILLISECONDS);
listener = new Listener<String>() { listener = new Listener<String>() {
@Override @Override
public void on(Event event, String i18n) { public void on(Event event, String i18n) {
showThanks();
moduleID = i18n; moduleID = i18n;
loadingIndex++; loadingIndex++;
updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]);
} }
}; };
EventDispatcher.listen(ModuleEvent.MajorModuleStarting, listener); EventDispatcher.listen(ModuleEvent.MajorModuleStarting, listener);
showThanks();
} }
private void updateModuleLog(String text) { 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 { public class SplashFx implements SplashStrategy {
private SplashFxWindow test; private SplashFxWindow fxWindow;
private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(); private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor();
@Override @Override
@ -29,7 +29,7 @@ public class SplashFx implements SplashStrategy {
Application.launch(SplashFxWindow.class); Application.launch(SplashFxWindow.class);
} }
}); });
test = SplashFxWindow.waitForStartUpTest(); fxWindow = SplashFxWindow.waitForStartUpTest();
} }
@Override @Override
@ -39,22 +39,11 @@ public class SplashFx implements SplashStrategy {
@Override @Override
public void updateModuleLog(final String text) { public void updateModuleLog(final String text) {
Platform.runLater(new Runnable() { fxWindow.updateModuleInfo(text);
@Override
public void run() {
test.updateModuleInfo(text);
}
});
} }
@Override @Override
public void updateThanksLog(final String text) { public void updateThanksLog(final String text) {
Platform.runLater(new Runnable() { fxWindow.updateThanks(text);
@Override
public void run() {
test.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.base.FRContext;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
@ -119,8 +120,16 @@ public class SplashFxWindow extends Application {
* *
* @param s 文字 * @param s 文字
*/ */
public void updateModuleInfo(String s) { public void updateModuleInfo(final String s) {
moduleInfo.setText(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 文字 * @param s 文字
*/ */
public void updateThanks(String s) { public void updateThanks(final String s) {
thanks.setText(s); Platform.runLater(new Runnable() {
@Override
public void run() {
if (thanks != null) {
thanks.setText(s);
}
}
});
} }
} }

Loading…
Cancel
Save