forked from fanruan/design
Wim.Zhai
6 years ago
4 changed files with 60 additions and 58 deletions
@ -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(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,33 +1,46 @@ |
|||||||
package com.fr.start.module; |
package com.fr.start.module; |
||||||
|
|
||||||
import com.fr.design.DesignerEnvManager; |
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.module.Activator; |
||||||
import com.fr.start.EnvSwitcher; |
import com.fr.workspace.WorkContext; |
||||||
|
import com.fr.workspace.Workspace; |
||||||
|
|
||||||
/** |
/** |
||||||
* Created by juhaoyu on 2018/1/8. |
* Created by juhaoyu on 2018/1/8. |
||||||
* 设计器启动时的环境相关模块activator |
* 设计器启动时的环境相关模块activator |
||||||
*/ |
*/ |
||||||
public class DesignerWorkspaceProvider extends Activator { |
public class DesignerWorkspaceProvider extends Activator { |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void start() { |
public void start() { |
||||||
//检查环境
|
//检查环境
|
||||||
DesignerEnvManager.checkNameEnvMap(); |
DesignerEnvManager.checkNameEnvMap(); |
||||||
|
|
||||||
EnvSwitcher switcher = new EnvSwitcher(); |
if (getModule().leftFindSingleton(StartupArgs.class) != null && getModule().leftFindSingleton(StartupArgs.class).isDemo()) { |
||||||
//设置好环境即可,具体跟环境有关的模块会自动调用
|
DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); |
||||||
switcher.switch2LastEnv(); |
} else { |
||||||
getRoot().setSingleton(EnvSwitcher.class, switcher); |
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 |
@Override |
||||||
public void stop() { |
public void stop() { |
||||||
//清空模块
|
|
||||||
getRoot().removeSingleton(EnvSwitcher.class); |
|
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue