You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
4.0 KiB
109 lines
4.0 KiB
package com.fr.start.module; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
import com.fr.design.EnvChangeEntrance; |
|
import com.fr.design.constants.DesignerLaunchStatus; |
|
import com.fr.design.editlock.ConnectionLockChangeChecker; |
|
import com.fr.design.editlock.ServerTableDataLockChangeChecker; |
|
import com.fr.design.env.DesignerWorkspaceGenerator; |
|
import com.fr.design.env.DesignerWorkspaceInfo; |
|
import com.fr.design.plugin.remind.PluginErrorDesignReminder; |
|
import com.fr.design.versioncheck.VersionCheckUtils; |
|
import com.fr.env.utils.WorkspaceUtils; |
|
import com.fr.event.Event; |
|
import com.fr.event.EventDispatcher; |
|
import com.fr.event.Listener; |
|
import com.fr.event.Null; |
|
import com.fr.log.FineLoggerFactory; |
|
import com.fr.module.Activator; |
|
import com.fr.value.NotNullLazyValue; |
|
import com.fr.workspace.WorkContext; |
|
import com.fr.workspace.Workspace; |
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
/** |
|
* Created by juhaoyu on 2018/1/8. |
|
* 设计器启动时的环境相关模块activator |
|
*/ |
|
public class DesignerWorkspaceProvider extends Activator { |
|
|
|
|
|
private NotNullLazyValue<StartupArgs> startupArgs = new NotNullLazyValue<StartupArgs>() { |
|
@NotNull |
|
@Override |
|
protected StartupArgs compute() { |
|
return findSingleton(StartupArgs.class); |
|
} |
|
}; |
|
|
|
@Override |
|
public void start() { |
|
//检查环境 |
|
DesignerEnvManager.checkNameEnvMap(); |
|
|
|
if (startupArgs.getValue().isDemo()) { |
|
DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); |
|
} else { |
|
DesignerWorkspaceInfo workspaceInfo = null; |
|
try { |
|
String current = DesignerEnvManager.getEnvManager().getCurEnvName(); |
|
workspaceInfo = WorkspaceUtils.getWorkspaceInfo(); |
|
Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo); |
|
boolean checkValid = workspace != null && workspaceInfo.checkValid(); |
|
if (!checkValid) { |
|
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(null, workspaceInfo); |
|
} else { |
|
WorkContext.switchTo(workspace); |
|
//在设计器完全启动完成后,对初始环境进行一次服务检测,对主要功能无影响,异常仅做日志提示即可 |
|
final String selectEnv = current; |
|
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() { |
|
@Override |
|
public void on(Event event, Null aNull) { |
|
try { |
|
VersionCheckUtils.showVersionCheckDialog(selectEnv); |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().warn("Check Service Failed"); |
|
} |
|
} |
|
}); |
|
} |
|
} catch (Throwable e) { |
|
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(e, workspaceInfo); |
|
} |
|
} |
|
pluginErrorRemind(); |
|
editLockCheckerStart(); |
|
} |
|
|
|
private void editLockCheckerStart() { |
|
ConnectionLockChangeChecker.getInstance().start(); |
|
ServerTableDataLockChangeChecker.getInstance().start(); |
|
} |
|
|
|
private void pluginErrorRemind() { |
|
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() { |
|
@Override |
|
public void on(Event event, Null aNull) { |
|
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); |
|
PluginErrorDesignReminder.getInstance().remindInvalidatePlugins(); |
|
} |
|
}); |
|
} |
|
|
|
@Override |
|
public void stop() { |
|
// void |
|
editLockCheckerStop(); |
|
} |
|
|
|
private void editLockCheckerStop() { |
|
ConnectionLockChangeChecker.getInstance().stop(); |
|
ServerTableDataLockChangeChecker.getInstance().stop(); |
|
} |
|
|
|
@Override |
|
public void afterAllStart() { |
|
DesignerLaunchStatus.setStatus(DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE); |
|
} |
|
}
|
|
|