From 2605a1a869e5711c78bed205d8b809eaba855ee6 Mon Sep 17 00:00:00 2001 From: ju Date: Tue, 24 Oct 2017 17:04:36 +0800 Subject: [PATCH 1/3] REPORT-5217 --- designer_base/src/com/fr/start/BaseDesigner.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java index d299a8cdd..34d2bb243 100644 --- a/designer_base/src/com/fr/start/BaseDesigner.java +++ b/designer_base/src/com/fr/start/BaseDesigner.java @@ -67,10 +67,6 @@ public abstract class BaseDesigner extends ToolBarMenuDock { ConfigManagerFactory.registerConfigManagerProxy(new ConfigManagerCreatorProxy()); //启动core BuildContext.setBuildFilePath(buildPropertiesPath()); - Register.load(); - //标记一下是设计器启动 - PluginConversionModule.getInstance().markDesignerStart(); - SiteCenter.getInstance(); if (isDebug()) { setDebugEnv(); @@ -82,6 +78,11 @@ public abstract class BaseDesigner extends ToolBarMenuDock { DesignUtils.clientSend(args); return; } + + Register.load(); + //标记一下是设计器启动 + PluginConversionModule.getInstance().markDesignerStart(); + SiteCenter.getInstance(); //下面这两句的位置不能随便调换,因为会影响语言切换的问题 initLanguage(); From 2f686922d85ff4555f2900c650aebcc15e586773 Mon Sep 17 00:00:00 2001 From: ju Date: Wed, 25 Oct 2017 14:33:38 +0800 Subject: [PATCH 2/3] pmd --- .../src/com/fr/start/BaseDesigner.java | 87 ++++++++++--------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java index 34d2bb243..448e4f414 100644 --- a/designer_base/src/com/fr/start/BaseDesigner.java +++ b/designer_base/src/com/fr/start/BaseDesigner.java @@ -100,43 +100,47 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } } } - + initLookAndFeel(args, splashWindow); + } + + private void initLookAndFeel(String[] args, SplashWindow splashWindow) { + // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 DesignUtils.initLookAndFeel(); - + DesignUtils.creatListeningServer(getStartPort(), startFileSuffix()); - + // 初始化Log Handler DesignerEnvManager.loadLogSetting(); DesignerFrame df = createDesignerFrame(); - + // 默认加载工作目录,用于读取License switch2LastEnv(); - + initDefaultFont(); //PluginManager要在环境切换和模块启动之前初始化 PluginManager.registerEnvListener(); // 必须先初始化Env再去startModule, 不然会导致lic读取不到 ModuleContext.startModule(module2Start()); - + // 再次加载工作目录,用于读取工作目录下的各种插件 switch2LastEnv(); - + ModuleContext.clearModuleListener(); collectUserInformation(); showDesignerFrame(args, df, false); for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) { TemplateTreePane.getInstance().getTemplateFileTree().refresh(); } - + splashWindow.setVisible(false); splashWindow.dispose(); - + bindGlobalListener(); - + showErrorPluginsMessage(); } - + private void bindGlobalListener() { GlobalListenerProviderManager.getInstance().init(); @@ -251,32 +255,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { file = FILEFactory.createFILE(FILEFactory.ENV_PREFIX + DesignerEnvManager.getEnvManager().getLastOpenFile()); } - - //启动时打开指定文件的接口 - DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG); - if (processor != null) { - FILE f = processor.fileToShow(); - if (f != null) { - file = f;//避免null - } else { - isException = true;//此时有文件nullpointer异常,执行打开空文件 - } - } - if (file.exists() && !isException) { - df.openTemplate(file); - } else { - df.addAndActivateJTemplate(); - MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - } - if (OperatingSystem.isMacOS()) { - enableFullScreenMode(df); - } - df.addWindowListener(new WindowAdapter() { - public void windowOpened(WindowEvent e) { - df.getSelectedJTemplate().requestGridFocus(); - } - }); - df.setVisible(true); + isException = openFile(df, isException, file); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage(), e); if (!isException) { @@ -286,8 +265,38 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } } } - - + + private boolean openFile(final DesignerFrame df, boolean isException, FILE file) { + + //启动时打开指定文件的接口 + DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG); + if (processor != null) { + FILE f = processor.fileToShow(); + if (f != null) { + file = f;//避免null + } else { + isException = true;//此时有文件nullpointer异常,执行打开空文件 + } + } + if (file.exists() && !isException) { + df.openTemplate(file); + } else { + df.addAndActivateJTemplate(); + MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + } + if (OperatingSystem.isMacOS()) { + enableFullScreenMode(df); + } + df.addWindowListener(new WindowAdapter() { + public void windowOpened(WindowEvent e) { + df.getSelectedJTemplate().requestGridFocus(); + } + }); + df.setVisible(true); + return isException; + } + + /** * @param window */ From d0c789075f3409ce4de745837f1ac49ed3dc63b5 Mon Sep 17 00:00:00 2001 From: ju Date: Wed, 25 Oct 2017 14:36:47 +0800 Subject: [PATCH 3/3] pmd --- .../src/com/fr/start/BaseDesigner.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java index 448e4f414..47e53bd72 100644 --- a/designer_base/src/com/fr/start/BaseDesigner.java +++ b/designer_base/src/com/fr/start/BaseDesigner.java @@ -62,12 +62,17 @@ public abstract class BaseDesigner extends ToolBarMenuDock { private Timer timer; public BaseDesigner(String[] args) { - + + init(args); + } + + private void init(String[] args) { + RestartHelper.deleteRecordFilesWhenStart(); ConfigManagerFactory.registerConfigManagerProxy(new ConfigManagerCreatorProxy()); //启动core BuildContext.setBuildFilePath(buildPropertiesPath()); - + if (isDebug()) { setDebugEnv(); } else { @@ -83,13 +88,13 @@ public abstract class BaseDesigner extends ToolBarMenuDock { //标记一下是设计器启动 PluginConversionModule.getInstance().markDesignerStart(); SiteCenter.getInstance(); - + //下面这两句的位置不能随便调换,因为会影响语言切换的问题 initLanguage(); - + // 在 initLanguage 之后加载设计器国际化文件,确保是正确的语言环境 Inter.loadLocaleFile(GeneralContext.getLocale(), DesignModule.LOCALE_FILE_PATH); - + SplashWindow splashWindow = new SplashWindow(createSplashPane()); if (args != null) { for (String arg : args) { @@ -204,7 +209,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock { //在VM options里加入-Ddebug=true激活 private boolean isDebug() { - return "true".equals(System.getProperty("debug")); + + return ComparatorUtils.equals("true", System.getProperty("debug")); } private static final int DEBUG_PORT = 51463;