Browse Source
* commit '9e5883970654d0ca025911e8764a7e1d68645436': DEC-472 新模块划分与启动、关闭框架 修改设计器启动时到新Module形式 DEC-472 新模块划分与启动、关闭框架 修改设计器启动时到新Module形式master
superman
7 years ago
11 changed files with 319 additions and 273 deletions
@ -1,86 +0,0 @@
|
||||
package com.fr.start; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.actions.file.newReport.NewWorkBookAction; |
||||
import com.fr.design.actions.report.ReportFooterAction; |
||||
import com.fr.design.actions.report.ReportHeaderAction; |
||||
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; |
||||
import com.fr.design.menu.MenuDef; |
||||
import com.fr.design.menu.ShortCut; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.stable.Constants; |
||||
|
||||
/** |
||||
* Created with IntelliJ IDEA. |
||||
* User: richie |
||||
* Date: 12/17/13 |
||||
* Time: 12:54 PM |
||||
* 这是英文版的GridBI设计器启动类 |
||||
*/ |
||||
public class Designer4BI extends Designer { |
||||
|
||||
/** |
||||
* 启动BI的设计器 |
||||
* |
||||
* @param args 参数 |
||||
* |
||||
*/ |
||||
public static void main(String[] args) { |
||||
new Designer4BI(args); |
||||
} |
||||
|
||||
public Designer4BI(String[] args) { |
||||
super(args); |
||||
} |
||||
|
||||
protected void initLanguage() { |
||||
//这两句的位置不能随便调换,因为会影响语言切换的问题
|
||||
FRContext.setLanguage(Constants.LANGUAGE_ENGLISH); |
||||
} |
||||
|
||||
protected SplashPane createSplashPane() { |
||||
return new BISplashPane(); |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* 创建新建文件的快捷方式数组。 |
||||
* @return 返回快捷方式的数组 |
||||
*/ |
||||
public ShortCut[] createNewFileShortCuts() { |
||||
ArrayList<ShortCut> shortCuts = new ArrayList<ShortCut>(); |
||||
shortCuts.add(new NewWorkBookAction()); |
||||
return shortCuts.toArray(new ShortCut[shortCuts.size()]); |
||||
} |
||||
|
||||
/** |
||||
* 获取模板-菜单选项 |
||||
* |
||||
* @param plus 当前的工作对象 |
||||
* |
||||
* @return 菜单栏对象数组 |
||||
* |
||||
*/ |
||||
public MenuDef[] createTemplateShortCuts(ToolBarMenuDockPlus plus) { |
||||
MenuDef[] menuDefs = plus.menus4Target(); |
||||
for (MenuDef m : menuDefs) { |
||||
List<ShortCut> shortCuts = new ArrayList<ShortCut>(); |
||||
for (int i = 0, count = m.getShortCutCount(); i < count; i++) { |
||||
ShortCut shortCut = m.getShortCut(i); |
||||
if (!ComparatorUtils.equals(shortCut.getClass(), ReportHeaderAction.class) |
||||
&& !ComparatorUtils.equals(shortCut.getClass(), ReportFooterAction.class)) { |
||||
shortCuts.add(shortCut); |
||||
} |
||||
} |
||||
m.clearShortCuts(); |
||||
for (int i = 0, len = shortCuts.size(); i < len; i ++) { |
||||
m.addShortCut(shortCuts.get(i)); |
||||
} |
||||
|
||||
} |
||||
return menuDefs; |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.fr.start.module; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.mainframe.TemplatePane; |
||||
import com.fr.design.module.DesignerModule; |
||||
import com.fr.env.SignIn; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.ModuleContext; |
||||
import com.fr.module.Activator; |
||||
import com.fr.stable.module.ModuleListener; |
||||
import com.fr.start.StartServer; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2018/1/8. |
||||
* 设计器启动时的环境相关模块activator |
||||
*/ |
||||
public class DesignerEnvActivator extends Activator { |
||||
|
||||
@Override |
||||
public void start() { |
||||
|
||||
String[] args = getModule().findSingleton(StartupArgs.class).get(); |
||||
if (args != null) { |
||||
for (String arg : args) { |
||||
if (ComparatorUtils.equals(arg, "demo")) { |
||||
DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); |
||||
StartServer.browserDemoURL(); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
//设置好环境即可,具体跟环境有关的模块会自动调用
|
||||
switch2LastEnv(); |
||||
//启动core部分
|
||||
getSub("core").start(); |
||||
//启动其他模块
|
||||
//todo 也切换到新Module
|
||||
ModuleContext.registerModuleListener(getModule().findSingleton(ModuleListener.class)); |
||||
ModuleContext.startModule(DesignerModule.class.getName()); |
||||
} |
||||
|
||||
|
||||
private void switch2LastEnv() { |
||||
|
||||
try { |
||||
String current = DesignerEnvManager.getEnvManager().getCurEnvName(); |
||||
SignIn.signIn(DesignerEnvManager.getEnvManager().getEnv(current)); |
||||
if (!FRContext.getCurrentEnv().testServerConnectionWithOutShowMessagePane()) { |
||||
throw new Exception(Inter.getLocText("Datasource-Connection_failed")); |
||||
} |
||||
} catch (Exception e) { |
||||
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void stop() { |
||||
//清空模块
|
||||
} |
||||
} |
@ -0,0 +1,101 @@
|
||||
package com.fr.start.module; |
||||
|
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.utils.DesignUtils; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.module.Activator; |
||||
import com.fr.stable.ProductConstants; |
||||
import com.fr.stable.module.ModuleListener; |
||||
import com.fr.start.Designer; |
||||
import com.fr.start.ReportSplashPane; |
||||
import com.fr.start.SplashWindow; |
||||
import com.fr.startup.activators.BasicActivator; |
||||
|
||||
import java.io.File; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2018/1/8. |
||||
*/ |
||||
public class DesignerStartup extends Activator { |
||||
|
||||
private static final int MESSAGE_PORT = 51462; |
||||
|
||||
private static final int DEBUG_PORT = 51463; |
||||
|
||||
@Override |
||||
public void start() { |
||||
|
||||
startSub(PreStartActivator.class); |
||||
|
||||
if (checkMultiStart()) { |
||||
return; |
||||
} |
||||
//启动基础部分
|
||||
startSub(BasicActivator.class); |
||||
//启动画面
|
||||
SplashWindow splashWindow = createSplashWindow(); |
||||
//启动env
|
||||
startSub(DesignerEnvActivator.class); |
||||
//启动设计器界面
|
||||
startDesigner(); |
||||
//启动画面结束
|
||||
splashWindow.setVisible(false); |
||||
splashWindow.dispose(); |
||||
startSub(StartFinishActivator.class); |
||||
} |
||||
|
||||
private SplashWindow createSplashWindow() { |
||||
|
||||
ReportSplashPane reportSplashPane = new ReportSplashPane(); |
||||
SplashWindow splashWindow = new SplashWindow(reportSplashPane); |
||||
getModule().setSingleton(ModuleListener.class, reportSplashPane.getModuleListener()); |
||||
return splashWindow; |
||||
} |
||||
|
||||
|
||||
private void startDesigner() { |
||||
|
||||
new Designer(getModule().getSingleton(StartupArgs.class).get()); |
||||
} |
||||
|
||||
private boolean checkMultiStart() { |
||||
|
||||
if (isDebug()) { |
||||
setDebugEnv(); |
||||
} else { |
||||
DesignUtils.setPort(getStartPort()); |
||||
} |
||||
// 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了
|
||||
if (DesignUtils.isStarted()) { |
||||
DesignUtils.clientSend(getModule().findSingleton(StartupArgs.class).get()); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
private int getStartPort() { |
||||
|
||||
return MESSAGE_PORT; |
||||
} |
||||
|
||||
|
||||
//在VM options里加入-Ddebug=true激活
|
||||
private boolean isDebug() { |
||||
|
||||
return ComparatorUtils.equals("true", System.getProperty("debug")); |
||||
} |
||||
|
||||
|
||||
//端口改一下,环境配置文件改一下。便于启动两个设计器,进行对比调试
|
||||
private void setDebugEnv() { |
||||
|
||||
DesignUtils.setPort(DEBUG_PORT); |
||||
DesignerEnvManager.setEnvFile(new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "Env_debug.xml")); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void stop() { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.start.module; |
||||
|
||||
import com.fr.base.ConfigManagerCreatorProxy; |
||||
import com.fr.base.ConfigManagerFactory; |
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.RestartHelper; |
||||
import com.fr.design.module.DesignModule; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.module.Activator; |
||||
import com.fr.plugin.conversion.PluginConversionModule; |
||||
import com.fr.stable.BuildContext; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2018/1/8. |
||||
*/ |
||||
public class PreStartActivator extends Activator { |
||||
|
||||
@Override |
||||
public void start() { |
||||
|
||||
RestartHelper.deleteRecordFilesWhenStart(); |
||||
ConfigManagerFactory.registerConfigManagerProxy(new ConfigManagerCreatorProxy()); |
||||
BuildContext.setBuildFilePath(buildPropertiesPath()); |
||||
SiteCenter.getInstance(); |
||||
//标记一下是设计器启动
|
||||
PluginConversionModule.getInstance().markDesignerStart(); |
||||
initLanguage(); |
||||
|
||||
// 在 initLanguage 之后加载设计器国际化文件,确保是正确的语言环境
|
||||
Inter.loadLocaleFile(GeneralContext.getLocale(), DesignModule.LOCALE_FILE_PATH); |
||||
} |
||||
|
||||
private void initLanguage() { |
||||
//这两句的位置不能随便调换,因为会影响语言切换的问题
|
||||
FRContext.setLanguage(DesignerEnvManager.getEnvManager(false).getLanguage()); |
||||
DesignerEnvManager.checkNameEnvMap(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* build得路径 |
||||
*/ |
||||
private String buildPropertiesPath() { |
||||
|
||||
return "/com/fr/stable/build.properties"; |
||||
} |
||||
|
||||
@Override |
||||
public void stop() { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.start.module; |
||||
|
||||
import com.fr.design.fun.impl.GlobalListenerProviderManager; |
||||
import com.fr.design.utils.DesignUtils; |
||||
import com.fr.general.ModuleContext; |
||||
import com.fr.module.Activator; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2018/1/8. |
||||
*/ |
||||
public class StartFinishActivator extends Activator { |
||||
|
||||
private static final int MESSAGE_PORT = 51462; |
||||
|
||||
@Override |
||||
public void start() { |
||||
|
||||
DesignUtils.creatListeningServer(getStartPort(), startFileSuffix()); |
||||
ModuleContext.clearModuleListener(); |
||||
GlobalListenerProviderManager.getInstance().init(); |
||||
} |
||||
|
||||
private int getStartPort() { |
||||
|
||||
return MESSAGE_PORT; |
||||
} |
||||
|
||||
|
||||
private String[] startFileSuffix() { |
||||
|
||||
return new String[]{".cpt", ".xls", ".xlsx", ".frm", ".form", ".cht", ".chart"}; |
||||
} |
||||
|
||||
@Override |
||||
public void stop() { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.start.module; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2018/1/8. |
||||
* 封装启动参数 |
||||
*/ |
||||
public class StartupArgs { |
||||
|
||||
private final String[] args; |
||||
|
||||
public StartupArgs(String[] args) { |
||||
|
||||
this.args = args; |
||||
} |
||||
|
||||
public String[] get() { |
||||
|
||||
return args; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!--设计器环境模块--> |
||||
<designer-env activator="com.fr.start.module.DesignerEnvActivator" invoke-children-strategy="custom"> |
||||
<core ref="/com/fr/startup/config/module-core.xml"/> |
||||
<!--todo 现在存在的这些个模块--> |
||||
</designer-env> |
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<startup-designer activator="com.fr.start.module.DesignerStartup" invoke-children-strategy="custom"> |
||||
<!--启动前的准备工作--> |
||||
<pre-start activator="com.fr.start.module.PreStartActivator"/> |
||||
<basic ref="/com/fr/startup/config/module-basic.xml"/> |
||||
<!--环境相关模块--> |
||||
<designer-env ref="/com/fr/start/module/module-designer-env.xml"/> |
||||
<!--启动完成后的清理工作--> |
||||
<start-finish activator="com.fr.start.module.StartFinishActivator"/> |
||||
</startup-designer> |
Loading…
Reference in new issue