Browse Source

Pull request #9504: REPORT-75786 11.0feature版本设计器无法启动

Merge in DESIGN/design from ~HARRISON/design:feature/x to feature/x

* commit '6926245b3f92b8359f179487e1c362ef5d57179d':
  REPORT-75786 11.0feature版本设计器无法启动 DesignUtils.initLookAndFeel 需要先解密。 会用到 GeneralUtils 的逻辑
feature/x
Harrison 2 years ago
parent
commit
97b89b31a3
  1. 24
      designer-base/src/main/java/com/fr/base/function/UITerminator.java
  2. 40
      designer-realize/src/main/java/com/fr/start/MainDesigner.java
  3. 11
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

24
designer-base/src/main/java/com/fr/base/function/UITerminator.java

@ -0,0 +1,24 @@
package com.fr.base.function;
import com.fr.design.utils.DesignUtils;
import com.fr.runtime.FineRuntime;
/**
* UI 终止动作
*
* created by Harrison on 2022/07/14
**/
public abstract class UITerminator {
public void run() {
// 先执行必须的逻辑
FineRuntime.start();
DesignUtils.initLookAndFeel();
// 在执行核心逻辑
doRun();
}
protected abstract void doRun();
}

40
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -1,6 +1,7 @@
package com.fr.start;
import com.fr.base.function.UITerminator;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.file.WebPreviewUtils;
@ -65,9 +66,9 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.lifecycle.FineLifecycleFatalError;
import com.fr.stable.xml.XMLTools;
import com.fr.start.common.DesignerStartupContext;
import com.fr.start.common.SplashCommon;
import com.fr.start.module.StartupArgs;
import com.fr.start.common.DesignerStartupContext;
import com.fr.start.preload.PreLoadService;
import com.fr.start.server.ServerTray;
import com.fr.third.org.apache.commons.lang3.time.StopWatch;
@ -88,8 +89,6 @@ import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
@ -123,7 +122,7 @@ public class MainDesigner extends BaseDesigner {
DesignerStartupContext.getRecorder().start();
startPreload();
startPreload0();
DeepLinkManager.getInstance().start(args);
StopWatch watch = new StopWatch();
@ -131,6 +130,9 @@ public class MainDesigner extends BaseDesigner {
DesignerLifecycleMonitorContext.getMonitor().beforeStart();
//启动运行时
FineRuntime.start();
startPreload1();
DesignerSubListener.getInstance().start();
EventDispatcher.listen(LifecycleErrorEvent.SELF, new Listener<FineLifecycleFatalError>() {
@Override
@ -157,13 +159,31 @@ public class MainDesigner extends BaseDesigner {
watch.stop();
}
private static void startPreload() {
/**
* {@link FineRuntime#start()} 运行后
*/
private static void startPreload1() {
CompletableFuture<Void> initLookAndFeel = CompletableFuture.runAsync(DesignUtils::initLookAndFeel);
PreLoadService.getInstance().addFuture(initLookAndFeel);
}
/**
* {@link FineRuntime#start()} 运行前
*/
private static void startPreload0() {
PreLoadService.getInstance().addRunnable(() -> {
if (DesignUtils.isPortOccupied()) {
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.PORT_OCCUPIED.getId(),
DesignerErrorMessage.PORT_OCCUPIED.getMessage());
DesignerPort.getInstance().resetPort();
UITerminator action = new UITerminator() {
@Override
protected void doRun() {
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.PORT_OCCUPIED.getId(),
DesignerErrorMessage.PORT_OCCUPIED.getMessage());
DesignerPort.getInstance().resetPort();
}
};
action.run();
}
});
@ -171,13 +191,13 @@ public class MainDesigner extends BaseDesigner {
Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
};
PreLoadService.getInstance().addRunnable(fontLoad);
CompletableFuture<Void> splashFuture = CompletableFuture.runAsync(() -> {
DesignerEnvManager.getEnvManager(false);
})
.thenRunAsync(DesignUtils::initLookAndFeel)
.thenRun(MainDesigner::showSplash);
PreLoadService.getInstance().addFuture(splashFuture);
}
private static void showSplash() {

11
designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

@ -32,9 +32,9 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.start.DesignerProcessType;
import com.fr.start.preload.PreLoadService;
import com.fr.start.ServerStarter;
import com.fr.start.event.LazyStartupEvent;
import com.fr.start.preload.PreLoadService;
import com.fr.start.server.FineEmbedServer;
import com.fr.third.guava.base.Stopwatch;
import com.fr.value.NotNullLazyValue;
@ -61,6 +61,10 @@ public class DesignerStartup extends Activator {
@Override
public void beforeAllStart() {
BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
registerDaoSelector();
Stopwatch beforeWatch = Stopwatch.createStarted();
PreLoadService.getInstance().waitForAll();
FineLoggerFactory.getLogger().debug( "DesignerStartup cost {} ms to wait load", beforeWatch.elapsed(TimeUnit.MILLISECONDS));
@ -97,13 +101,8 @@ public class DesignerStartup extends Activator {
FineLoggerFactory.getLogger().error(DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getId() + ": " + DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getMessage());
}
DesignerExiter.getInstance().execute();
return;
}
BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
registerDaoSelector();
}
@Override

Loading…
Cancel
Save