|
|
|
package com.fr.start;
|
|
|
|
|
|
|
|
import com.fr.design.constants.DesignerLaunchStatus;
|
|
|
|
import com.fr.design.fun.DesignerStartClassProcessor;
|
|
|
|
import com.fr.design.mainframe.DesignerContext;
|
|
|
|
import com.fr.design.ui.util.UIUtil;
|
|
|
|
import com.fr.event.Event;
|
|
|
|
import com.fr.event.EventDispatcher;
|
|
|
|
import com.fr.event.Listener;
|
|
|
|
import com.fr.event.Null;
|
|
|
|
import com.fr.invoke.Reflect;
|
|
|
|
import com.fr.stable.bridge.StableFactory;
|
|
|
|
import com.fr.task.Once;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by juhaoyu on 2019-06-14.
|
|
|
|
* 设计器上下文
|
|
|
|
*/
|
|
|
|
public class DesignerInitial {
|
|
|
|
|
|
|
|
private static volatile BaseDesigner designer;
|
|
|
|
|
|
|
|
private static final Once OPEN_LAST_FILE_INIT = new Once(() -> {
|
|
|
|
|
|
|
|
EventDispatcher.listen(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE, new Listener<Null>() {
|
|
|
|
@Override
|
|
|
|
public void on(Event event, Null param) {
|
|
|
|
EventDispatcher.stopListen(this);
|
|
|
|
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
DesignerContext.getDesignerFrame().setVisible(true);
|
|
|
|
DesignerContext.getDesignerFrame().resizeFrame();
|
|
|
|
//启动画面结束
|
|
|
|
SplashContext.getInstance().hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
DesignerLaunchStatus.setStatus(DesignerLaunchStatus.STARTUP_COMPLETE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
public static void init(final String... args) {
|
|
|
|
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
DesignerStartClassProcessor processor = StableFactory.getMarkedInstanceObjectFromClass(DesignerStartClassProcessor.MARK_STRING, DesignerStartClassProcessor.class);
|
|
|
|
if (processor != null) {
|
|
|
|
designer = Reflect.on(processor.transform()).create(args).get();
|
|
|
|
} else {
|
|
|
|
designer = new MainDesigner(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void prepare() {
|
|
|
|
|
|
|
|
DesignerLaunchStatus.setStatus(DesignerLaunchStatus.DESIGNER_INIT_STARTED);
|
|
|
|
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (designer != null) {
|
|
|
|
designer.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
OPEN_LAST_FILE_INIT.run();
|
|
|
|
}
|
|
|
|
}
|