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. 31
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  3. 35
      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();
}
}
}

31
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,6 +27,7 @@ public class DesignerStartup extends Activator {
@Override
@Metrics
public void start() {
startSub(PreStartActivator.class);
//启动基础部分
startSub(BasicActivator.class);
@ -38,20 +38,14 @@ public class DesignerStartup extends Activator {
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();
}
@ -63,6 +57,21 @@ public class DesignerStartup extends Activator {
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;
}
}
}
}
/**

35
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.
@ -16,17 +19,33 @@ public class DesignerWorkspaceProvider extends Activator {
//检查环境
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