Browse Source

无JIRA任务 预览demo有问题

设置环境和预览demo分开,预览demo不触发第二次切环境
master
ju 6 years ago
parent
commit
ec3b3eea4c
  1. 29
      designer-realize/src/main/java/com/fr/start/EnvSwitcher.java
  2. 37
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  3. 37
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

29
designer-realize/src/main/java/com/fr/start/EnvSwitcher.java

@ -1,29 +0,0 @@
package com.fr.start;
import com.fr.design.DesignerEnvManager;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.mainframe.TemplatePane;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
/**
* Created by juhaoyu on 2018/1/31.
* 环境切换器
*/
public class EnvSwitcher {
public void switch2LastEnv() {
try {
String current = DesignerEnvManager.getEnvManager().getCurEnvName();
Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getWorkspaceInfo(current));
if (workspace == null) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
} else {
WorkContext.switchTo(workspace);
}
} catch (Throwable e) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
}
}
}

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

@ -1,7 +1,6 @@
package com.fr.start.module;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event;
import com.fr.event.Listener;
@ -28,30 +27,25 @@ public class DesignerStartup extends Activator {
@Override
@Metrics
public void start() {
startSub(PreStartActivator.class);
//启动基础部分
startSub(BasicActivator.class);
final String[] args = getModule().upFindSingleton(StartupArgs.class).get();
final Designer designer = new Designer(args);
startSub(DesignerWorkspaceProvider.class);
registerEnvListener();
//启动env
startSub(EnvBasedModule.class);
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
break;
}
}
}
//designer模块启动好后,查看demo
browserDemo();
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(new Runnable() {
@Override
public void run() {
designer.show(args);
DesignerContext.getDesignerFrame().getProgressDialog().dispose();
}
@ -60,11 +54,26 @@ public class DesignerStartup extends Activator {
DesignerContext.getDesignerFrame().setVisible(true);
//启动画面结束
SplashContext.getInstance().hide();
DesignerContext.getDesignerFrame().getProgressDialog().setVisible(true);
startSub(StartFinishActivator.class);
}
private void browserDemo() {
final String[] args = getModule().upFindSingleton(StartupArgs.class).get();
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
ServerStarter.browserDemoURL();
break;
}
}
}
}
/**
* 切换环境时重新启动所有相关模块
*/

37
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

@ -1,9 +1,12 @@
package com.fr.start.module;
import com.fr.design.DesignerEnvManager;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.mainframe.TemplatePane;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator;
import com.fr.start.EnvSwitcher;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
/**
* Created by juhaoyu on 2018/1/8.
@ -15,18 +18,34 @@ public class DesignerWorkspaceProvider extends Activator {
public void start() {
//检查环境
DesignerEnvManager.checkNameEnvMap();
EnvSwitcher switcher = new EnvSwitcher();
//设置好环境即可,具体跟环境有关的模块会自动调用
switcher.switch2LastEnv();
getRoot().setSingleton(EnvSwitcher.class, switcher);
final String[] args = getModule().upFindSingleton(StartupArgs.class).get();
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
break;
}
}
} else {
try {
String current = DesignerEnvManager.getEnvManager().getCurEnvName();
Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getWorkspaceInfo(current));
if (workspace == null) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
} else {
WorkContext.switchTo(workspace);
}
} catch (Throwable e) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
}
}
}
@Override
public void stop() {
//清空模块
getRoot().removeSingleton(EnvSwitcher.class);
}

Loading…
Cancel
Save