Browse Source

Merge pull request #948 in DESIGN/design from ~JU/design:feature/10.0 to feature/10.0

* commit '40d515d864c8e4ce406469e130fd92c9c247003d':
  REPORT-17988 设计器启动速度 bugfix
  REPORT-17988 设计器启动速度 bugfix
  REPORT-17988 设计器启动速度--本机大概从 14.2s -> 10.2 bugfix 后面刷新env的原因是啥?
research/10.0
ju 6 years ago
parent
commit
300fafea36
  1. 2
      designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java
  2. 19
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  3. 7
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  4. 11
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  5. 64
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

2
designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java

@ -9,5 +9,5 @@ public interface DesignerOpenedListener extends EventListener {
/** /**
* Invoked when the target of the listener has changed the rpt content. * Invoked when the target of the listener has changed the rpt content.
*/ */
public void designerOpened(); void designerOpened();
} }

19
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -308,16 +308,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
}); });
this.addDesignerOpenedListener(new DesignerOpenedListener() {
@Override
public void designerOpened() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
});
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setVisible(false); this.setVisible(false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.setExtendedState(JFrame.MAXIMIZED_BOTH);
@ -326,7 +316,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
initMenuPane(); initMenuPane();
this.progressDialog = new ProgressDialog(this); this.progressDialog = new ProgressDialog(this);
} }
public void resizeFrame() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
public void closeAuthorityEditing() { public void closeAuthorityEditing() {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
WestRegionContainerPane.getInstance().replaceDownPane( WestRegionContainerPane.getInstance().replaceDownPane(

7
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -43,8 +43,6 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
} }
private void init() { private void init() {
//初始化
EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Basic_Initializing"));
// 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到
DesignUtils.initLookAndFeel(); DesignUtils.initLookAndFeel();
// 初始化Log Handler // 初始化Log Handler
@ -55,11 +53,14 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
public void show() { public void show() {
collectUserInformation(); collectUserInformation();
showDesignerFrame(false); showDesignerFrame(false);
DesignerContext.getDesignerFrame().setVisible(true);
//TODO: 2019-06-14 这里有啥作用?
DesignerContext.getDesignerFrame().refreshEnv(); DesignerContext.getDesignerFrame().refreshEnv();
for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) { for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) {
TemplateTreePane.getInstance().getTemplateFileTree().refresh(); TemplateTreePane.getInstance().getTemplateFileTree().refresh();
} }
DesignerContext.getDesignerFrame().setVisible(true);
DesignerContext.getDesignerFrame().resizeFrame();
} }

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

@ -1,21 +1,11 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.event.Event;
import com.fr.event.Listener;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.record.analyzer.Metrics; import com.fr.record.analyzer.Metrics;
import com.fr.runtime.FineRuntime; import com.fr.runtime.FineRuntime;
import com.fr.start.DesignerInitial;
import com.fr.start.ServerStarter; import com.fr.start.ServerStarter;
import com.fr.start.server.FineEmbedServer;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/** /**
* Created by juhaoyu on 2018/1/8. * Created by juhaoyu on 2018/1/8.
@ -31,7 +21,6 @@ public class DesignerStartup extends Activator {
getSub("parallel").start(); getSub("parallel").start();
//designer模块启动好后,查看demo //designer模块启动好后,查看demo
browserDemo(); browserDemo();
startSub(DesignerShowActivator.class); startSub(DesignerShowActivator.class);
startSub(StartFinishActivator.class); startSub(StartFinishActivator.class);
FineRuntime.startFinish(); FineRuntime.startFinish();

64
designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

@ -3,14 +3,17 @@ package com.fr.start.module;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.fun.OemProcessor; import com.fr.design.fun.OemProcessor;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateInfoCollector;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.DesignerPort; import com.fr.design.utils.DesignerPort;
import com.fr.event.EventDispatcher;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.module.ModuleEvent;
import com.fr.stable.BuildContext; import com.fr.stable.BuildContext;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
@ -30,10 +33,10 @@ import java.util.concurrent.Executors;
* Created by juhaoyu on 2018/1/8. * Created by juhaoyu on 2018/1/8.
*/ */
public class PreStartActivator extends Activator { public class PreStartActivator extends Activator {
@Override @Override
public void start() { public void start() {
BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
// 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了 // 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了
final String[] args = getModule().upFindSingleton(StartupArgs.class).get(); final String[] args = getModule().upFindSingleton(StartupArgs.class).get();
@ -45,87 +48,98 @@ public class PreStartActivator extends Activator {
System.exit(0); System.exit(0);
return; return;
} }
RestartHelper.deleteRecordFilesWhenStart(); RestartHelper.deleteRecordFilesWhenStart();
preloadResource(); preloadResource();
SplashContext.getInstance().registerSplash(createSplash()); SplashContext.getInstance().registerSplash(createSplash());
SplashContext.getInstance().show(); SplashContext.getInstance().show();
//初始化
EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Basic_Initializing"));
// 完成初始化 // 完成初始化
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
CloudCenter.getInstance(); CloudCenter.getInstance();
// 创建监听服务 // 创建监听服务
DesignUtils.createListeningServer(DesignUtils.getPort(), startFileSuffix()); DesignUtils.createListeningServer(DesignUtils.getPort(), startFileSuffix());
initLanguage(); initLanguage();
} }
@Override @Override
public void stop() { public void stop() {
} }
private void checkDebugStart() { private void checkDebugStart() {
if (isDebug()) { if (isDebug()) {
setDebugEnv(); setDebugEnv();
} }
} }
/** /**
* 在VM options里加入-Ddebug=true激活 * 在VM options里加入-Ddebug=true激活
* *
* @return isDebug * @return isDebug
*/ */
private boolean isDebug() { private boolean isDebug() {
return ComparatorUtils.equals("true", System.getProperty("debug")); return ComparatorUtils.equals("true", System.getProperty("debug"));
} }
//端口改一下,环境配置文件改一下。便于启动两个设计器,进行对比调试 //端口改一下,环境配置文件改一下。便于启动两个设计器,进行对比调试
private void setDebugEnv() { private void setDebugEnv() {
DesignUtils.setPort(DesignerPort.DEBUG_MESSAGE_PORT); DesignUtils.setPort(DesignerPort.DEBUG_MESSAGE_PORT);
String debugXMlFilePath = StableUtils.pathJoin( String debugXMlFilePath = StableUtils.pathJoin(
ProductConstants.getEnvHome(), ProductConstants.getEnvHome(),
ProductConstants.APP_NAME + "Env_debug.xml" ProductConstants.APP_NAME + "Env_debug.xml"
); );
DesignerEnvManager.setEnvFile( DesignerEnvManager.setEnvFile(
new File(debugXMlFilePath)); new File(debugXMlFilePath));
} }
private void initLanguage() { private void initLanguage() {
//这两句的位置不能随便调换,因为会影响语言切换的问题 //这两句的位置不能随便调换,因为会影响语言切换的问题
GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLanguage()); GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLanguage());
} }
private String[] startFileSuffix() { private String[] startFileSuffix() {
return new String[]{".cpt", ".xls", ".xlsx", ".frm", ".form", ".cht", ".chart"}; return new String[]{".cpt", ".xls", ".xlsx", ".frm", ".form", ".cht", ".chart"};
} }
private static void preloadResource() { private static void preloadResource() {
ExecutorService service = Executors.newCachedThreadPool(); ExecutorService service = Executors.newCachedThreadPool();
service.submit(new Runnable() { service.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
new ImagePreLoader(); new ImagePreLoader();
} }
}); });
service.submit(new Runnable() { service.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
TemplateInfoCollector.getInstance(); TemplateInfoCollector.getInstance();
} }
}); });
service.shutdown(); service.shutdown();
} }
private SplashStrategy createSplash() { private SplashStrategy createSplash() {
OemProcessor oemProcessor = OemHandler.findOem(); OemProcessor oemProcessor = OemHandler.findOem();
if (oemProcessor != null) { if (oemProcessor != null) {
SplashStrategy splashStrategy = null; SplashStrategy splashStrategy = null;

Loading…
Cancel
Save