Browse Source

Merge pull request #318 in DESIGN/design from ~JU/design:release/10.0 to release/10.0

* commit '1ff55110dc3af9154fd7f5d3b94b4e46a26ed5ff':
  无JIRA任务 预览demo有问题 设置环境和预览demo分开,预览demo不触发第二次切环境
  无JIRA任务 预览demo有问题 设置环境和预览demo分开,预览demo不触发第二次切环境
research/10.0
ju 6 years ago
parent
commit
1e1db5ce96
  1. 29
      designer-realize/src/main/java/com/fr/start/EnvSwitcher.java
  2. 25
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  3. 29
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java
  4. 17
      designer-realize/src/main/java/com/fr/start/module/StartupArgs.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();
}
}
}

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

@ -1,11 +1,9 @@
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;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.record.analyzer.Metrics;
@ -28,6 +26,7 @@ public class DesignerStartup extends Activator {
@Override
@Metrics
public void start() {
startSub(PreStartActivator.class);
//启动基础部分
startSub(BasicActivator.class);
@ -38,20 +37,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 +56,14 @@ public class DesignerStartup extends Activator {
DesignerContext.getDesignerFrame().getProgressDialog().setVisible(true);
startSub(StartFinishActivator.class);
}
private void browserDemo() {
if (getModule().leftFindSingleton(StartupArgs.class) != null && getModule().leftFindSingleton(StartupArgs.class).isDemo()) {
ServerStarter.browserDemoURL();
}
}
/**

29
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,27 @@ public class DesignerWorkspaceProvider extends Activator {
//检查环境
DesignerEnvManager.checkNameEnvMap();
EnvSwitcher switcher = new EnvSwitcher();
//设置好环境即可,具体跟环境有关的模块会自动调用
switcher.switch2LastEnv();
getRoot().setSingleton(EnvSwitcher.class, switcher);
if (getModule().leftFindSingleton(StartupArgs.class) != null && getModule().leftFindSingleton(StartupArgs.class).isDemo()) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
} 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);
}

17
designer-realize/src/main/java/com/fr/start/module/StartupArgs.java

@ -1,5 +1,7 @@
package com.fr.start.module;
import com.fr.general.ComparatorUtils;
/**
* Created by juhaoyu on 2018/1/8.
* 封装启动参数
@ -17,5 +19,20 @@ public class StartupArgs {
return args;
}
/**
* 是否是产品演示
*/
public boolean isDemo() {
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
return true;
}
}
}
return false;
}
}

Loading…
Cancel
Save